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; Try to indent and put spaces...That way your code is much neater to look at and better organization.....
-
01-08-2007, 11:07 PM #4951lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
Try to indent and put spaces...That way your code is much neater to look at and better organization..
-
01-08-2007, 11:24 PM #4952words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
Yes, loading another file via dofile(".lua") will stop all scripts besides what you just loaded... Meaning you have to have some sort of loop to keep that script from reaching the bottom...

...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
01-09-2007, 02:13 AM #4953QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
No it doesn't, it runs the script you just loaded inside the script that you called it from. Using dofile recklessly (ie circlar dofiles) will lead to internal memory leaks and stack overflows.
Zitat von SG57
[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]
-
01-09-2007, 03:40 AM #4954
I need help i wanne know how to change the current direction
like if the current direction is MS0:NewMap/
and i want to change it to MS0:NewMap/stuff/
-= Double Post =-
is that dangerous ? because i am working on a software and i have dozen of dofiles like when i click start menu dofile startmenu when i click it down dofile desktop.
Zitat von yaustar
Geändert von mbr7 (01-09-2007 um 03:40 AM Uhr) Grund: Automerged Doublepost
-
01-09-2007, 05:24 AM #4955QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- Missouri
- Beiträge
- 451
- Points
- 6.041
- Level
- 50
- Downloads
- 0
- Uploads
- 0
So I take it SG57 is wrong and a new loop in each file is not the way to go?
Is this dangerous? Should I put all my code in one file?
Zitat von yaustar
EDIT: Off-topic: Is the X360 Gamercard avatar for the forums for premium members only? Coz mine isn't showin.
-
01-09-2007, 06:24 AM #4956QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Bottom line, if you use dofile, make sure you use then correctly. For those C/C++ coders out there, you are essentially calling a function in a function. If those functions never end, then the variables on the stack don't get cleared up and overflow.
To check if your app will have this problem, he is an exercise to do. Scan you 'root' file. Replace all the dofiles calls with the contents of the files that you are calling. Once you have done that you should have one file with the contents of other files in it. Do the same thing again until there are no more dofile calls. If you find that you never stop doing this, then you have a problem and you can see why.[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]
-
01-09-2007, 10:30 AM #4957QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
how about if the script that has the dofile merely loads variables and functions? would it be 'dangerous' then?
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
01-09-2007, 01:09 PM #4958Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
Dofiles arent bad its ok if your using them to load stuff or go to a new area or something but only when they are nessceary (lol spelling). Just dont overdue it like
--my app
--colors
dofile
--pics
dofile
--fonts
dofile
while true do
--main loop and functions
dofile
end
--flip and stuff
dofile
just dont over due it.If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
Gold donations are highly appreciated!
-
01-09-2007, 03:15 PM #4959QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Changing the current directory is easy.
Zitat von mbr7
Say we're in a directory called "dir" and it contains a folder called "dir2"
System.currentDirectory(" ./dir2")
Then to goup a directory:
System.currentDirectory(" ./..")
And for more directory functions, check the lua examples snippets etc thread at the bottom is a filebrowser snippet I wrote.
-
01-09-2007, 04:07 PM #4960lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
I only use dofile's to load a menu or options, Evrything else is inside one script, I really dont like to put more than 3 dofiles in a single script.
Zitat von GuitarGod1134
XBOX360 AVATAR: You need to have a regular avatar loaded first.
-
01-09-2007, 04:26 PM #4961Designs

- Registriert seit
- Jul 2006
- Ort
- Canada
- Beiträge
- 1.395
- Points
- 14.040
- Level
- 76
- Downloads
- 0
- Uploads
- 0
is it possible to overclock a psp in lua. so when the game starts it sets the psp to 333 mhz automatically

-
01-09-2007, 04:48 PM #4962lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
You need cools lua player mod.
-
01-09-2007, 04:53 PM #4963.info

