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 Freshmilk I'm a little lost. What exactly are you trying to do? You want it to display one ...
-
11-14-2008, 02:36 PM #9511
Achievements:
- Registriert seit
- Oct 2008
- Beiträge
- 18
- Points
- 2.282
- Level
- 28
- Downloads
- 0
- Uploads
- 0
No, I want it so that all I have to do is press X and it shows a different text.
So say this is my menu.
Menu Items:
1.Say yes (when selected with X prints "Yes")
2.Say no (when selected with X prints "No")
3.Exit (exits the program obviously)
Now, what im having trouble with is, when I select option 1 with X I have to hold X for the message "Yes" to stay on the screen. If i just press X the message "Yes" only stays on the screen for as long as I hold X.
What im trying to accomplish, is when I press X I want the new message of "Yes" to stay on screen till say I press O or something, i dont know yet. But I do know that i dont want to have to hold X for the message to stay on screen.
Get what im saying lol, its kind of hard to explain.
-
11-14-2008, 04:12 PM #9512
I'll bet your in a loop, and at the top of the loop is a screen clear, so when you hold X, its really clearing + displaying really quickly...
but since you dont post any code we cant be sure...-- Code Monkey : Sarien, Fishguts, Cracks and Crevices --
"Did IQ's just drop sharply while I was away?" (Ripley)
-
11-14-2008, 07:26 PM #9513QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
To your question: Yes, talk to me on msn for various methods
To original question:
Code:displayText = false while true do screen:clear(Color.new(255,255,255)) oldpad = pad pad = Controls.read if pad:cross() and not oldpad:cross() then displayText = not displayText end if displayText then screen:print(0,0,"Text is on") end screen.waitVblankStart() screen.flip() end[size=3][url=http://luaplayer.org/forums/index.php?topic=507]Complete Lua development cycle outline[/url][/size]
-
11-15-2008, 10:31 AM #9514
Achievements:
- Registriert seit
- Oct 2008
- Beiträge
- 18
- Points
- 2.282
- Level
- 28
- Downloads
- 0
- Uploads
- 0
-
11-18-2008, 04:29 PM #9515
Achievements:
- Registriert seit
- Oct 2008
- Beiträge
- 18
- Points
- 2.282
- Level
- 28
- Downloads
- 0
- Uploads
- 0
Well, that bit of code works but it doesnt work. Ill let you see for yourself whats going on while its being run.
Note:You will see that with what I have in my code I am still experimenting with Lua, as I amstill learning, so bear with me if some of my choices in the menu dont make sense.
Also, if your trying to run this code, put an image named image.jpg in the same folder as this .lua or it wont load properly.
Code:image = Image.load("image.jpg") red = Color.new(255,0,0) black = Color.new(0,0,0) white = Color.new(255,255,255) menustatus = 1 while true do screen:clear(black) pad = Controls.read() if pad:up() then menustatus = menustatus - 1 screen.waitVblankStart(4) end if pad:down() then menustatus = menustatus + 1 screen.waitVblankStart(4) end color={white, white, white, white, white, white} color[menustatus]=red screen:print(50, 50, "Display Text", color[1]) screen:print(50, 60, "Info", color[2]) screen:print(50, 70, "Display Image", color[3]) screen:print(50, 80, "Screen Lock", color[4]) screen:print(50, 90, "Test", color[5]) screen:print(50, 100, "Exit", color[6]) if menustatus == 1 then if pad:cross() then screen:clear(black) screen:print(50, 50, "Hey it worked!", color[1]) end end if menustatus == 2 then if pad:cross() then screen:clear(black) screen:print(50, 50, "Created by Nava -C- 2008", red) end end if menustatus == 3 then if pad:cross() then screen:blit(0,0,image) end end if menustatus == 4 then if pad:cross() then screen:clear(black) screen:print(50, 50, "Can you figure out the password?", red) end end if menustatus == 5 then while true do displayText = false oldpad = pad pad = Controls.read() if pad:cross() and not oldpad:cross() then displayText = not displayText end if displayText then screen:print(50,50, "Hey it worked!", red) end screen:waitVblankStart() screen:flip() end end if menustatus <= 0 then menustatus = 6 end if menustatus >= 7 then menustatus = 1 end screen.flip() screen.waitVblankStart() end
-
11-20-2008, 07:36 AM #9516Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
screen:clear() is defaulted to clear black, you don't really need that Or the created color unless you intend to use it.
-
11-21-2008, 12:17 PM #9517QJ Gamer Green
- Registriert seit
- Jul 2008
- Ort
- In your pocket.
- Beiträge
- 192
- Points
- 5.875
- Level
- 49
- My Mood
-
- Downloads
- 0
- Uploads
- 0
-
11-21-2008, 12:48 PM #9518Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
-
11-21-2008, 03:24 PM #9519QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
-
11-23-2008, 04:58 AM #9520Seven Year Vet. BOW DOWN.

- Registriert seit
- Dec 2005
- Ort
- Manchester, UK
- Beiträge
- 2.240
- Points
- 14.794
- Level
- 78
- My Mood
-
- Downloads
- 1
- Uploads
- 0
How hard would it be for me to port an unindented 1,400-line game into PGE lua from Lua v0.16? And for the change in speed, would it be worth doing it?
-
11-23-2008, 05:03 AM #9521Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
how complex is the code, what game is it, depends on the game.
------ 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).
-
12-03-2008, 12:15 PM #9522QJ Gamer Green
- Registriert seit
- May 2008
- Ort
- The Netherlands
- Beiträge
- 330
- Points
- 3.567
- Level
- 37
- Downloads
- 0
- Uploads
- 0
Hey people, I'm stuck with my game. The coding goes perfect but I want to make a option, that pauses the game if you press start. There's a lot of action in my game so
I really do need a pause option so people can take a break, or just want to stop for a while.
I searched google but didn't find anything.
Something like this:
Code:if pad:start() then --Pause Game (Show An Image And Pause Game) end
-
12-03-2008, 12:54 PM #9523QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
u need to create a simple variable like so:
pause = 1;
than anything that increments simple multiply it by the pause variable
and if u want to pause:
and that creates the pause state, simple do an if pause==0 then //menu hereCode:if pad:start() then --thanks dan for pointing out that it's ~, instead of ! pause ~= pause; 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
-
12-03-2008, 01:01 PM #9524Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Isn't '!pause' for C?
In Lua it's '~=' So it would be
Code:pause ~= pause;
-
12-03-2008, 01:03 PM #9525QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
sorry, haven't used lua in a long time, it's why i said for someone to correct me if i'm wrong, and it's for many other languages than just C, but it's the major one for homebrew, so yes
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
-
12-03-2008, 01:07 PM #9526QJ Gamer Green
- Registriert seit
- May 2008
- Ort
- The Netherlands
- Beiträge
- 330
- Points
- 3.567
- Level
- 37
- Downloads
- 0
- Uploads
- 0
Does somebody know where I can find a sample, or post a sample?
Is this code right:
Code:if pad:start() then pause ~= pause; screen:blit("0,0, pause") end
-
12-03-2008, 01:07 PM #9527Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
-
12-03-2008, 01:34 PM #9528Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
------ 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).
-
12-03-2008, 05:28 PM #9529QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
pause = not pause
[size=3][url=http://luaplayer.org/forums/index.php?topic=507]Complete Lua development cycle outline[/url][/size]
-
12-04-2008, 06:30 AM #9530QJ Gamer Green
- Registriert seit
- May 2008
- Ort
- The Netherlands
- Beiträge
- 330
- Points
- 3.567
- Level
- 37
- Downloads
- 0
- Uploads
- 0
I don't understand. How is the code got to be then?
-
12-04-2008, 11:53 AM #9531Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Simple.
Say you have a boolean called pause,
then you have your if statement,
then another simple if statementCode:if press sumthing then pause = true end
Basically if pause then do things, pause would either be true Or false. When you press say start it would make it true, then that if comes into play.Code:if pause then blit watever end
Then have another If checking e.g
if pause is true & you set it to not pause (or any boolean) then it basically means the opposite, so pause would be......... (i know but i want malliet to answer, see if he understands)Code:if pad:cross() then pause = not pause end
-
12-04-2008, 12:24 PM #9532
- Registriert seit
- Feb 2007
- Ort
- In the heart of europe!
- Beiträge
- 22
- Points
- 3.497
- Level
- 36
- Downloads
- 0
- Uploads
- 0
Hi there!
Is there any way to merge the source of my lua game into the eboot.pbp? I don't want the people to complain about my style in writing games
Thanks in advance!
-
12-04-2008, 01:23 PM #9533QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
from: LUA development Help
and if you still want to do it:
hopefully that helps you, and next time try to search first=-), and lastly if you manage to accompalish what you wanted to do, than don't listen to people complaining about your code, it only happens if you release something really, really pointless, and easy to do with a few lines of lua1. 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
-
12-04-2008, 05:04 PM #9534QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 550
- Points
- 5.381
- Level
- 47
- Downloads
- 1
- Uploads
- 0
Why don't you want people criticising your code? People don't just say "ZOMG HIS CODZ SUCK LOLOLO U SUCK!!!!!!!!!!!!!11111", most people will give you helpful suggestions and advice for improving yourself.
Besides, if you have bad code and you just bytecode your app, people will then just complain about the fact that it is bytecoded.
-
12-05-2008, 05:46 AM #9535
- Registriert seit
- Feb 2007
- Ort
- In the heart of europe!
- Beiträge
- 22
- Points
- 3.497
- Level
- 36
- Downloads
- 0
- Uploads
- 0
-
12-05-2008, 08:58 AM #9536
Achievements:
- Registriert seit
- Dec 2008
- Beiträge
- 27
- Points
- 2.231
- Level
- 28
- Downloads
- 0
- Uploads
- 0
how do u load a .wav file in luaplayer? please help
-
12-05-2008, 09:06 AM #9537QJ Gamer Green
- Registriert seit
- May 2008
- Ort
- The Netherlands
- Beiträge
- 330
- Points
- 3.567
- Level
- 37
- Downloads
- 0
- Uploads
- 0
-
12-05-2008, 09:12 AM #9538
Achievements:
- Registriert seit
- Dec 2008
- Beiträge
- 27
- Points
- 2.231
- Level
- 28
- Downloads
- 0
- Uploads
- 0
thanks malliet :)
-=Double Post Merge =-
well now i have a problem my psp freezes look at my code please see if anythings wrong
korn = Sound.load("Music/korn.wav")
if pad:l() then
korn:"without these quotes"play()
end
theres more code in between but these are what im haveing trouble withGeändert von KiNGxLeGiTx (12-05-2008 um 09:29 AM Uhr)
-
12-05-2008, 09:31 AM #9539QJ Gamer Green
- Registriert seit
- May 2008
- Ort
- The Netherlands
- Beiträge
- 330
- Points
- 3.567
- Level
- 37
- Downloads
- 0
- Uploads
- 0
-
12-05-2008, 09:33 AM #9540
Achievements:
- Registriert seit
- Dec 2008
- Beiträge
- 27
- Points
- 2.231
- Level
- 28
- Downloads
- 0
- Uploads
- 0
i figured out what was wrong but i still need help its my wav file i loaded up another one and it worked but i cant get my korn.wav to work
Geändert von KiNGxLeGiTx (12-05-2008 um 10:53 AM Uhr)


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