Lua Programming Help Thread
This is a discussion on Lua Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Thats because it only goes through the function if you hold X. And the function distracts/adds from y only once ...
-
03-07-2006, 03:39 PM #601
Thats because it only goes through the function if you hold X. And the function distracts/adds from y only once and only if you hold X. If you want to make it do a full jump, then you can add a special variable, and if that var is say 1, then you let it do your functon. If its 0 then it wont. I hope its clear enough, im kinda drunk lol>
LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
03-07-2006, 03:55 PM #602QJ Gamer Blue
- Registriert seit
- Feb 2006
- Beiträge
- 224
- Points
- 5.036
- Level
- 45
- Downloads
- 0
- Uploads
- 0
Lol thanks, I put jump = false and in the jump function I put if jump==true then ... the rest of the function then jump = false so it stops jumping.... and if pad:cross() then jump = true .. works now thanks Alatair!
-
03-07-2006, 05:59 PM #603QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 375
- Points
- 5.631
- Level
- 48
- Downloads
- 0
- Uploads
- 0
of that was the solution to the problem. now i just have to do collision and what to do when the poles reach the endof the screen. ill probly need help somewhere in there
-
03-08-2006, 02:36 AM #604
sure no prob. I'll try and help anybody who i can help!
LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
03-08-2006, 03:34 AM #605is not posting very often

- Registriert seit
- Feb 2006
- Ort
- omnipresent
- Beiträge
- 5.162
- Points
- 33.152
- Level
- 100
- Downloads
- 0
- Uploads
- 0
What happened is I blitted the cursor at X, Y and it said that the value was nil
if i said X = 100, Y = 100, it didn't move even though the code said X = X+1, so... im confused
-
03-08-2006, 03:40 AM #606
Heres what i used for my cursor:
This works perfectly for me. Dont just copy it, but also see if you understand it.Code:mouse=Image.load('mouse.png') x=240 y=136 while true do screen:blit(x, y, mouse, 0, 0, mouse:width(), mouse:height()) pad = Controls.read() dx = pad:analogX() if math.abs(dx) > 32 then x = x + dx / 32 end dy = pad:analogY() if math.abs(dy) > 32 then y = y + dy / 32 end screen.waitVblankStart() screen:flip() endLUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
03-08-2006, 07:00 AM #607QJ Gamer Blue
- Registriert seit
- Feb 2006
- Beiträge
- 224
- Points
- 5.036
- Level
- 45
- Downloads
- 0
- Uploads
- 0
I need a little help getting my gun to work in lua
if pad:cross() then
shootright()
end
how would I make it so it does shootright() when I just tap X instead of while I hold it?
is it a different command to make it read the pad or something?
I already tried using variables like..
shootis = false
function shootright()
if shootis==true then
if shoottime>=1 then
bulletx = bulletx + 50
shoottime = 0
shoottime = shoottime + 1
end
end
end
if pad:cross() then
shootis = true
shootright()
end
But it still meant I had to hold in the cross button...
so does anyone know if there is a way to make it happen on 1 tap of the cross button??
thanks...
-
03-08-2006, 07:05 AM #60811th Squad Captain
- Registriert seit
- Jun 2005
- Ort
- You are here -----> 名前: アダム | 飲むコー
- Beiträge
- 2.562
- Points
- 26.490
- Level
- 97
- Downloads
- 0
- Uploads
- 0
Thats pretty messed up lol...
Zitat von lui2603
I Will see what i can do for ya :mrgreen: .
This is pretty simple for what your asking
so if i cant do it today then someone else will
probally sort this out asap lol..FAVORITE GAME! - BEER & ANIME! - SO EXICTING!

開発者, 携帯用プログラマー 日本サポータおよび恋人 本名のアダムの鍛冶屋
Currently Working On: - Flashmod V2.50 - Flashmod V2.60
Currently Drinking: Coffee! - 私はコーヒーを飲む
Chao Garden: DEMO v0.6
Chao Garden V0.5b Review!
-
03-08-2006, 07:08 AM #609QJ Gamer Blue
- Registriert seit
- Feb 2006
- Beiträge
- 224
- Points
- 5.036
- Level
- 45
- Downloads
- 0
- Uploads
- 0
Lol, thanks
-
03-08-2006, 07:13 AM #61011th Squad Captain
- Registriert seit
- Jun 2005
- Ort
- You are here -----> 名前: アダム | 飲むコー
- Beiträge
- 2.562
- Points
- 26.490
- Level
- 97
- Downloads
- 0
- Uploads
- 0
if pad:cross() then
shootright=true
end
if shootright==true then
bulletx = bulletx + 50
end
if shootright==false then
end
Maybe that will work?
But i really need a more detailed
destriction/code for this to understand...
I Will make a better version soon, cause
thats just a small test lol. ;)FAVORITE GAME! - BEER & ANIME! - SO EXICTING!

