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; windows luaplayer - includes the simple menu and simple movement examples that i posted on this thread - with their ...
-
04-10-2008, 11:44 AM #8491Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
windows luaplayer - includes the simple menu and simple movement examples that i posted on this thread - with their own run files i also included the optional.cmd file just open it and you can choose a file that is in the luaplayer directory to run with the luaplayer
download:
http://www.sendspace.com/file/14kijf
------ FaT3oYCG -----
AKA Craig, call me what you want to It's your preference.
My Website: http://www.modern-gamer.co.uk/
Currently working on:
(0) MediaGrab
(0) PGE Gears Of War - On hold (Very large project).
(0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).
-
04-10-2008, 11:46 AM #8492QJ Gamer Blue
- Registriert seit
- Apr 2008
- Beiträge
- 497
- Points
- 4.268
- Level
- 41
- Downloads
- 0
- Uploads
- 0
thanks alot!!
-= Double Post =-
I tryed it and it started, but then my speakers made a wierd noise, and now there is a luaplayer.exe.stackdump in the file. What did I do wrong??
-= Double Post =-
nvm, now it works just fine. but the config.cfg wont load, should it??Geändert von PSProgramer (04-10-2008 um 11:57 AM Uhr) Grund: Automerged Doublepost
-
04-10-2008, 12:01 PM #8493Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
lol i dont know what operating system are you using and the stack dump is just an error file you can delete it unless it has anything usefull that might tell us why it crashed inside
Zitat von PSProgramer
ok and the config.cfg is just the file where the x and y co-ordinates from the simple_movement.lua are stored press X to save the co-ordinates then close and restart it and it should start from the last position it was at------ FaT3oYCG -----
AKA Craig, call me what you want to It's your preference.
My Website: http://www.modern-gamer.co.uk/
Currently working on:
(0) MediaGrab
(0) PGE Gears Of War - On hold (Very large project).
(0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).
-
04-10-2008, 12:02 PM #8494Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
to load it to make Link' X and Y watever is in the Config file
That's how Fat30YCG Taught me lolCode:Link = {} dofile("/config.cmd")
-
04-10-2008, 12:10 PM #8495QJ Gamer Blue
- Registriert seit
- Apr 2008
- Beiträge
- 497
- Points
- 4.268
- Level
- 41
- Downloads
- 0
- Uploads
- 0
thanks alot guys, it's all making since now. One last thing that I'm still haveing trouble with is the adding of alpha, I tryed to follow, your instructions, but I couldn't find the remove color tool. If I PM you a sprite sheet, can you send me back an example of what it's supposed to do?? I only need the first character on the sheet, right now, so I can figure out how to do, this, because I have alllllllllllloooooooooooo oottttttttttttttttt of spites, and sprite sheets.
thanx again
-
04-10-2008, 12:14 PM #8496Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
i just use the CUT tool, use the magic wand and Cut, colour gone.
-
04-10-2008, 12:16 PM #8497QJ Gamer Blue
- Registriert seit
- Apr 2008
- Beiträge
- 497
- Points
- 4.268
- Level
- 41
- Downloads
- 0
- Uploads
- 0
By the way, since Dan369 is here, I was wondering if you mind, if I borrow some of your sprites?? They are really similar to mine, maybe from the same sprite sheet. If not it's cool. Just asking.
Thanks for helping by the way.
And I think you Zelda is coming along great, hope mine is close to as good as yours.
-= Double Post =-
I tried to run my Zelda program so far on lua for windows and I got this error:
error:Zelda.lua:30: 'end' expected (to close 'if' at line 18) near '(eof)'
I am working on putting in a timer, so that a stream of text comes at different times, rather than all at once. I do not no how, to fix it, please help, and what is (eof)??
thanx for the help.Geändert von PSProgramer (04-10-2008 um 12:54 PM Uhr) Grund: Automerged Doublepost
-
04-10-2008, 01:28 PM #8498Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
eof is end of file - basically you have missed an end out somewhere
e.g.
if something then
blah
blah
blah
should be
if something then
blah
blah
blah
end
the remove colour tool is on the picture tool bar, it is the pen with an arrow pointing down and left it is not highlighted bit it is on the last tool bar at the top in the middle of the screen
Zitat von PSProgramer
like on this picture
also if dan lets you use his then thats fine if you still cant do it ill do it for youGeändert von FaT3oYCG (04-10-2008 um 01:55 PM Uhr)
------ FaT3oYCG -----
AKA Craig, call me what you want to It's your preference.
My Website: http://www.modern-gamer.co.uk/
Currently working on:
(0) MediaGrab
(0) PGE Gears Of War - On hold (Very large project).
(0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).
-
04-10-2008, 04:44 PM #8499QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 550
- Points
- 5.381
- Level
- 47
- Downloads
- 1
- Uploads
- 0
eof stands for End of File. Basically, you've got more if/while/repeat/switch statements you have ends. Go back and indent your code if you do not already, and go to line 18, and see if anything doesn't make sense there.
Zitat von PSProgramer
Next time, post your code. Not the whole program, just the lines around the line the error is referring to. Also, with game mechanics code, I recommend you test it in the lua interpreter (Not to be mistaken with luaplayer for windows) first. While it will not give you a fancy output, it will give you a nice trace-back when an error occurs.
You need to start learning how to help yourself. Don't go running to the help thread everytime you reach a minor snag. Do some research, etc. Google if you friend.
Lastly, I don't think you should be tackling such a big project if you can't even create a menu, start smaller games and build your way up (Try a tetris clone, or maybe minesweeper (I haven't seen that for the PSP yet)). I guarantee you that you will abandon this project before you even have your first level running.
Oh, and to create transparency in an image, go download Gimp. It is an free, open-source image editor that is almost as good as photoshop. There are plenty of guides on the internet that deal with your problem. Also most sprite sheets use a specific colour for transparency. In Gimp, you should just be able to to a colour replace.Geändert von Nielkie (04-10-2008 um 05:13 PM Uhr)
-
04-11-2008, 05:36 AM #8500QJ Gamer Blue
- Registriert seit
- Apr 2008
- Beiträge
- 497
- Points
- 4.268
- Level
- 41
- Downloads
- 0
- Uploads
- 0
Nielkie
I would like to thank you for your concern, but I plan on writing this entire thing. So what if I can't do some of the things, to get started. Thats always the hard part for me, getting started. Once I get the minor kincks out in the begining, I will be fine for at least a little awhile. Thank you for your help. And yes, I believe i did fix the problem. thank you Fat3oYCG you have helped me alot, and haven't critisized me yet. I thank you for not putting down newer programers. And thanx for the help on the alpha thing, I think I got it.
-
04-11-2008, 08:16 AM #8501Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
well thank you for your appreciation not everyone is that nice, also that isnt 100% true, i do put down some new programmer but only the ones that talk rubbish and dont look promising, mainly if they fail from the start then they will fail forever, i learned lua by myself and found it hard to find relevant material until i cam e here and had the same sort of problems as you, but like you i asked and got some good answers, you will see this if you look furnther back through this thread, i now consider myself to be and advanced programer in the lua programming language, although i do not know every little thing i can learn and understand new features of the language quickly, i can see you becoming just as good as me if you practice and put in the work, but make sure you dont just rely on other people telling you the answer, somtimes it is good to try something out and then if you cant get it to work maybe ask if it is the right method to use if you still cant do it then i would ask for some help but overall i wish you the best of luck, you are a budding programmer in the making, happy coding
Zitat von PSProgramer
thanks
[email protected]------ FaT3oYCG -----
AKA Craig, call me what you want to It's your preference.
My Website: http://www.modern-gamer.co.uk/
Currently working on:
(0) MediaGrab
(0) PGE Gears Of War - On hold (Very large project).
(0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).
-
04-11-2008, 08:49 AM #8502QJ Gamer Blue
- Registriert seit
- Apr 2008
- Beiträge
- 497
- Points
- 4.268
- Level
- 41
- Downloads
- 0
- Uploads
- 0
thank you for the support, and Help, I really do appreciate it, and I will quit asking so many questions. It was just so very overwelming in the beginning, looking at all the stuff I needed to do, but it isn't so bad now that I look at it. I have customized your menu, I do appreciate that by the way. There are only 4 options, rather than 5 and I moved the place, and spaceing of the options. One thing, though that I am haveing trouble with, is putting in a background. I know how to "screen:blit" to input images, but i can't get it to fill the background like I want to. But yeah, other than that I am all good. I got the transparency on my sprites, finally. Thanx for that. I have already got almost all the sprites needed for running in all directions transparent. thanks for all the help. I will PM you later in the day on my progress so far.
-PSProgramer
-
04-18-2008, 11:27 AM #8503
hey everyone, im making great progress on my game, but i need help, what is the command to exit?
ive been using this, but the psp freezes when i press square
also im using hm6Code:if controls:square() then os.exit() end
My Projects
[URL="http://www.megaupload.com/?d=Q860B1VV"]BUMPER HARVEST MOD - PEGGLE DELUXE BETA 1[/URL]
working on Zuno, an uno like game
[QUOTE=FreePlay]It's a picture of a monkey. There, I spoiled it for you.[/QUOTE]
-
04-18-2008, 12:00 PM #8504
Hi,
Zitat von ifiwere1337
this should work:
I have not tried it but i think it should work because it is on this list:Code:if controls:square() then System.Quit() end
http://luaplayerhm.xtreemhost.com/in...view=functions
-
04-18-2008, 04:14 PM #8505
oh, i didnt know they had a list of functions on the site, i will try that thanks
Zitat von sony psp player
--edit
thanks it worksMy Projects
[URL="http://www.megaupload.com/?d=Q860B1VV"]BUMPER HARVEST MOD - PEGGLE DELUXE BETA 1[/URL]
working on Zuno, an uno like game
[QUOTE=FreePlay]It's a picture of a monkey. There, I spoiled it for you.[/QUOTE]
-
04-19-2008, 05:49 AM #8506QJ Gamer Blue
- Registriert seit
- Mar 2006
- Beiträge
- 48
- Points
- 4.355
- Level
- 42
- Downloads
- 0
- Uploads
- 0
Hey guys,
could someone tell me, how to assign the ram?
thx
-
04-19-2008, 06:37 AM #8507
I don't think Luaplayer is able to assign the ram
Zitat von Kooperus
-
04-19-2008, 02:33 PM #8508
its not able yet, maybe lua player .20, but not luaplayerhm
My Projects
[URL="http://www.megaupload.com/?d=Q860B1VV"]BUMPER HARVEST MOD - PEGGLE DELUXE BETA 1[/URL]
working on Zuno, an uno like game
[QUOTE=FreePlay]It's a picture of a monkey. There, I spoiled it for you.[/QUOTE]
-
04-19-2008, 02:51 PM #8509Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
the ram is automatically assigned for what is needed when its all used it runs out of ram this is also called memory we can solve this by using the collectgarbage() function or the System.memclean() in luaplayer hm, but it would be good to be able to assign ram / memory so that it could be overwritten every time that section gets full, if it was doing a process that needed lots of ram but didnt need to store all of the data in the ram at one time
basically no there isnt a function but you can clear the ram of unused variables and code with functions that are available------ FaT3oYCG -----
AKA Craig, call me what you want to It's your preference.
My Website: http://www.modern-gamer.co.uk/
Currently working on:
(0) MediaGrab
(0) PGE Gears Of War - On hold (Very large project).
(0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).
-
04-21-2008, 03:51 PM #8510QJ Gamer Blue
- Registriert seit
- Jan 2007
- Ort
- U.S.
- Beiträge
- 405
- Points
- 7.014
- Level
- 55
- Downloads
- 0
- Uploads
- 0
Okay. I'm working on saving/loading sets for my Marching Band Drill Writer program. I have saving working so that a text file is written to, with all the x and y coordinates of all the dots on the screen on their own line. For example:
140
200
50
170
That would mean that there is a dot at coordinates (140,200) and a dot at coordinates (50,170). So saving is working. But I can't seem to get loading working. What I need to do is read those numbers from the text file and insert them into a table so they can be drawn. Here is what I have:
That seems to work fine, but when it goes back to the drawing screen, and it tries to draw the dots at the loaded coordinates, I get an error: "calling 'blit' on bad self (number expected, got nil)".Code:--outside of loop function addLocation(x,y) table.insert(locations,{x=x,y=y}) end --(looping gamestate starts here) if pad:square() and not oldpad:square() then System.usbDiskModeDeactivate() loadFile = io.open("Saved Sets/" .. loadFile2 .. ".txt","r") number = 0 locations = nil locations = {} for line in loadFile:lines() do number = number + 1 end for j = 1, number do xc = loadFile:read() yc = loadFile:read() addLocation(xc,yc) end loadFile:close() System.usbDiskModeActivate() gamestate = "game" pausestate = "select" end --here is the code that draws the X's for the dots. it's not actually here in my program, but it's in there if locations ~= nil then for i = 1, table.getn(locations) do screen:blit(locations[i].x,locations[i].y,dot) end end
NOTE: The table inserting and drawing does work fine, because it's the same way I'm doing it for the main program. It must be something with the loading/inserting after loading....
Also, I know I would have to take into account that it is reading through and reading two lines each time- therefore it should only loop that action 1/2 of the number of lines in the file times (if that makes any sense). But I've messed around with that, and I still can't get it to work at all. Ugh!
It's really bugging me (no pun intended). Thanks for any help.
-
04-22-2008, 01:13 AM #8511QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
There are 4 lines in the file. You are reading 4 sets of x and y ordinates, 2 of which don't exist.Code:for line in loadFile:lines() do number = number + 1 end for j = 1, number do xc = loadFile:read() yc = loadFile:read() addLocation(xc,yc) end[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
04-22-2008, 07:52 AM #8512Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
you could also just save the co-ordinates in a table, and just read the whole file, then you wouldnt have that problem and it would be much easier to load / save data
------ FaT3oYCG -----
AKA Craig, call me what you want to It's your preference.
My Website: http://www.modern-gamer.co.uk/
Currently working on:
(0) MediaGrab
(0) PGE Gears Of War - On hold (Very large project).
(0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).
-
04-22-2008, 12:32 PM #8513QJ Gamer Blue
- Registriert seit
- Jan 2007
- Ort
- U.S.
- Beiträge
- 405
- Points
- 7.014
- Level
- 55
- Downloads
- 0
- Uploads
- 0
Yeah, that's what I was thinking, but how would I go about only reading as many times as half the number of lines? I've tried but it says you can't manipulate a function (loadFile:lines()). Would "for j = 1, number/2 do" work? Not sure if I've tried it... I'll try it later.
Zitat von yaustar
Hmm... I'll have to try that too.
Zitat von FaT3oYCG
Thanks to both of you.
-
04-22-2008, 02:24 PM #8514Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
im not sure if this works but it should do
Code:white = Color.new(255, 255, 255) coordinate_table = { } dofile("./stored_coordinates_table.lua") function save_coordinate_data() coordinate_file = io.open("stored_coordinates_table.lua", "w") coordinate_file:write("coordinate_table = { \n") for i = 1, table.getn(coordinate_table) do coordinate_file:write("{ x = " .. coordinate_table[i].x .. ", " .. "y = " .. coordinate_table[i].y .. "}" .. " , \n") end coordinate_file:write("}") coordinate_file:close() end function addLocation(x, y) table.insert(coordinate_table, {x = x, y = y}) end oldpad = Controls.read() while true do pad = Controls.read() screen:clear() -- insert your main code here if pad:triangle() and not oldpad:triangle() then for i = 1, 10 do addLocation(4, 10) end end if pad:circle() then for i = 1, table.getn(coordinate_table) do screen:print(10, 10 + i * 10, coordinate_table[i].x .. " : " .. coordinate_table[i].y, white) end end if pad:cross() then save_coordinate_data() end -- insert your main code here if pad:start() then break end oldpad = pad screen.waitVblankStart() screen.flip() endGeändert von FaT3oYCG (04-22-2008 um 02:48 PM Uhr)
------ FaT3oYCG -----
AKA Craig, call me what you want to It's your preference.
My Website: http://www.modern-gamer.co.uk/
Currently working on:
(0) MediaGrab
(0) PGE Gears Of War - On hold (Very large project).
(0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).
-
04-22-2008, 02:46 PM #8515QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
for j = 1, math.floor(number/2)*2, 2 do
the third number is how many to increase the iterator each loop (default 1)
the math.floor(number/2)*2 will eliminate the possibility of an error from an unexpected odd number of lines in the file
-
04-22-2008, 06:42 PM #8516QJ Gamer Blue
- Registriert seit
- Jan 2007
- Ort
- U.S.
- Beiträge
- 405
- Points
- 7.014
- Level
- 55
- Downloads
- 0
- Uploads
- 0
Ok, here is what I have:
I get the error: "attempt to call global 'locations' (a table value)" at the line "table.insert(locations{x =xc,y=yc})".Code:for line in loadFile:lines() do number = number + 1 end for j = 1, math.floor(number/2)*2, 2 do xc = loadFile:read() yc = loadFile:read() table.insert(locations{x=xc,y=yc}) end
-
04-22-2008, 07:57 PM #8517QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
you forgot a comma in there. table.insert(locations>>> >>>>>,<<<<<<<<"{blahblahb lah})
-
04-23-2008, 11:49 AM #8518QJ Gamer Blue
- Registriert seit
- Jan 2007
- Ort
- U.S.
- Beiträge
- 405
- Points
- 7.014
- Level
- 55
- Downloads
- 0
- Uploads
- 0
Ahh... wow. Thanks. But there's still an error :Argh: . "calling 'blit' on bad self (number expected, got nil)". That's the line where I try to blit all of the dots at the newly loaded coordinates. After it loads it won't blit.
-
04-23-2008, 12:16 PM #8519Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Code:for i = 1, table.getn(locations) do screen:blit(locations[i].x, locations[i].y, dot) end
------ FaT3oYCG -----
AKA Craig, call me what you want to It's your preference.
My Website: http://www.modern-gamer.co.uk/
Currently working on:
(0) MediaGrab
(0) PGE Gears Of War - On hold (Very large project).
(0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).
-
04-24-2008, 02:00 PM #8520QJ Gamer Blue
- Registriert seit
- Jan 2007
- Ort
- U.S.
- Beiträge
- 405
- Points
- 7.014
- Level
- 55
- Downloads
- 0
- Uploads
- 0
Yeah, that's exactly what I have.


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