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; Well i hinted at it a few times, but besides being the "really helpful guy, in the LUA Help Thread", ...
-
04-01-2006, 06:57 AM #1261
Well i hinted at it a few times, but besides being the "really helpful guy, in the LUA Help Thread", im also working on a project of my own (a RTS).
Im pretty far at the moment. I just need to make some graphics for other units and buildings and a menu and then implement them and i will release a beta i think. But since i dont have the right stuff on my pc here ill have to wait till next weekend. If thats done i will release something soon.
Geändert von Altair (04-01-2006 um 07:12 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]
-
04-01-2006, 07:06 AM #1262
Got a question: Does anyone know, if using "dofile()" uses more memory then if you put it in the same file?
I ask this because if you run one lua file and in it you call another one. If you quit that one, you "fall back to the old lua file. So does this mean it has that state saved in the memory? And would that be a big amount it would use or is it really really small?
Hope its clearLUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
04-01-2006, 07:18 AM #1263Developer

- Registriert seit
- Oct 2005
- Ort
- Boston, MA
- Beiträge
- 1.389
- Points
- 14.378
- Level
- 77
- Downloads
- 0
- Uploads
- 0
Kool, I thought that to myself before, my guess would be it would take up alot, another problem with do file is, if you move to the main game, and you unload your menu images for more space, but if you break it and will mess up the menu, due to the images being nil.
Zitat von Altair
-
04-01-2006, 07:37 AM #1264
well could ofcourse make it load the images again before i go back to the menu. So it only loads them when i need them.
LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
04-01-2006, 03:19 PM #1265Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
Okay. How could I have it so if I press X then 1 of 5 (or however many) sentences will pop up? would i do need to store the value from math.random() into a variable then print it onto the screen? Would this work?
Code:while true do screen.clear() pad=Controls.read() if pad:cross() then do math.Random(5) math.Random(5) if math.random(5) = 1 then screen:print(130,200,1,white) if math.random(5) = 2 then screen:print(130,200,2,white) if math.random(5) = 3 then screen:print(130,200,3,white) if math.random(5) = 4 then screen:print(130,200,4,white) if math.random(5) = 5 then screen:print(130,200,5,white) screen.waitVblankStart() screen.flip() end