開発者, 携帯用プログラマー 日本サポータおよび恋人 本名のアダムの鍛冶屋
Currently Working On: - Flashmod V2.50 - Flashmod V2.60
Currently Drinking: Coffee! - 私はコーヒーを飲む
Chao Garden: DEMO v0.6
Chao Garden V0.5b Review!
-
03-08-2006, 07:26 AM #611QJ Gamer Blue
- Registriert seit
- Feb 2006
- Beiträge
- 224
- Points
- 5.036
- Level
- 45
- Downloads
- 0
- Uploads
- 0
Hm it won't work because the bullet will only go to bulletx + 50
that's why I had shoottime going in a loop so that bulletx will keep adding 50..
the thing is if I have it on a loop which is started by pressing x it wont keep going unless I hold in x all the time...
edit: also does anyone know how I make lua read from a tileset in a single .png file? like if each tile was 10 pixels wide and 10 pixels long?Geändert von lui2603 (03-08-2006 um 07:28 AM Uhr)
-
03-08-2006, 08:23 AM #612
Maybe this willl work (i did it really fast, maybe i need to adjust some things):
About the tiles:Code:function shootright() for shoottime=1,10 do bulletx = bulletx + 50 shoottime = shoottime + 1 end end if pad:cross() then shootright() end
Just load them all from that picture. You can see how at the basic LUA tutorial. Im sorry i forgot the site and im not at home. Its something like: add 10 pixels eachtime you load a part from that picture. Ill look up the site when im back home.
AltairLUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
03-08-2006, 08:38 AM #613is not posting very often

