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; @shadow-evillink: Is this your complete code? Code: testing--------------- black=Color.new(0,0,0) background=Image.load("background.png") screen:blit(0,0,backgroun d,false) screen.waitVblankStart() screen.flip() end screenrint(200,130,"It worked Finally",black) screen:flip() while ...
-
02-05-2006, 01:44 PM #481QJ Gamer Silver
- Registriert seit
- Jun 2005
- Ort
- Puerto Rico
- Beiträge
- 310
- Points
- 7.109
- Level
- 55
- Downloads
- 0
- Uploads
- 0
@shadow-evillink:
Is this your complete code?
if so then it should be:Code:testing--------------- black=Color.new(0,0,0) background=Image.load("background.png") screen:blit(0,0,backgroun d,false) screen.waitVblankStart() screen.flip() end screenrint(200,130,"It worked Finally",black) screen:flip() while true do screen.waitVblankStart() end end
The thing you did wrong was that you put in an "end" while there wasn't any if/while/for/etc. command in fornt of it. Also you have a lot of waitVblankstart's and screenflips, but that should still work, i think.[/QUOTE]Code:black=Color.new(0,0,0) background=Image.load("background.png") screen:blit(0,0,background,false) screenrint(200,130,"It worked Finally",black) while true do screen.waitVblankStart() screen:flip() end
Thanks, I'm just now learning lua. I will test it out and thanks again.
-
02-05-2006, 03:15 PM #482
No prob!
@KKDDKK
You should put a "then" after each "elseif" aswell.LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
02-05-2006, 03:37 PM #483QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 375
- Points
- 5.631
- Level
- 48
- Downloads
- 0
- Uploads
- 0
k im working on hetting the inmages on the screen. i thought it would be easy but i keeo getting this error.
PlayerStand = Image.load(
layerstand.png")...]:6 '=' expected near 'screen'
this is from ttlde
and this is my code
ive been over my code abouty 20 times and i cant fiogure out what is wrong with it.Code:PlayerStand = Image.load("playerstand.png") PlayerJump = Image.load("playerjump.png") Obj = Image.load("obj.png") green = Color.new(0, 255, 0) -Start Code screen:blit(100, 90, PlayerStand) screen.flip() screen.waitVblankStart()
-
02-05-2006, 03:55 PM #48411th Squad Captain
- Registriert seit
- Jun 2005
- Ort
- You are here -----> 名前: アダム | 飲むコー
- Beiträge
- 2.562
- Points
- 26.490
- Level
- 97
- Downloads
- 0
- Uploads
- 0
Fixed version, I have just fixed a error but
Zitat von soadnation
your code end's because it doesnt loop [0 second's so it end's].
Fully working Version (To loop the image)Code:PlayerStand = Image.load("Playerstand.png") PlayerJump = Image.load("Playerjump.png") Obj = Image.load("Obj.png") green = Color.new(0, 255, 0) screen:blit(100, 90, PlayerStand) screen.waitVblankStart() screen.flip()
Code:PlayerStand = Image.load("Playerstand.png") PlayerJump = Image.load("Playerjump.png") Obj = Image.load("Obj.png") green = Color.new(0, 255, 0) while true do screen:blit(100, 90, PlayerStand) screen.waitVblankStart() screen.flip() endFAVORITE 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!
-
02-05-2006, 04:06 PM #485QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 375
- Points
- 5.631
- Level
- 48
- Downloads
- 0
- Uploads
- 0
k thanks. completly forgot about the lopp that goes around the waitVblanks
-
02-05-2006, 04:18 PM #486
@KKDDKK
here is a full working (tested myself) code:
Code:Default Code: stage =1 black=Color.new(0,0,0) background1=Image.load("1.jpg") background2=Image.load("2.jpg") background3=Image.load("3.jpg") background4=Image.load("4.jpg") background5=Image.load("5.jpg") sound=Sound.load("sound.wav") while true do screen:clear(black) sound:play() if stage==1 then screen:blit(0,0,background1) stage=2 elseif stage==2 then screen:blit(0,0,background2) stage=3 elseif stage==3 then screen:blit(0,0,background3) stage=4 elseif stage==4 then screen:blit(0,0,background4) stage=5 elseif stage==5 then screen:blit(0,0,background5) stage=6 elseif stage==6 then screen:blit(0,0,background2) stage=1 end screen.waitVblankStart(90) 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]
-
02-05-2006, 04:20 PM #487
Hey soadnation, what is it you're making?
LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
02-05-2006, 06:32 PM #488QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 375
- Points
- 5.631
- Level
- 48
- Downloads
- 0
- Uploads
- 0
its a 2-d version of a mini game in an early xboxd title
now im working on adding simeple movement but it gives me a runtime error on line 11(if pad left) "Attemt to index global 'pad' (a function value)"
i usualy wouldnt post this right away and try to work it out myself a little but before i post it here but im going to bed and i was hoping to get the left/right movement down by tomorow.Code:PlayerStand = Image.load("Playerstand.png") PlayerJump = Image.load("Playerjump.png") Obj = Image.load("Obj.png") green = Color.new(0, 255, 0) XAxis = 100 while true do screen:clear() pad = Controls.read if pad:left() then XAxis = XAxis-1 end if pad:right() then XAxis = XAxis+1 end screen:blit(X, 90, PlayerStand) screen.waitVblankStart() screen.flip() end
nevermind. saw that i was missing the "()" after pad = control read right as it posted. but when it starts the picture doesnt move when i hit left and rightGeändert von soadnation (02-05-2006 um 06:54 PM Uhr)
-
02-06-2006, 02:51 AM #489
well that's because your image blits at (X, 90) while you don't state the X, because you use "XAxis" above!
LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
02-06-2006, 04:17 AM #490QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 375
- Points
- 5.631
- Level
- 48
- Downloads
- 0
- Uploads
- 0
yea. figured that out when i got on this morning. thanks anyways.
now i got a question. can i make a collision funtion for an object and then duplicate the object multiple times?Geändert von soadnation (02-06-2006 um 04:26 AM Uhr)
-
02-06-2006, 06:10 AM #49111th Squad Captain
- Registriert seit
- Jun 2005
- Ort
- You are here -----> 名前: アダム | 飲むコー
- Beiträge
- 2.562
- Points
- 26.490
- Level
- 97
- Downloads
- 0
- Uploads
- 0
This is where i am stuck
Zitat von soadnation
Collisions aint going so well
If anyone could help then thank's
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!
-
02-06-2006, 02:08 PM #492
well i know you can do that with tiles, eventhough i don't understand it. (I don't get the assigning of the letters to each part of a piture. Can someone maybe explain?). But i don't know if you can just copy it, because then the variables will mixup, or not? Hmmmm.... i'll think about it.
LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
02-06-2006, 03:08 PM #493
i think you can use a function and the then you give it as arguments the coordinats of each object. So say you have x1,y1,x2,y2,etc. and you have a function collision(x,y).
Then you can say
I dont know if thats the best/shortest way of doing it though.Code:if xcoordinate==x1 and ycoordinate ==y1 then collision(x1,y1) end etc.
LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
02-06-2006, 05:27 PM #494QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 375
- Points
- 5.631
- Level
- 48
- Downloads
- 0
- Uploads
- 0
the thing im trying to make will have pipes(some on the ground some in the air) that all move the same way. they are all gona be the same picture just at different heights. thats why i was wondering if i could just have collision for one of them and then just copy it.
-
02-06-2006, 06:54 PM #495QJ Gamer Bronze
- Registriert seit
- Oct 2005
- Ort
- Alabama
- Beiträge
- 272
- Points
- 5.975
- Level
- 50
- Downloads
- 0
- Uploads
- 0
Here's a tile engine I was messing around with. I ported this from Darkbasic language into lua, and changed some things around a bit as well. It has working collision based on images stored in an array. if the index to the image is less than 50 then you wont collide with the tile. Above 50 you will. This is messy since i was just tinkering around with the code. But you can look at it, for fun if anything. Not sure which images i used so i may have included a few more than needed.
Oh, and this scrolls the screen in all directions as well, like an RPG.My lua tutorials for PSP - www.evilmana.com/tutorials
PSP Lua CodeBase - Add your own code examples to the codebase! - www.evilmana.com/tutorials/codebase/
-
02-07-2006, 01:33 AM #496
thanks, i looked at the lua tut again aswell and now i get the tilestuff. BTW PSPMillionaire, what are all the "61"'s in "map[1] "? I don't see any picture 61.
LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
02-07-2006, 04:31 AM #497QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 375
- Points
- 5.631
- Level
- 48
- Downloads
- 0
- Uploads
- 0
how do i add get rid of the white background on my pictures? i tried the alpha equals true command but it doesnt work. if it helps i used photoshop for them.
-
02-07-2006, 12:59 PM #498QJ Gamer Bronze
- Registriert seit
- Oct 2005
- Ort
- Alabama
- Beiträge
- 272
- Points
- 5.975
- Level
- 50
- Downloads
- 0
- Uploads
- 0
Images[61] = Image.load("Brick.png")
Zitat von Altair
That is the image associated with it :)My lua tutorials for PSP - www.evilmana.com/tutorials
PSP Lua CodeBase - Add your own code examples to the codebase! - www.evilmana.com/tutorials/codebase/
-
02-07-2006, 03:38 PM #499
Wow that was stupid! I just read over it. Next time ill read better. thx though!
@soadnation
You have to make the white background transparent. If you use photoshop then it's easy. Just use magic eraser, one click and its done.Geändert von Altair (02-07-2006 um 03:40 PM 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]
-
02-07-2006, 03:44 PM #500QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 375
- Points
- 5.631
- Level
- 48
- Downloads
- 0
- Uploads
- 0
stupid me. i ment paint. never thought i would get THOSE two mixed up.
one problem. in my menu script i told it to do file index.lua in the data folder but it never does.
i have this in my menu script
this is my file structureCode:dofile("./jumpdata/index.lua")
-Jump folder
-Index.lua
--JumpData folder
-index.lua
-picture files
once this is done and i get the duck done and some new obj ill probly release an early version(without collision)Geändert von soadnation (02-07-2006 um 04:03 PM Uhr)
-
02-08-2006, 01:56 PM #501
i think you aren't supposed to put the filename in "s (dont know what they're called in english). So it becomes:
Code:dofile(./jumpdata/index.lua)
LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
02-08-2006, 04:24 PM #502QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 375
- Points
- 5.631
- Level
- 48
- Downloads
- 0
- Uploads
- 0
i need the quotes i know that. i dont need the ( though. still doesnt work now. now its
dofile "jumpdata/Index.lua
also what is wrong with thise line of code?
if math:random(0, 1)==0 then
when i try running it it says
wrong number of argumentsGeändert von soadnation (02-08-2006 um 04:32 PM Uhr)
-
02-09-2006, 02:04 AM #503
its
I think that should workCode:if math.random(0, 1)==0 then
hmm in the wiki it says:
dofile([filename])
If that doesn't work then i dont know because i havent used that before. But Ill try it if i have the time.LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
02-09-2006, 05:00 PM #504QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 375
- Points
- 5.631
- Level
- 48
- Downloads
- 0
- Uploads
- 0
still doesnt work. right now im not even that worried with the dofuile. its the mathrandom part. without it i cant go any further.
this is the code its in
if np<6 and rc==1 and math:random(0,1)==0 then screenLblit(x1, y1, Obj) else end
-
02-10-2006, 07:29 AM #505
I told you it's with a point, not a colon.
So it's:
if np<6 and rc==1 and math.random(0,1)==0 then screenLblit(x1, y1, Obj) else end
and not
if np<6 and rc==1 and math:random(0,1)==0 then screenLblit(x1, y1, Obj) else endLUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
02-10-2006, 08:02 AM #506
Ok i figured the dofile() out:
it's just
dofile("index.lua")
if it's in the same directory
If its not, then you can do this:
dofile("map/map/index.lua")
or you can put this in front of it:
System.currentDirectory("map/map")
Instead of "map/map" you type the directory its in (duh).
Both methods work.
So for you its:
orCode:dofile("jumpdata/index.lua")
Hope that helpedCode:System.currentDirectory("jumpdata") dofile("index.lua")Geändert von Altair (02-10-2006 um 08:30 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]
-
02-10-2006, 08:23 AM #507QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 375
- Points
- 5.631
- Level
- 48
- Downloads
- 0
- Uploads
- 0
see i thought it was with a : because in ttlde it has a lua funtion dictiopnsary type thing wherte u select it and it shows up on screen. it had showed up with a : not a .
-
02-10-2006, 08:31 AM #508
well i used a . instead of a : and with me 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]
-
02-10-2006, 08:36 AM #509
and if it still doesnt work. Try storing the math.random(0,1) in a variable first and compare the variable in the if statement.
LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
02-10-2006, 08:44 AM #510QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 375
- Points
- 5.631
- Level
- 48
- Downloads
- 0
- Uploads
- 0
it works. i just now need to think of whats the best way to go about this.
also i just did the dofile and it works perfectly. thatnks alot.Geändert von soadnation (02-10-2006 um 08:53 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