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; Zitat von yaustar Yongobongo: I gave you this 2-3 pages back Here is the complete listing from GameDev. http://www.gamedev.net/reference/list.asp?categoryid=18 There ...
-
01-18-2007, 03:35 PM #5131.info

- Registriert seit
- Jun 2006
- Ort
- ACT, Australia
- Beiträge
- 1.674
- Points
- 15.395
- Level
- 80
- Downloads
- 0
- Uploads
- 0
Thanks, i've got some simple AI working now :)
Zitat von yaustar
-
01-18-2007, 03:43 PM #5132QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- Missouri
- Beiträge
- 451
- Points
- 6.041
- Level
- 50
- Downloads
- 0
- Uploads
- 0
So how exactly do I fix it?
-
01-18-2007, 03:45 PM #5133QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
You make it stop double flipping it every loop.
-
01-18-2007, 03:48 PM #5134QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- Missouri
- Beiträge
- 451
- Points
- 6.041
- Level
- 50
- Downloads
- 0
- Uploads
- 0
wehn i do that. like if i remove the first screen.flip() it will load everything so fast and stop.
-
01-18-2007, 03:58 PM #5135
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
Well take it out of the loop or make the data loading in the loop then add a break then load the animation in another while loop.
Zitat von Cheez Pirate
-
01-18-2007, 04:00 PM #5136QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Well why dont you just ditch a loading screen? What you have loads in like 0.1 seconds, why unnecessarily make people wait?
-
01-18-2007, 04:03 PM #5137
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
what is the pad:Controls:read() for??Code:white = Color.new(255,255,255) red = Color.new(255,0,0) black = Color.new(0,0,0) dofile("lib/animlib.lua") logo = ANIM.new(8,"logo","png","logo/") loadingscreen = Image.load("images/loadingscreen.png") loadingbar = {} loadingbar.y = 11 data = {} data.loaded = 0 cursor = Image.load("images/cursor.png") data.loaded = data.loaded + 25 * 4 nameofimage = nil while true do pad = Controls.read() screen:clear(white) logo:advancedBlit(0,0,500,1) screen.flip() screen:clear(white) screen:blit(0,0,loadingscreen) screen:fillRect(47,205,data.loaded,loadingbar.y,red) screen.waitVblankStart() screen.flip() end
-= Double Post =-
Exactly there is no need to make a loading screen unless you use something that takes a while like netlib or sumfin
Zitat von TacticalPinguin
Geändert von pspfreak9 (01-18-2007 um 04:03 PM Uhr) Grund: Automerged Doublepost
-
01-18-2007, 04:56 PM #5138QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- Missouri
- Beiträge
- 451
- Points
- 6.041
- Level
- 50
- Downloads
- 0
- Uploads
- 0
Well the thing is... That isn't a complete game lol. There will be a lot more. Now what does break do? :X
-
01-18-2007, 06:18 PM #5139words 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
the keyword 'break' does just what it says - 'breaks' the current running loop.
pad = Controls.read() will return the current state of the PSPs buttons, each true or false. So, by placing it in a loop, your constantly checking for a changae in button presses, therefor calling if pad:cross() your checking the pad metatable (or wahtever it is in lua... its a structure in C) to see if the cross button is checked to true indicating its being pressed.
Or something like that im sure
...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-18-2007, 07:14 PM #5140QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- Missouri
- Beiträge
- 451
- Points
- 6.041
- Level
- 50
- Downloads
- 0
- Uploads
- 0
I don't think the 2 of you before SG57 know what i'm saying.
How can I blit the animation and when it's OVER load the loading screen. And I know the load screen is 0.1 seconds. It's not anywhere near what else i'll be loading in the future.Code:white = Color.new(255,255,255) red = Color.new(255,0,0) black = Color.new(0,0,0) dofile("lib/animlib.lua") logo = ANIM.new(8,"logo","png","logo/") loadingscreen = Image.load("images/loadingscreen.png") loadingbar = {} loadingbar.y = 11 data = {} data.loaded = 0 cursor = Image.load("images/cursor.png") data.loaded = data.loaded + 25 * 4 nameofimage = nil while true do pad = Controls.read() screen:clear(white) screen:clear(white) logo:advancedBlit(0,0,500,1) screen:blit(0,0,loadingscreen) screen:fillRect(47,205,data.loaded,loadingbar.y,red) screen.waitVblankStart() screen.flip() end
-
01-18-2007, 07:50 PM #5141
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
Ok then put the animation in the script (not in a while loop) then make a while loop put your loading stuff in it then "break" and move on to whatever your going to.
TO SG57 : I know what the pad = Controls.read() is im just saying first it is in the loop why?? and I see no need for that since he hasnt used it ;)
-
01-18-2007, 08:22 PM #5142QJ Gamer Silver
- Registriert seit
- Oct 2006
- Ort
- 貴方
- Beiträge
- 1.159
- Points
- 7.371
- Level
- 57
- Downloads
- 0
- Uploads
- 0
he probably will use it in the future...
-
01-18-2007, 08:45 PM #5143QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- Missouri
- Beiträge
- 451
- Points
- 6.041
- Level
- 50
- Downloads
- 0
- Uploads
- 0
alright. loading stuff. by that you mean the loadingscreen, data.loaded, or screen:fillRect?
-
01-18-2007, 10:49 PM #5144QJ Gamer Silver

