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; my break command works fine on windows, but not in PSP. ??? :icon_sad:...
-
03-21-2006, 10:22 AM #1021
my break command works fine on windows, but not in PSP.
??? :icon_sad:
D:
-
03-21-2006, 10:26 AM #1022Think, Do, Gloat.
- Registriert seit
- Nov 2005
- Ort
- England, Norwich
- Beiträge
- 1.422
- Points
- 12.687
- Level
- 73
- Downloads
- 0
- Uploads
- 0
no worries altair, luckily, i just worked around the error. copied and pasted the stuff i had done into an older version of the app, so it works just fine! only took like 3 mins in the end.
i'll have to keep thinking on it i think. i will try out some sounds in lua and see they lose quality if i hold them down.
-
03-21-2006, 01:22 PM #1023<img src="images/smilies/psp.gif" border="0" alt="" title="" cl***="inlineimg" /> <img src="images/smilies/Punk.gif" border="0" alt="" title="" cl***=&

- Registriert seit
- Jun 2005
- Ort
- Canada
- Beiträge
- 1.944
- Points
- 11.105
- Level
- 69
- Downloads
- 0
- Uploads
- 0
if you find it out, please tell me, since i have the same problem
-
03-21-2006, 08:29 PM #1024
- Registriert seit
- Jun 2005
- Beiträge
- 3
- Points
- 4.632
- Level
- 43
- Downloads
- 0
- Uploads
- 0
Well. I'm preaty new to lua but have teh basics down. I want to make an rpg of some sort and right now I am trying to figure out how I would make the world (background?) from a tile sheet. I've seen some people do it that way so I figure its the best.
I have looked at a bunch of tuorials and came across: "http://wiki.ps2dev.org/psp:lua_player:tutorial" Which at the bottom tells me about tiles and how to use them.
now, I don't really get what is going on in the script. I could copy and past it and just use it but I would REALLY apriciate it if someone could tell me what each part means like:
"screen:blit(16 * x, 16 * y, tiles, 17 * tileX + 1, 17 * tileY + 1, 16, 16, false)"
screen:blit = prints picture to screen
16 * x = first cordinate of something something -- 16 = number of pixels of "image.png", *=multiply, x = bla bla bla...
or something like that. I dont know what Im talking about in the example but I hope you get what I mean. Thanks!
P.S. If this has been answered then Im really sorry. Its just that 103 pages is alot!
-
03-21-2006, 11:39 PM #1025
basically it's dynamically setting up the image locations and where they will appear on the screen..
imagine your PSP screen is like a cartoon animation.. you have different layers.. for example your background, main character, foreground, etc..
They all stack on top of each other in the order that you draw them.. so first things first you want to draw your background... in your case you will be using tiles to create the background.
A table is created to store the information for the background and where to draw each tile. A function would then read the information from the table and get the variables which tell lua where to put the image.
You should copy the tutorial script and images and get it working yourself. Once you have a working version of the tutorial, you can modify it by substituting your own images and adjusting the values to get it to work for your application. This will help you learn the small fine-tuning skills you will need to develop a bug-free application.
Hope I've helped answer your question and good luck!
-
03-22-2006, 01:41 AM #1026
I'm trying to blit a random image, i'm using this:
and my array looks like this:Code:screen:blit(enemy.x,enemy.y,enemysprite[math.random(1,2)])
But i get this error:Code:enemysprite = {} enemysprite.a = Image.load("Images/enemy1.png") enemysprite.b = Image.load("Images/enemy2.png")
Can you not blit from an array?Code:error: Jumper.lua:93: bad argument #2 to `blit' (Image expected, got nil)
Is there another way to do this?D:
-
03-22-2006, 01:48 AM #1027
hmm i think you can, but you can always just use variables. And say if var==1 then image1 end etc. But using a table would be more convenient ofcourse.
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-22-2006, 01:51 AM #1028
BTW what is the line where the error occurs?
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-22-2006, 01:53 AM #1029
The error occours on the blit.
D:
-
03-22-2006, 01:57 AM #1030
Ok i got it: You haven't got it stored in enemysprite[number] but in enemysprite.a en .b which will never be generated by math.random obviously.
So what you should do is:
Code:enemysprite = {Image.load("Images/enemy1.png"),Image.load("Images/enemy2.png")}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-22-2006, 02:19 AM #1031
- Registriert seit
- Feb 2006
- Beiträge
- 2
- Points
- 4.124
- Level
- 40
- Downloads
- 0
- Uploads
- 0
can i ask some here??? guys if ever i update my psp to 2.6 version, can i still use my iso?
-
03-22-2006, 02:36 AM #1032
Well that is not the kind of question to ask here. This thread is for LUA help only.
But no you cannot use ISOs on 2.0+D:
-
03-22-2006, 02:39 AM #1033
--deleted
Geändert von Altair (03-22-2006 um 03:27 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-22-2006, 02:40 AM #1034
Yeah i saw it, thanks Altair.
Most of my problems seem to be stupid mistakes, but at least you put me right.D:
-
03-22-2006, 03:26 AM #1035
No prob and this way we get more games so i do it gladly.
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-22-2006, 03:31 AM #1036
Yeah more games!
As i start to get more experienced i will help here as much as i can.D:
-
03-22-2006, 03:48 AM #1037
Is it possible to make it so that a press only counts once each time?
For example, on my menu i have to tap left for one milisecond otherwise it zooms across, how can i make it so one press equals one move.D:
-
03-22-2006, 04:20 AM #1038
Is there anyway to blit an image, wait a set amount of time, then blit another?
D:
-
03-22-2006, 04:59 AM #1039is not posting very often

- Registriert seit
- Feb 2006
- Ort
- omnipresent
- Beiträge
- 5.162
- Points
- 33.152
- Level
- 100
- Downloads
- 0
- Uploads
- 0
err gutya, do something like:
oldpad = controls.read
pad = controls.read
if pad ~= oldpad then
code goes here...
oldpad = pad
end
At least i think its thisWhat did we think the world would look like in 2015?
http://forums.qj.net/501501-post26.html
Zitat von Abe
-
03-22-2006, 05:33 AM #1040
No, that does not work.
D:
-
03-22-2006, 05:48 AM #1041
its like this:
Code:while true do pad=controls.read if pad~=oldpad then put your control code here end -- end of the if pad~=oldpad loop oldpad=pad end --end of while loop
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-22-2006, 05:51 AM #1042
Yes. OR use a timer (this way you still have functionality, i.e. the loop continues), OR use screen.waitVblanck() (this way the loop will pause for a given amount of time (60=1 second))Is there anyway to blit an image, wait a set amount of time, then blit another?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-22-2006, 06:03 AM #1043
Thanks, but now i get this error, what on earth does is mean?
Code:error: index.lua:131: <eof> expected near `end'
D:
-
03-22-2006, 06:05 AM #1044
You have to much ends, maybe it can also mean that you have to few. Anyway, check your ends.
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-22-2006, 06:22 AM #1045
The oldpad thing doesnt work, heres what i have in my main loop:
Code:--Main Loop while true do pad = Controls.read() if pad~=oldpad then if pad:down() then menustatus = 2 end if pad:up() then menustatus = 1 end if pad:cross() and menustatus == 1 then score = 0 dofile("Jumper.lua") end if pad:cross() and menustatus == 2 then break end if pad:right() then dificulty = dificulty + 1 end if pad:left() then dificulty = dificulty - 1 end if dificulty > 3 then dificulty = 3 end if dificulty < 1 then dificulty = 1 end if menustatus == 1 then screen:print(200,248,"Play",green) screen:print(200,258,"Quit",white) end if menustatus == 2 then screen:print(200,248,"Play",white) screen:print(200,258,"Quit",green) end if dificulty == 1 then screen:print(160,208,"Easy",green) screen:print(200,208,"Medium",white) screen:print(250,208,"Hard",white) end if dificulty == 2 then screen:print(160,208,"Easy",white) screen:print(200,208,"Medium",green) screen:print(250,208,"Hard",white) end if dificulty == 3 then screen:print(160,208,"Easy",white) screen:print(200,208,"Medium",white) screen:print(250,208,"Hard",green) end screen.flip() screen.waitVblankStart() end if pad:right() then dificulty = dificulty + 1 end if pad:left() then dificulty = dificulty - 1 end if dificulty > 3 then dificulty = 3 end if dificulty < 1 then dificulty = 1 end if menustatus == 1 then screen:print(200,248,"Play",green) screen:print(200,258,"Quit",white) end if menustatus == 2 then screen:print(200,248,"Play",white) screen:print(200,258,"Quit",green) end if dificulty == 1 then screen:print(160,208,"Easy",green) screen:print(200,208,"Medium",white) screen:print(250,208,"Hard",white) end if dificulty == 2 then screen:print(160,208,"Easy",white) screen:print(200,208,"Medium",green) screen:print(250,208,"Hard",white) end if dificulty == 3 then screen:print(160,208,"Easy",white) screen:print(200,208,"Medium",white) screen:print(250,208,"Hard",green) end screen.flip() screen.waitVblankStart() oldpad=pad end
D:
-
03-22-2006, 06:26 AM #1046
look closer at my post. Anyway, the controls that you want to do something only ones if pressed should be in the "if pad~=oldpad then" and "end" commands. Now you have exactly those outside of them.
Geändert von Altair (03-22-2006 um 06:28 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-22-2006, 06:40 AM #1047
I don't understand. :Argh:
D:
-
03-22-2006, 07:23 AM #1048Think, Do, Gloat.
- Registriert seit
- Nov 2005
- Ort
- England, Norwich
- Beiträge
- 1.422
- Points
- 12.687
- Level
- 73
- Downloads
- 0
- Uploads
- 0
you have added the right bits to the controls.
obviously delete the spaces i created there. it's just to show you where to put them. make sure oldpad = pad is at the end, before you have the ends. so in the loop. and make sure you haveif pad:------directional button-------() and
oldpad:------directional button-------() ~= pad:------directional button-------() then
(-------sound here-----)
lay()
end
endout of the loop at the beginning and finaly, make sure you haveoldpad = Controls.read()at the beginning of the loop.pad = Controls.read()
obviously, change it from the sound play, to whatever you want it to do.
-
03-22-2006, 07:38 AM #1049
So this would be correct?:
if so it doesnt workCode:if pad:right() and oldpad:right() ~= pad:right() then dificulty = dificulty + 1 end if pad:left() and oldpad:left() ~= pad:right() then dificulty = dificulty - 1 end
D:
-
03-22-2006, 07:46 AM #1050Think, Do, Gloat.
- Registriert seit
- Nov 2005
- Ort
- England, Norwich
- Beiträge
- 1.422
- Points
- 12.687
- Level
- 73
- Downloads
- 0
- Uploads
- 0
you spelt dificulty wrong, don't know if that makes a difference. it's difficulty.
i'll take a look at the script if you want.


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