- Registriert seit
- Feb 2006
- Ort
- omnipresent
- Beiträge
- 5.162
- Points
- 33.152
- Level
- 100
- Downloads
- 0
- Uploads
- 0
Cheers its quite similar to mine and i think i know where I'm going wrong!AltairHeres what i used for my cursor:
Code:
mouse=Image.load('mouse.p ng')x=240y=136while true doscreen:blit(x, y, mouse, 0, 0, mouse:width(), mouse:height())pad = Controls.read() dx = pad:analogX() if math.abs(dx) > 32 then x = x + dx / 32 end dy = pad:analogY() if math.abs(dy) > 32 then y = y + dy / 32 endscreen.waitVblankStart () screen:flip()end
This works perfectly for me. Dont just copy it, but also see if you understand it.
thanks
-
03-08-2006, 09:23 AM #614QJ Gamer Blue
- Registriert seit
- Feb 2006
- Beiträge
- 224
- Points
- 5.036
- Level
- 45
- Downloads
- 0
- Uploads
- 0
My game was working just fine but after I added this peice of code:
if pad:up() and spritenum = car[1] then
direction = "up"
spritey = spritey - 1
end
if pad:down() and spritenum = car[1] then
direction = "down"
spritey = spritey + 1
end
if pad:right() and spritenum = car[1] then
direction = "right"
spritex = spritex + 1
end
if pad:left() and spritenum = car[1] then
direction = "left"
spritex = spritex - 1
end
it gave me an error saying "'then' expected near '='"
anyone know what's wrong with it?
-
03-08-2006, 11:47 AM #615
oo-oo, i know! To check if something is equal you have to use "==", not "=". So you have to change those.
For example: "if pad:up() and spritenum = car[1] then", becomes "if pad:up() and spritenum == car[1] then"LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
03-08-2006, 12:27 PM #616QJ Gamer Blue
- Registriert seit
- Feb 2006
- Beiträge
- 224
- Points
- 5.036
- Level
- 45
- Downloads
- 0
- Uploads
- 0
Oh yeah, didn't see that... Cheers Altair!
-
03-08-2006, 12:53 PM #617QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- OMG where AM I!?!?!?!?
- Beiträge
- 820
- Points
- 6.374
- Level
- 52
- Downloads
- 0
- Uploads
- 0
How can I change the sensitivity of the buttons. Its going too much.
Geändert von InhumanElmo (03-08-2006 um 01:11 PM Uhr)
[SPOILER="For PSP History"]1.50 > 1.52 > 2.00 > 1.5 > 1.5 (POC CF) > 1.5 (Harleyg) > 1.5 (Casual) > 3.03 OE-A > 3.03 OE-C[/SPOILER]
Check it out: [URL="http://youtube.com/watch?v=xNVPKM07TWs&mode=related&search="]Pen Spinning[/URL]
-
03-08-2006, 03:17 PM #618QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 375
- Points
- 5.631
- Level
- 48
- Downloads
- 0
- Uploads
- 0
ive started doing my collision(checking pixels) and i get this error
Index.lua:201: An argument was incorrect
these are the things that i added
im pretty sure im just doing it wrong because all i have to gooff of is that command. nothing else(like how it works)Code:TR = image:pixel(XAxis+48, YAxis) TL = image:pixel(XAxis, YAxis) BR = image:pixel(XAxis+48, YAxis+64) BL = image:pixel(XAxis, YAxis+64) TRcolor = TR:colors() TLcolor = TL:colors() BRcolor = BR:colors() BLcolor = BL:colors()
-
03-08-2006, 03:34 PM #619
@InhumanElmo
Do you mean for the Analogstick?
@Soadnation
What line is line 201? I think your code is correct, but i have never used it though.LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
03-08-2006, 03:35 PM #620QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- OMG where AM I!?!?!?!?
- Beiträge
- 820
- Points
- 6.374
- Level
- 52
- Downloads
- 0
- Uploads
- 0
No I mean for the actual dpad buttons. Is it possible? I need it for scrolling through numbers but it always goes too fast and skips numbers!
[SPOILER="For PSP History"]1.50 > 1.52 > 2.00 > 1.5 > 1.5 (POC CF) > 1.5 (Harleyg) > 1.5 (Casual) > 3.03 OE-A > 3.03 OE-C[/SPOILER]
Check it out: [URL="http://youtube.com/watch?v=xNVPKM07TWs&mode=related&search="]Pen Spinning[/URL]
-
03-08-2006, 03:38 PM #621
well you can say "if oldpad~=pad then" and then your code there. Where you add "oldpad=pad" at the end of your controlcheck part. What it does is check if your controls are the same as the last one and if so then it doesn't do anything. If they are different then it reads the controls. If it isnt clear i can post some code.
You can also put some WaitVBlank's after it. Then it has a pause and goes slower.LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
03-08-2006, 04:52 PM #622QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- OMG where AM I!?!?!?!?
- Beiträge
- 820
- Points
- 6.374
- Level
- 52
- Downloads
- 0
- Uploads
- 0
The Vblanks work. Thanks alot!
[SPOILER="For PSP History"]1.50 > 1.52 > 2.00 > 1.5 > 1.5 (POC CF) > 1.5 (Harleyg) > 1.5 (Casual) > 3.03 OE-A > 3.03 OE-C[/SPOILER]
Check it out: [URL="http://youtube.com/watch?v=xNVPKM07TWs&mode=related&search="]Pen Spinning[/URL]
-
03-08-2006, 05:15 PM #623QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 375
- Points
- 5.631
- Level
- 48
- Downloads
- 0
- Uploads
- 0
line 201 is trhe first one
-
03-09-2006, 01:47 AM #624
np!
@Soadnation
Where you have "image" you have to write the name of YOUR image. So if its background it becomes "background
ixel(x,y,)". Or if you want it of the whole screen its "screen
ixel(x,y)".
LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
03-09-2006, 02:34 PM #625QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 375
- Points
- 5.631
- Level
- 48
- Downloads
- 0
- Uploads
- 0
thanks that helped alot. now i got the collision working*when it collides it says somtyhing) just have to change that to do somthing when they colide
-
03-10-2006, 12:11 AM #626QJ Gamer Blue
- Registriert seit
- Feb 2006
- Beiträge
- 224
- Points
- 5.036
- Level
- 45
- Downloads
- 0
- Uploads
- 0
How would I make it do a different thing if X is pressed if it already does something else?
at the moment I have X shooting
pad = Controls.read()
if pad:cross() then
shoot()
end
*some more code to make sprite change*
then after
newpad = Controls.read()
if newpad:cross() then
*something else*
end
but when I press cross through newpad it still shoots...
end
-
03-10-2006, 04:38 AM #627
Hmm never tried that. Maybe you can just make a variable for that like:
pad = Controls.read()
if pad:cross() then
whatever=1
shoot()
end
*some more code to make sprite change*
then after
if pad:cross() and whatever==1 then
*something else*
end
The thing is you should have a puase in between i think, because otherwise it will do it immediately afterwards.Geändert von Altair (03-10-2006 um 04:40 AM Uhr)
LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
03-10-2006, 05:34 AM #628QJ Gamer Blue
- Registriert seit
- Feb 2006
- Beiträge
- 224
- Points
- 5.036
- Level
- 45
- Downloads
- 0
- Uploads
- 0
Ok I done it now.
if pad:cross() and spritenum==sprites then
shoot()
end
if pad:cross() and spritenum==carnum and direction=="up" then
spritey = spritey - 5
end
-
03-10-2006, 08:26 AM #629
and it works?
LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
03-10-2006, 10:37 AM #630QJ Gamer Blue
- Registriert seit
- Feb 2006
- Beiträge
- 224
- Points
- 5.036
- Level
- 45
- Downloads
- 0
- Uploads
- 0
Yeah... thanks for the help but just after posting I realised I could do it this way
Oh and if anyone knows how to do this, help would be really appreciated! I've been trying for so long to get it working...
I'm trying to get the lua script to read from a text file (map.txt) and have the numbers or letters which are in map.txt assigned to a table in my script.
So if i had
Tile = {}
Tile[1] = Image.load("grass.png")
and had "G" in the map.txt so that if I put
GGGGGG
GGGGGG
It would do 2 lines of the same image repeated...
thanks if anyone can help.
edit: Could somebody maybe upload an lua script which only has the code and map?Geändert von lui2603 (03-10-2006 um 11:46 AM Uhr)


LinkBack URL
About LinkBacks
Mit Zitat antworten

Hello everyone I am new here and I am glad to be part of this amazing community and I think there...
New to forum