- Registriert seit
- Oct 2006
- Ort
- Pimp'en in the US F#
- Beiträge
- 1.254
- Points
- 7.278
- Level
- 56
- Downloads
- 0
- Uploads
- 0
mmmm, got the weirdest error that I've ever seen just now....
I Had just put an image in the images folder (the Pxp compo Splash Screen)
then loaded up my app on my psp, then it gave me
error: index.lua:4:Image.load Error loading image
now, that is nothing new the weird part is what happened when i opened up the images folder of my app that was on my psp after that..., what i found was..
http://img136.imageshack.us/my.php?image=screenstn2.png
all of those which look like it Fragments of lua code used to be images and folders of images...
really weird, any suggestions?
Edit: Looks like things just got worse....seems i cant delete that images directory, wouldn't let me, I went on to my psp, and that didn't work, it said "delete Failed"... WTF is going on?NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
01-19-2007, 07:55 AM #5145QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Clear everything off your PSP then format. Then put everything back on it
-
01-19-2007, 12:03 PM #5146QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
ouch, sounds like a virus.
Zitat von BlackShark
if reformatting doesnt work (it should though), try deleting it with IR shell or FileAssistant.[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
01-19-2007, 02:05 PM #5147Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von BlackShark
you memory card is corrupted. formating will make it work again. however, if it happens often, you memory card is either getting old, or is fake.--------------------------------------------------------------------------------------
-
01-19-2007, 03:12 PM #5148
Hey when I print font text EG:
screen:fontPrint(font,0,0 ,"I have probleme with this",White)
The script works fine the image and everythig blit exept the Font script.Is it maybe because the .fft is to big if yes can somone explain me how to use this and how to resise the .ttf to the size of a normal screen
rint function.Actualy I just want to know what is number dpiX/Y
Font Font:setCharSize(number width, number height, number dpiX, number dpiY)Free Prizes at Prizerebel Join us!
I already got 11 Gifts. Ask me for details or proof.
-
01-19-2007, 03:21 PM #5149QJ Gamer Silver

- Registriert seit
- Oct 2006
- Ort
- Pimp'en in the US F#
- Beiträge
- 1.254
- Points
- 7.278
- Level
- 56
- Downloads
- 0
- Uploads
- 0
ok, well, i think it was a corrupted Eboot, cuz I got a new kxploited one and put my game stuff in that one then moved everything to the stick so now every thing works as it should, however i still have that damn folder with the damned Image folder....i WOULD reformat it but i got about 3 and half GIGS of stuff on it...various..stuff...... o0... Got a 4 gig for Xmas :P I love it any way the folder only takes up about 150 kb so its not a Big problem...not anymore...
NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
01-19-2007, 03:28 PM #5150
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
Backshark I have the same type of problem when I was deleting the folder 'dh' Devhook it said it could not be deleted beacuase of one file called COOKIE.DAT So I went and found the file under 271 and deleted it. It WAS GONE. I tried deleting 'dh' and the FILE JUST CAME BACK???
-= Double Post =-
TO CHEEZPIRATE HOLD ON IM gonna make you your script again.Geändert von pspfreak9 (01-19-2007 um 03:28 PM Uhr) Grund: Automerged Doublepost
-
01-19-2007, 03:28 PM #5151QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
use File Assistant for corrupted things :)
[1 Year QJ Member]
[LUA Coder and C Learner]
[Ball Revamped Clone v0.1]
[Phil's Shooting Range v0.3]
[HideFile PRX v2]
[SSR PRX v1.1]
-
01-19-2007, 03:34 PM #5152
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
Does anyone know how to create a FPS counter??
-
01-19-2007, 03:37 PM #5153QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
yes, i made a small snippet in the lua snippets thread.
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
01-19-2007, 03:40 PM #5154
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
K thanks
-
01-19-2007, 04:36 PM #5155
how do i check if a part of a table exists?
what would be the correct way to do that case? i cant find an "isset" kind of functionCode:test = {foo=true, bar=0} if test.meep then -- was found else -- was not found end
-
01-19-2007, 05:49 PM #5156QJ Gamer Blue
- Registriert seit
- Jan 2007
- Ort
- U.S.
- Beiträge
- 405
- Points
- 7.014
- Level
- 55
- Downloads
- 0
- Uploads
- 0
Please help out a noob (to lua)
Okay, so I have just begun learning lua recently, and I am making a stupid app for practice/learning. I have this code:
First let me tell you what it is supposed to do- there is a start screen that is a menu with choices between 2 different songs to play. If you click (cross) on a song, it should go to a new screen that says "press x to play song, press x again to pause song, enjoy." The selected song should play once pressing cross, pause if cross is pressed again, and that's about it. I have many problems-the selector for the menu doesn't move, when I press X it sometimes plays music, sometimes it doesn't, and instead of pausing it stops it completely and starts back over when I press X again. Thanks for any help, I know this is confusing. Hopefully the code is at least sort of neat.Code:--App by andyauff --Version .02 of "Useless Music App", finished January , 2007 --define colors--------------------------------------------------- white = Color.new (255,255,255) blue = Color.new (0,0,255) black = Color.new (0,0,0) red = Color.new (255,0,0) green = Color.new (0,255,0) yellow = Color.new (255,255,0) purple = Color.new (255,0,255) --create the menu function---------------------------------------- function drawMenu() gamestate = "menu" oldpad = Controls.read() song = "mindwave" selector = { image = Image.createEmpty (145,15), x = 147, y = 77} selector.image:clear(yellow) screen:clear(green) pad = Controls.read() screen:blit(selector.x,selector.y,selector.image) screen:print(150,80,"Mindwave",blue) screen:print(150,100,"Minute",blue) --controls if pad:up() and oldpad:up() ~= pad:up() then selector.y = 77 song = "mindwave" end if pad:down() and oldpad:down() ~= pad:down() then selector.y = 97 song = "minute" end if pad:cross() and oldpad:cross() ~= pad:cross() then inGame() end screen.flip() end --create the game funtion------------------------------------------ function inGame() gamestate = "start" pad = Controls.read() screen:clear(red) screen:print(150,100,"To play song, press X.",green) screen:print(150,120,"To pause song, press X again.",yellow) screen:print(150,140,"Enjoy!",purple) if pad:cross() and gamestate == "start" and song == "mindwave" then Music.playFile("mindwave.mod", false) gamestate = "playing" end if pad:cross() and gamestate == "start" and song == "minute" then Music.playFile("minute.xm", false) gamestate = "playing" end if pad:cross() and gamestate == "playing" then Music.pause() gamestate = "paused" end if pad:cross() and gamestate == "paused" then Music.resume() gamestate = "playing" end if pad:start() then gamestate = "menu" end screen.flip() end --main loop--------------------------------------------------------- while true do drawMenu() oldpad = pad end
-
01-19-2007, 05:58 PM #5157QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
It would work since test.meep will return nil although I wouldn't recommend it from a programming style/design standpoint.
Zitat von eyece
[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-19-2007, 06:26 PM #5158
no, thats what i tried, it didn't work, it just returns the "attempt to index field '?'" error,
i may have to have all the table parts set to false, kind of gay though, LUA-Player v0.21 should have implemented something like this:
if ~variable then
...
end
-
01-19-2007, 06:31 PM #5159
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
Hey how can i like change print to a function like this:
toCode:print(buffer)
Some thing like that. What im trying to say is how can i transfer what is printed to somewhere elseCode:if buffer ... then ... end
-
01-19-2007, 06:43 PM #5160
Can somone anwser to my question please.Page 516 firstpost.
Free Prizes at Prizerebel Join us!
I already got 11 Gifts. Ask me for details or proof.


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