--XBL Gamertag: PhenoM904--
-
04-01-2006, 03:29 PM #1266QJ Gamer Green
- Registriert seit
- Nov 2005
- Ort
- Sweden
- Beiträge
- 460
- Points
- 6.520
- Level
- 52
- Downloads
- 0
- Uploads
- 0
I really want and need a Wi-Fi turotial for lua!
I guess i am not the only one?[CENTER]Some of my homebrew Applications/Games:
[URL=http://forums.qj.net/showthread.php?t=47294&page=1&pp=10]Planet Fighter[/URL] | [URL=http://forums.qj.net/showthread.php?p=641672#post641672]Graphic Creator (V2.0)[/URL] | [URL=http://forums.qj.net/showthread.php?p=512717]Fire Pong[/URL] | [B][URL="http://forums.qj.net/f-psp-development-forum-11/t-release-brushes-v20-99207.html#post1430891"][COLOR="Red"][SIZE="3"]Brushes v2.0[/COLOR][/SIZE][/B][/URL] [URL="http://forums.qj.net/f-psp-development-forum-11/t-release-brushes-v20-99207.html"][B][SIZE="2"][COLOR="Black"]Released![/COLOR][/SIZE][/B][/URL]
[URL="http://haxxblaster.2u.se/"][COLOR="black"][FONT="Arial Black"]www.HaxxBlaster.com[/FONT][/COLOR][/URL]
[URL="http://forums.qj.net/f-psp-development-forum-11/t-release-brushes-v20-99207.html"][IMG]http://img19.imageshack.us/img19/1346/brushesbannerqz3.png[/IMG][/URL][/CENTER]
-
04-01-2006, 03:58 PM #1267
@MaSt3r_ShAk3:
You cant say "do math.random(5)". Also close ever "if then" statement with an "end" statement. Also you have to say "if ... == ... then" and not "if ... = ... then". So you have to use TWO "="'s.
So it becomes:
Code:while true do screen.clear() pad=Controls.read() if pad:cross() then random=math.Random(5) if random == 1 then screen:print(130,200,1,white) end if random == 2 then screen:print(130,200,2,white) end if random == 3 then screen:print(130,200,3,white) end if random == 4 then screen:print(130,200,4,white) end if random == 5 then screen:print(130,200,5,white) end screen.waitVblankStart() screen.flip() end
LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
04-01-2006, 04:04 PM #1268Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
Ok, I get an error. Unexpected symbol near '1'

--XBL Gamertag: PhenoM904--
-
04-01-2006, 04:10 PM #1269
o yeah i just noticed: "screen
rint(130,200,4,white)"
should be:
"screen
rint(130,200,"4",white)"
And that for all these commands. You see, if you want it to display the character 4 then you have to put it in "'s (dont know what they're called :P ). If you dont then lua treats it like a variable.LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
04-01-2006, 04:13 PM #1270Tha Sigerator

- Registriert seit
- Jul 2005
- Ort
- New Orleans, LA
- Beiträge
- 4.047
- Points
- 26.703
- Level
- 97
- Downloads
- 0
- Uploads
- 0
i think i got all the errors. it actually starts now.
u gotta define the whatchacallits tho
Code:white = Color.new(0, 0, 0) while true do screen:clear() pad=Controls.read() if pad:cross() then do math.Random(5) end math.Random(5) if math.random(5) == 1 then screen:print(130,200,"1",white) end if math.random(5) == 2 then screen:print(130,200,"2",white) end if math.random(5) == 3 then screen:print(130,200,"3",white) end if math.random(5) == 4 then screen:print(130,200,"4",white) end if math.random(5) == 5 then screen:print(130,200,"5",white) end screen.waitVblankStart() screen.flip() end end
- - - - Somewhere Lurking in THA SHADOWS - - - -
-
04-01-2006, 04:13 PM #1271Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
It IS a variable and "s are called quotations. But i will just have the random number print text. Thanks alot!

--XBL Gamertag: PhenoM904--
-
04-01-2006, 04:19 PM #1272
O yeah lol quotations that was it, thx.
Ok well if they are variables, then you have to define them first. So say like:
1="hello"
But i dont know if you can use numders as variables.LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
04-01-2006, 04:51 PM #1273Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
Yeah, i was thinking that but Ill do this for now. But what does this error mean??
Code:error:script.lua:5: Argument Error: Image:clear([color]) zero or one argument

--XBL Gamertag: PhenoM904--
-
04-01-2006, 04:57 PM #1274
well i dont know whats at line 5 so i can only guess.
Or you have the wrong name for the image, or something is wrong with your spelling probably. But i cant tell without the code you have now. Check all the names!LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
04-01-2006, 05:21 PM #1275Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
Ok cool... I test on window lua player and when I press X nothing happens...

--XBL Gamertag: PhenoM904--
-
04-01-2006, 11:25 PM #1276
Hope this helps!
Code:r = 1 white = Color.new(255, 255, 255) quotes = {} quotes[0] = "Hello from number 0" quotes[1] = "Hello from number 1" quotes[2] = "Hello from number 2" quotes[3] = "Hello from number 3" quotes[4] = "Hello from number 4" quotes[5] = "Hello from number 5" while true do screen:clear() pad = Controls.read() if pad:cross() and pad ~= oldpad then r = math.random(5) end screen:print(130, 200, quotes[r], white) oldpad = pad screen.flip() screen.waitVblankStart() endGeändert von califrag (04-01-2006 um 11:28 PM Uhr)
-
04-02-2006, 10:48 AM #1277is not posting very often

- Registriert seit
- Feb 2006
- Ort
- omnipresent
- Beiträge
- 5.162
- Points
- 33.152
- Level
- 100
- Downloads
- 0
- Uploads
- 0
ok i really need to know how to make like a file browser, just to load files e.g bmp's and stuff. It says stuff about tables and i dont know how to use them, please help :$
What did we think the world would look like in 2015?
http://forums.qj.net/501501-post26.html
Zitat von Abe
-
04-02-2006, 01:17 PM #1278
Sorry i cant help ya there. I dont know, and im not planning on checking how the bmplib works so i cant help you.
Also, if i were you i would learn how to use tables they'll come in handy on many occasions. Its not that difficult either. And if you learn how it works maybe you can figure out how the bmplib works yourself?LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
04-02-2006, 01:37 PM #1279
Here's an example that builds a table and then prints the results to your screen. I'm sure you can figure out how to load the images and display them from here...
HTH!Code:white = Color.new(255, 255, 255) tblImages = {} count = 1 imageList = System.listDirectory("./images/") for index, imageFile in imageList do if not imageFile.directory then tblImages[count] = imageFile.name count = count + 1 end end while true do y = 10 for _, v in pairs (tblImages) do screen:print(0, y, v, white) y = y + 10 end screen.flip() screen.waitVblankStart() endGeändert von califrag (04-02-2006 um 01:48 PM Uhr)
-
04-03-2006, 12:34 PM #1280QJ Gamer Blue
- Registriert seit
- Apr 2006
- Ort
- Northampton, England
- Beiträge
- 59
- Points
- 4.272
- Level
- 41
- Downloads
- 0
- Uploads
- 0
Hi everyone, The problem I am having is after I have writen my lua script, saved it as index.lua, I open the lua player, and it will say no script found (or something similar) What's the problem here?
-
04-03-2006, 01:00 PM #1281
It's a problem in your code, post it and we will try and help.
D:
-
04-03-2006, 01:55 PM #1282QJ Gamer Blue
- Registriert seit
- Apr 2006
- Ort
- Northampton, England
- Beiträge
- 59
- Points
- 4.272
- Level
- 41
- Downloads
- 0
- Uploads
- 0
I'm sorry, I forgot to add that certain other scripts I have downloaded won't work aswell, it's just the lua tutorial scripts (part 1)
-
04-03-2006, 02:05 PM #1283<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
where can i find the new features in the new lua,,
-
04-03-2006, 02:33 PM #1284
It could be any number of things. Have you tried running it on windows LUA player?
Zitat von code-zero
D:
-
04-03-2006, 04:05 PM #1285QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
well i have a question and if any1 knows any tut's that would be helpful but heres my prob:
kinda like aotm he has multiple angry faces shooting at the same time but i'm unsure how to do this i've been trying multiple things but can't figure out how to do it i hope you understand my prob and can help me out=-)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
-
04-03-2006, 05:36 PM #1286Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
hi, this s my code:
it works, but i get the same two money amounts every time, 1.e+6(1000000) ,and 7.5e+5(750000) how can i make it so that each time a takes another values that what it already has? and one more thing how can i disable scientific notation??Code:b = Color.new(255, 255, 255) System.usbDiskModeActivate() cases = {26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 } money_value = {100000, 750000, 500000, 400000, 300000, 200000, 100000, 50000, 25000, 10000, 50000, 1000, 750, 500, 400, 300, 200, 100, 75, 50, 25, 10, 5, 1, .01 } case_money = {} while true do pad = Controls.read() if pad:start() then break end n = 1 a = math.random(26) screen:clear() while n < 27 do case_money[n] = money_value[a] n = n + 1 end if n >26 then assign = false end screen:print(130, 100, money_value[1], b) screen:print(130, 150, money_value[2], b) screen.waitVblankStart() screen:flip() end--------------------------------------------------------------------------------------
-
04-03-2006, 06:08 PM #1287
right before your "while true do" put:
math.randomseed(os.time() )
math.random()
math.random()
math.random()
-
04-03-2006, 06:17 PM #1288Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
same thing. it still doesnt work, heres my current code:
Zitat von califrag
thanks for all ur help!Code:b = Color.new(255, 255, 255) System.usbDiskModeActivate() cases = {26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 } money_value = {100000, 750000, 500000, 400000, 300000, 200000, 100000, 50000, 25000, 10000, 50000, 1000, 750, 500, 400, 300, 200, 100, 75, 50, 25, 10, 5, 1, .01 } case_money = {} math.randomseed(os.time() ) math.random() math.random() math.random() while true do pad = Controls.read() if pad:start() then break end n = 1 a = math.random(26) screen:clear() while n < 27 do case_money[n] = money_value[a] n = n + 1 end screen:print(130, 100, money_value[1], b) screen:print(130, 150, money_value[2], b) screen.waitVblankStart() screen:flip() end--------------------------------------------------------------------------------------
-
04-03-2006, 06:27 PM #1289
ok i decided to try to learn LUA. I started with trying the "hello world" thing (using notepad), I typed the code and every thing and I saved it as script.lua but it saved as a text document. How can I make it save as a LUA file??? sorry for the incredibly noobish question its just i am very new to programing.
Thanks guys :icon_smil
-
04-03-2006, 06:32 PM #1290Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
if the name is somethin like blah.txt
Zitat von MrBoots
then just simply rename it to blah.lua
windows may ask you that is may not work if u chage the file extension, but ignore that.--------------------------------------------------------------------------------------


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