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; lui you are the best that helped me so much=-)(cmd thing) new question is there a duplication feature like laser:duplicate(laser+i) ...
-
03-11-2006, 07:43 PM #661QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
lui you are the best that helped me so much=-)(cmd thing)
new question is there a duplication feature like laser:duplicate(laser+i)
i'll do a little searching
Geändert von slicer4ever (03-11-2006 um 07:54 PM Uhr)
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
03-11-2006, 07:57 PM #662Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
What code would I use to make something fall down the screen?
@slicer4ever. You could make a function with x and y variables and call the function with the coordinates you want, maybe something like...
Where "image" is the image you want to duplicateCode:function duplicate() screen:blit(x, y, image) screen.flip() end
Geändert von Mast3r_Shak3 (03-11-2006 um 08:01 PM Uhr)

--XBL Gamertag: PhenoM904--
-
03-11-2006, 08:07 PM #663QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
would this reset the thing if used a second time?
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
03-11-2006, 08:11 PM #664Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
No, you can call the function over and over again. The purpose is to call the same things over and over again without having to keep on typing it out. You can write the function in or outside of your main loop

--XBL Gamertag: PhenoM904--
-
03-11-2006, 08:17 PM #665QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
k i'll try it and thanks=-)
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
03-11-2006, 08:23 PM #666Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
Depending on the nature of the duplication you might want to put differnt variables, but thats up to you.

--XBL Gamertag: PhenoM904--
-
03-11-2006, 08:26 PM #667QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
hmm...how do you call the function i tried:
if pad:cross() then duplicate()
end
but it doesn't seem to wanna work
edit: nvm i forgot: if pad:cross() then duplicate()Geändert von slicer4ever (03-11-2006 um 08:35 PM Uhr)
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
03-11-2006, 08:39 PM #668Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
You have to do it like this.
So when you want that to happen just type duplicate() in the codeCode:function duplicate() if pad:cross() then screen:blit(x,y, image)
Click me for a tut on functions
--XBL Gamertag: PhenoM904--
-
03-11-2006, 08:47 PM #669QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
k thanks=-)
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
03-12-2006, 04:02 AM #670QJ Gamer Blue
- Registriert seit
- Feb 2006
- Beiträge
- 224
- Points
- 5.036
- Level
- 45
- Downloads
- 0
- Uploads
- 0
Earlier I asked how I would read from a .txt file in lua and display some of it on screen...
someone said the function would be io.read or something like that
could someone explain more how to use this? Like if I wanted to write a score to a text file, would it be io.write?
and what would I have to put after that for it to write a number to a text file
-
03-12-2006, 05:02 AM #671
That was me. But the thing is it wasn't in the list of all the commands, so im not sure if it will work. The command was: io.input(”file.txt”) where file.txt is your file.
To write maybe io.output("...") works. You will have to try it out.
@ PSPHax0r9
Sure you can send it to me. Ill give it a look.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-12-2006, 07:32 AM #672is not posting very often

- Registriert seit
- Feb 2006
- Ort
- omnipresent
- Beiträge
- 5.162
- Points
- 33.152
- Level
- 100
- Downloads
- 0
- Uploads
- 0
@Altair - yes start and select do, why?
-
03-12-2006, 08:50 AM #673Developer

- Registriert seit
- Oct 2005
- Ort
- Boston, MA
- Beiträge
- 1.389
- Points
- 14.378
- Level
- 77
- Downloads
- 0
- Uploads
- 0
can somebody give me a sample code for a timer?
-
03-12-2006, 08:58 AM #674Quality Haxing Since 1991
- Registriert seit
- Oct 2005
- Ort
- Pennsylvania, USA Fi
- Beiträge
- 6.206
- Points
- 29.255
- Level
- 99
- Downloads
- 0
- Uploads
- 0
One comes included with luaplayer.
@Altair - I PM'ed you.
Zitat von Noriko
-
03-12-2006, 09:52 AM #675is not posting very often