- Registriert seit
- Jun 2006
- Ort
- ACT, Australia
- Beiträge
- 1.674
- Points
- 15.395
- Level
- 80
- Downloads
- 0
- Uploads
- 0
333 mhz is the max anyway, you can also use the systemext or something lrx y be2003 on ps2dev
-
01-09-2007, 04:56 PM #4964lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
Nevermind, In his release thread he said he removed the overclocking function cause it can be dangerous if you dont use it right.
-
01-09-2007, 05:04 PM #4965QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
well...I use it and it works fine. (cools' mod 2)
i just set the cpu speed to 333 in the beginning and at the end i set it back to 222. everything's worked normal, as expected.[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
01-09-2007, 05:07 PM #4966QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- Missouri
- Beiträge
- 451
- Points
- 6.041
- Level
- 50
- Downloads
- 0
- Uploads
- 0
You've failed to answer my main question. How do you keep a image from disapearing after 1 frame? Dark_Merlins way doesn't work.
-
01-09-2007, 05:11 PM #4967lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
Why dont you find out? You cant expect to come here and ask a million questions and hope someone answers it.
Zitat von Cheez Pirate
-
01-09-2007, 05:11 PM #4968QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
well...i dont know what your code is but you could set a variable for it like this:
Zitat von Cheez Pirate
that should give you a basic concept. :)Code:imageblitted = false ... while true do ... ... if something then imageblitted = true end ... ... if imageblitted = true then screen:blit(x, y, image) end ... ... end
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
01-09-2007, 06:22 PM #4969QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- Missouri
- Beiträge
- 451
- Points
- 6.041
- Level
- 50
- Downloads
- 0
- Uploads
- 0
That's understandable. Thanks.
Zitat von EminentJonFrost

And to pspgamer81. I always try to find out before I post.
-
01-09-2007, 06:39 PM #4970lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
You can try a little bit harder than, I was like this before, I didnt know anything, But once you sit down, Go over the functions, Understand the code, Then you wont need to be coming here alot.
Zitat von Cheez Pirate
-
01-09-2007, 06:59 PM #4971words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
Cheez_Pirate - Dont mind pspgamer. He's just a little social butterfly... Loves to post, not saying what he says is 100% true... He's even hypicritical at times, like just there... Funny how he doesnt want you posting a zillion questions/problems where he is already half way to a zillion... Maybe he doesnt like competition ;)
And honestly, just learn the game programming theory, or if your still struggling with the whole 'programming concept' then make small demos and read tutorials. Once you get those 2 down, nothings stopping you from making a game in any language, as long as your willing to learn that languages syntax... Oh and if that machine allows arbitrary code to be ran :X
...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
01-09-2007, 07:06 PM #4972Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
lol, i wouldnt be talking. im not even sure if YOU understand the code.
Zitat von pspgamer81
OT:
you sig text makes no sense. you cant die in hell, dont you have to be dead to even get there?--------------------------------------------------------------------------------------
-
01-09-2007, 07:11 PM #4973lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
Nope, You can be alive.
Lets get back on topic.
-
01-09-2007, 08:27 PM #4974QJ Gamer Blue
- Registriert seit
- Jun 2006
- Ort
- In the shadows..
- Beiträge
- 135
- Points
- 4.936
- Level
- 44
- Downloads
- 0
- Uploads
- 0
hey i asked my ques in another thread sometime back when someone told me to post my question in this thread instead.. so here it is..
My question is.. Say for example i have a file containing many lines of text/code... Now what i want to do is when i press the button 'x' then the screen should show the text which is on the offset 0x0002DE0 , how can i do this?
when i use the file:seek("set",0x0002DE0 ) [suggested by youresam] then it prints 11744 on the screen but i dont want that as the output.. i want it to print the value at that offset in the file it has opened..
for example, there is a file called hello.reg in which at the offset 0x0002DE0 the value 1111 is stored, so when it opens the file, i want it to show the value 1111 instead of 11744 .. now some of you may say that instead of using 0x0002DEO i should use 0xF to show 1111 but that value is dynamic, if i change 1111 to 2222 then it should show that value at the offset 0x0002DE0 ..
i dont know if you understood what i mean to say but thats what i mean :-) .. also if this is not possible then how can i open up a file in hex mode on the psp using lua? if i can open the file in hex mode then i may be able to pick up from there to do the function i want it to do..
-
01-09-2007, 08:33 PM #4975
>_< Can someone help me with my code, it is really slow and the fps meter shows 0 all the time.
Heres the files http://upload.team-duck.com/users/Da...0Espionage.rarhttp://upload.team-duck.com/users/Da...vector-sig.png
http://upload.team-duck.com/users/Da...n/SOTW-Bar.jpg
I do not eat my babies - twelve
View the QJ Worm!
-
01-09-2007, 10:01 PM #4976QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- Missouri
- Beiträge
- 451
- Points
- 6.041
- Level
- 50
- Downloads
- 0
- Uploads
- 0
I've updated my code a little. Now when I press X on menustatus = 1 it will go to the singleplayer1 menu. I want it to go back to the main menu when triangle is pressed. It won't work. I want to go to singleplayer2 menu when X is pressed in singleplayer1 menu. It won't work.
When I try to load multiplayer by pressing X on menustatus = 2 it says the image could not be found. Returned as boolean. But I checked the paths and filenames like 10 times and it's all right but it won't load the multiplayer1 menu.
Code:white = Color.new(255,255,255) menustatus = 1 singleplayer1 = false singleplayer2 = false multiplayer1 = false menu1 = Image.load("images/menu1.png") cursor1 = Image.load("images/cursor1.png") multiplayer1 = Image.load("images/multiplayer1.png") singleplayer1 = Image.load("images/singleplayer1.png") singleplayer2 = Image.load("images/singleplayer2.png") oldpad = Controls.read() while true do pad = Controls.read() screen:clear(white) screen:blit(0,0,menu1) if menustatus == 1 then screen:blit(280,172,cursor1) end if menustatus == 2 then screen:blit(280,196,cursor1) end if pad:down() and oldpad:down() ~= pad:down() then menustatus = menustatus + 1 end if pad:up() and oldpad:up() ~= pad:up() then menustatus = menustatus - 1 end if menustatus == 0 then menustatus = 1 end if menustatus == 3 then menustatus = 2 end --singleplayer1 if pad:cross() and menustatus == 1 then singleplayer = true end if singleplayer == true then screen:clear(white) screen:blit(0,0,singleplayer1) end if singleplayer1 == true and pad:cross() then singleplayer2 = true singleplayer1 = false end if pad:triangle() and singleplayer1 == true then singleplayer1 = false end --singleplayer2 if singleplayer2 == true then screen:clear(white) screen:blit(0,0,singleplayer2) end if pad:triangle() and singleplayer2 == true then singleplayer2 = false end --multiplayer1 if pad:cross() and menustatus == 2 then multiplayer1 = true end if multiplayer1 == true then screen:clear(white) screen:blit(0,0,multiplayer1) end if pad:triangle() and multiplayer1 == true then multiplayer1 = false end --reloading main menu if singleplayer1 == false or multiplayer1 == false and singleplayer2 == false then screen:clear(white) screen:blit(0,0,menu1) end --reloading singleplayer1 menu if singleplayer2 == false and menu1 == false then screen:clear(white) screen:blit(0,0,singleplayer1) end screen.waitVblankStart() screen.flip() oldpad = pad end
-
01-10-2007, 12:57 PM #4977QJ Gamer Silver
- Registriert seit
- Aug 2006
- Ort
- The Matrix
- Beiträge
- 1.090
- Points
- 8.002
- Level
- 60
- Downloads
- 0
- Uploads
- 0
i was wondering how to delete a directory and ALL its files, like deleting "/psp/game/mygame/temp/" then "*.*"
-= Double Post =-
i tried
Didn't workCode:System.removeFile("*.*")Geändert von CoolRaccoon (01-10-2007 um 12:58 PM Uhr) Grund: Automerged Doublepost
http://i28.tinypic.com/1znoljt.png
lolololololol - Reach 100,000 Gamerscore
-
01-10-2007, 01:27 PM #4978
- Registriert seit
- Dec 2006
- Beiträge
- 14
- Points
- 3.536
- Level
- 37
- Downloads
- 0
- Uploads
- 0
I have a huge problem i really need help in. I am making a app that requires alot of animation and many of my animation use up to 100 frames. I am using the anilib V.4, and al my frames are in jpg format. here are my problems
1. trieng to use .png images give me a "cannot load image" error
2. the animation will work fine if less than 30 frames, but if its over 30 my program freeezes.
this is really holding me back if any one has any advice it would be greatly appreciated
-
01-10-2007, 01:48 PM #4979QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Write your own or extend animlib to unload any animation frame images that are not being used from memory and load the frames that you need next or only load the images you need for the current frame. It be relatively slow but you have no choice since you are running out of memory.
Zitat von yotop456
Why on earth would you need 100 frames for an animation any way?[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]
-
01-10-2007, 05:21 PM #4980QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
i'll help out some, cheez pirate.