- Registriert seit
- Feb 2006
- Ort
- omnipresent
- Beiträge
- 5.162
- Points
- 33.152
- Level
- 100
- Downloads
- 0
- Uploads
- 0
EDIT: Sorted it out, just need to do click function!
Geändert von Glynnder (03-12-2006 um 10:51 AM Uhr)
-
03-12-2006, 02:40 PM #676QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
hey i have a problem so here it is:
i am using a function to blit something to the screen when i press x but now it won't stay on the screen heres my function:
thanks in advanceCode:function duplicatetoplaser() screen:blit(playerx+10,playery-31, playerlasertop) screen.flip() screen:waitVblankStart() end
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
03-12-2006, 03:08 PM #677
thats because you only call the function when you press "X". So what happens is, you press X, then it goes through the function ones and then the next loop it makes its gone again.
BTW 100th post W000T!!! Im a Journeyman, im a Journeyman!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-12-2006, 03:16 PM #678QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
so what would i do then to make it stay there permently?
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
03-12-2006, 04:11 PM #679Simon Champion!
- Registriert seit
- Mar 2006
- Ort
- Calgary, Alberta, Ca
- Beiträge
- 537
- Points
- 11.489
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Hi everyone! I have an idea for a game but I'm just learning Lua so can someone give me a bit of code to get me started? I want a simple little game that there are 3 constantly bouncing balls that when you press a trigger, you can select one and move it right or left. I need some help. How do you make it so you can switch between them and how can you make them bounce constantly. Those are my main issues. Help would be appreciated. Thank you!
Geändert von Greenskull (03-12-2006 um 04:13 PM Uhr)
-
03-12-2006, 04:14 PM #680QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 375
- Points
- 5.631
- Level
- 48
- Downloads
- 0
- Uploads
- 0
im trying to get highscore working in my game but it always gives me an error
these are my functionsCode:attempt to compare nil with a number
save function
load functionCode:function saveHighscore() file = io.open(highscoreFile, "w") if file then file:write(high) file:close() end end
Code:function loadHighscore() file = io.open(highscoreFile, "r") if file then high = file:read("*n") file:close() end end
this is how i call the funtion in my game(the write variable is to make sure it only saves once)
i know the save funtion works because if i get rid of the part where i compare the highscore variable to your score(and just save the score) it saves it.Code:if write==1 then loadHighscore() if high<score then high=score saveHighscore() write=2 end end
i know the load funtion is fine because in my menu script i have an option to view highscore.
then i just have it print the high variable and it works fine. but when i combined the two i get the error and i dont know why.Code:function loadHighscore() file = io.open(highscoreFile, "r") if file then high = file:read("*n") file:close() end end
-
03-12-2006, 07:37 PM #681Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
What does the "function argument expected near 'blah blah'" mean? And what code would I use to make 'script.lua' (My loading screen) read 'game.lua'? (The actual game code)

--XBL Gamertag: PhenoM904--
-
03-12-2006, 07:39 PM #682Quality Haxing Since 1991
- Registriert seit
- Oct 2005
- Ort
- Pennsylvania, USA Fi
- Beiträge
- 6.206
- Points
- 29.255
- Level
- 99
- Downloads
- 0
- Uploads
- 0
Why not just make your entire loading screen file a function? Then you could condense it into one LUA file. If you can't do that for some reason, the comand would be dofile("game.lua")
Zitat von MaSt3r_ShAk3
Zitat von Noriko
-
03-12-2006, 07:52 PM #683Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
Good idea... But I need to know what the error means before I can get anyhere =/

--XBL Gamertag: PhenoM904--
-
03-12-2006, 07:53 PM #684Quality Haxing Since 1991
- Registriert seit
- Oct 2005
- Ort
- Pennsylvania, USA Fi
- Beiträge
- 6.206
- Points
- 29.255
- Level
- 99
- Downloads
- 0
- Uploads
- 0
Give the exact error.
Zitat von Noriko
-
03-12-2006, 07:57 PM #685Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
Well im on my PSP but it was
Code:Function argument expected near 'while'

--XBL Gamertag: PhenoM904--
-
03-12-2006, 08:11 PM #686QJ Gamer Bronze
- Registriert seit
- Oct 2005
- Ort
- Alabama
- Beiträge
- 272
- Points
- 5.975
- Level
- 50
- Downloads
- 0
- Uploads
- 0
whats your while command look like..an example could be...
while something == something do
code here
end
make sure you just dont have something like
while do
whereas ..
while true do ... would workMy lua tutorials for PSP - www.evilmana.com/tutorials
PSP Lua CodeBase - Add your own code examples to the codebase! - www.evilmana.com/tutorials/codebase/
-
03-13-2006, 02:55 AM #687
Soadnation, what line is the error in?
Also, do you get the error when you leave in the comparisation of the highscore and your score, or only when you put in the save and load function?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-13-2006, 08:52 AM #688QJ Gamer Blue
- Registriert seit
- Feb 2006
- Beiträge
- 224
- Points
- 5.036
- Level
- 45
- Downloads
- 0
- Uploads
- 0
could someone please explain how io.input and io.output are used?
I've got io.output("highscore.txt" ) ... what do I need to put to make it write a variable (score) to the text file?
then what would I have to put after io.input in order to read the score from the text file and display it on screen/
-
03-13-2006, 10:10 AM #689Simon Champion!
- Registriert seit
- Mar 2006
- Ort
- Calgary, Alberta, Ca
- Beiträge
- 537
- Points
- 11.489
- Level
- 70
- Downloads
- 0
- Uploads
- 0
hey PSPHax0r9, I have an idea for a game but I'm just learning Lua so can you give me a bit of code to get me started? I want a simple little game that there are 3 constantly bouncing balls that when you press a trigger, you can select one and move it right or left. I need some help. How do you make it so you can switch between them and how can you make them bounce constantly. Those are my main issues. Help would be appreciated. Thank you!
-
03-13-2006, 01:45 PM #690Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
Heres my code so far (besides the loading screen, combining scripts later)
Zitat von PSPMillionaire
Code:black=Color.new(0, 0, 0) player={} player[1]={x=240, y=250} screenwidth=480 - player:width while true do screen:blit(0, 0, background, false) screen:blit(player[1].x,player[1].y,player) for a=0,10 do for b=0,0 do screen:blit(45*a, 45*b, spike) end end pad = Controls.read() screen:clear() if pad:left() then player[1].x = player.x - 2 end if pad:right() then player[1].x = player.x + 2 end screen.waitVblankStart() screen.flip() end
--XBL Gamertag: PhenoM904--


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