first off, theres alot of 'if' statements that can be cleaned up...too little time over here to type explanations. i'll just fix it up for you for now.
take a look at this and see if you see an error that will obviously give you some trouble later on:
Code:singleplayer1 = false singleplayer2 = false singleplayer1 = Image.load("images/singleplayer1.png") singleplayer2 = Image.load("images/singleplayer2.png")i'm tired.Code:white = Color.new(255,255,255) menustatus = 1 singleplayer1 = false singleplayer2 = false multiplayer1 = false menu1 = Image.load("images/menu1.png") cursor1 = Image.load("images/cursor1.png") multiplayer1 = Image.load("images/multiplayer1.png") singleplayer1image = Image.load("images/singleplayer1.png") singleplayer2image = Image.load("images/singleplayer2.png") --better than oldpad upPressed = false downPressed = false leftPressed = false rightPressed = false crossPressed = false squarePressed = false trianglePressed = false circlePressed = false while true do pad = Controls.read() screen:clear(white) screen:blit(0,0,menu1) if menustatus == 1 then screen:blit(280,172,cursor1) elseif menustatus == 2 then screen:blit(280,196,cursor1) end if pad:down() then if downPressed == false then menustatus = menustatus + 1 if menustatus > 2 then menustatus = 2 end downPressed = true end else downPressed = false end if pad:up() then if upPressed == false then menustatus = menustatus - 1 if menustatus < 1 then menustatus = 1 end upPressed = true end else upPressed = false end --singleplayer1 if pad:cross() then if crossPressed == false then if menustatus == 1 and singleplayer1 == false then singleplayer = true elseif menustatus == 1 and singleplayer1 == true then singleplayer2 = true singleplayer1 = false elseif menustatus == 2 and multiplayer1 == false then multiplayer1 = true end crossPressed = true end else crossPressed = false end if pad:triangle() then if singleplayer1 == true then singleplayer1 = false end if singleplayer2 == true then singleplayer2 = false end if multiplayer1 == true then multiplayer1 = false end end if singleplayer1 == true then screen:blit(0,0,singleplayer1image) end if singleplayer2 == true then screen:blit(0,0,singleplayer2image) end if multiplayer1 == true then screen:blit(0,0,multiplayer1) end screen.waitVblankStart() screen.flip() end
this is what i was able to do in a few minutes. you'll see some things are missing. sorry about that. but you should be able to figure it out from there. gotta sleep. hope this helped. :)
night![CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]


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