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 Art Well mine wasn't as simple to code as: Code: RipISO(); // Please I hated the idea of ...
-
05-10-2008, 06:45 AM #8581
- Registriert seit
- Mar 2008
- Beiträge
- 40
- Points
- 2.784
- Level
- 32
- Downloads
- 0
- Uploads
- 0
no its graphics look fine compared to my friends fat PSP
Zitat von Art
-
05-10-2008, 10:55 AM #8582
- Registriert seit
- Mar 2008
- Beiträge
- 40
- Points
- 2.784
- Level
- 32
- Downloads
- 0
- Uploads
- 0
another question
Another question, i want to make it where i press a button, text appears, and then it goes away after about 3 seconds, like this for example:
I press X, and it says on the bottom:
USB mode activated!
and then it goes away after 3 seconds.
I know how to do the USB thing, but as for the txt appearing and going away....
well, can anyone help?
-
05-10-2008, 01:50 PM #8583Local Tech
- Registriert seit
- Oct 2007
- Ort
- home
- Beiträge
- 1.821
- Points
- 9.044
- Level
- 63
- Downloads
- 1
- Uploads
- 0
so are you gonna release it??
-
05-10-2008, 01:54 PM #8584QJ Gamer Platinum
- Registriert seit
- Feb 2006
- Ort
- National Front Disco
- Beiträge
- 13.057
- Points
- 66.627
- Level
- 100
- Downloads
- 0
- Uploads
- 0
Merged with the Lua Help Thread. :)
-
05-10-2008, 02:48 PM #8585QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
removeUSBTextCounter = 0
while true do
if pad:cross() then showUSBText = true System.usbDiskModeActivat e() end
if showUSBText then
removeUSBTextCounter = removeUSBTextCounter + 1
if removeUSBTextCounter > 180 then showUSBText = false removeUSBTextCounter = 0
screen
rint(2,260,"USB mode activated!")
end
end
-
05-10-2008, 03:22 PM #8586
- Registriert seit
- Mar 2008
- Beiträge
- 40
- Points
- 2.784
- Level
- 32
- Downloads
- 0
- Uploads
- 0
ugh...
thx TurtlesPwn, but now I have another question...
When I press a button, it executes the command. Then, once its done, it goes back to the menu of my program. example:
I pressed O to go back on a system message, and it went back to the menu of my app.
but when it goes back to the menu, I can an longer press any buttons, when I press a button, nothing happins, Once I press a button, its done, i can't press any more
can anyone help?
-
05-10-2008, 04:04 PM #8587QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
Nobody can help with the info youve given us so far
-
05-10-2008, 04:14 PM #8588
- Registriert seit
- Mar 2008
- Beiträge
- 40
- Points
- 2.784
- Level
- 32
- Downloads
- 0
- Uploads
- 0
ok, ill try to be more specific:
Zitat von TurtlesPwn
Ok, lets say I pressed O in the program I have created, and it starts to play music, now I want to shut off the music, lets say i pressed X to stop the music, but it does not work...
Here is another example:
Lets say i pressed O and it displayed a picture of... a beach. and now I want to go back, Lets say I pressed X to go back, but it doesnt go back, even though i programmed it to go back
how do I fix this problem?
-
05-10-2008, 04:32 PM #8589
why dont you just ask us to write the program for you, it would be much better than writing 10 posts on how do i do this, i learned how to do that stuff by looking at past posts, you could use the search, its there for a reason
Zitat von omegaridley
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]
-
05-10-2008, 04:33 PM #8590QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 550
- Points
- 5.381
- Level
- 47
- Downloads
- 1
- Uploads
- 0
You obviously do not understand the flow of your program, that is something we cannot help you with.
-
05-10-2008, 04:43 PM #8591
- Registriert seit
- Mar 2008
- Beiträge
- 40
- Points
- 2.784
- Level
- 32
- Downloads
- 0
- Uploads
- 0
I just want a code that can loop the program so I wont have to reset the program everytime i execute a command
Zitat von ifiwere1337
can you do that?
-
05-10-2008, 05:41 PM #8592QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
Please tell me youre using a while loop.....
-
05-10-2008, 05:43 PM #8593
- Registriert seit
- Mar 2008
- Beiträge
- 40
- Points
- 2.784
- Level
- 32
- Downloads
- 0
- Uploads
- 0
yeah, but, i think, well, here is my coding(100% working except for the problem im having):
Zitat von TurtlesPwn
Code:white = Color.new(255, 255, 255) background = Image.load("SYSTEM/images/background.png") done = false while true do pad = Controls.read() if pad:cross() and done == false then System.message("UMD ISO will be dumped in name 9660.ISO, if u have a UMD dumped by this app, rename the ISO in the memory stick. Are you ready to dump the UMD?",1) button = System.buttonPressed(1) if button == "yes" then UMD.ripISO("ms0:/ISO/9660.ISO", green) end button = System.buttonPressed(1) if button == "no" then System.Quit() end done = true end if done == false then Ogg.load("SYSTEM/music/system.ogg") Ogg.play() screen:blit(0, 0, background, false) screen:print(1, 1, "press X to Dump UMD Disk", white) end if pad:circle() and done == false then System.message("Dumping a UMD video is diffrent than dumping a UMD game. To dump a UMD video, you must enter USB mode and dump it to the PC. When you have USB enabled for UMD drive, it will show up as UMD9660.iso, drag that to your PC and it will start dumping. Do you want to enable UMD USB mode now?",1) button = System.buttonPressed(1) if button == "yes" then System.usbDevUMD() end button = System.buttonPressed(1) if button == "no" then System.Quit() end done = true end if done == false then screen:print(1, 10, "Press O to dump UMD video", white) end if pad:square() and done == false then System.message("This will show the available amount of free space on your memory stick. Do you wish to continue?",1) button = System.buttonPressed(1) if button == "yes" then System.getDevSize("ms0:") end button = System.buttonPressed(1) if button == "no" then System.Quit() end done = true end if done == false then screen:print(1, 20, "Press [] to see free space on memory stick", white) end if pad:start() and done == false then System.message("WARNING! This will clock the Central Processing Unit to 20 MHz! Are you sure you want to proceed?",1) button = System.buttonPressed(1) if button == "yes" then System.setcpuspeed(20) end button = System.buttonPressed(1) if button == "no" then System.Quit() end done = true end if done == false then screen:print(1, 30, "Press Start to clock CPU to 20 MHz", white) end if pad:select() and done == false then System.message("This will clock the Central Processing Unit to 333 MHz, which is higher than default. Are you sure you want to proceed?",1) button = System.buttonPressed(1) if button == "yes" then System.setcpuspeed(333) end button = System.buttonPressed(1) if button == "no" then System.Quit() end done = true end if done == false then screen:print(1, 40, "Press Select to Clock CPU to 333 MHz", white) end if pad:l() and done == false then System.message("Are you sure you want to exit?",1) button = System.buttonPressed(1) if button == "yes" then System.Quit() end button = System.buttonPressed(1) if button == "no" then end done = true end if done == false then screen:print(1, 50, "Press L trigger To exit", white) end if pad:r() and done == false then System.message("You are about to shutdown the PSP. Do you want to proceed?",1) button = System.buttonPressed(1) if button == "yes" then System.shutdown() end button = System.buttonPressed(1) if button == "no" then end done = true end if done == false then screen:print(1, 60, "Press R to Shutdown The system", white) end screen.waitVblankStart() screen.flip() end
-
05-10-2008, 06:02 PM #8594QJ Gamer Platinum
- Registriert seit
- Dec 2005
- Ort
- h0000000rj
- Beiträge
- 12.867
- Points
- 57.528
- Level
- 100
- Downloads
- 0
- Uploads
- 0
I would think it's rather obvious.
The way you have it now, once you set 'done' to true, it never becomes false again, so it never accepts more input.
Try moving 'done = false' below 'while true do'.[I fail @ life]
-
05-10-2008, 06:37 PM #8595
i didnt know you knew lua freeplay, i thought you only did c++
Zitat von FreePlay
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]
-
05-10-2008, 06:47 PM #8596
- Registriert seit
- Mar 2008
- Beiträge
- 40
- Points
- 2.784
- Level
- 32
- Downloads
- 0
- Uploads
- 0
Thx freeplay, it now works!!!
Zitat von FreePlay
but I still have other problems...
this code is supposed to show how much space I have left on my memory stick:
but it doesnt show anything...Code:System.getDevSize("ms0:")
anyone know?
-
05-10-2008, 07:16 PM #8597QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
You dont have to "know" lua to look at and understand a script written in it - it looks like plain english to someone used to lowerlevel programming languages.
-
05-10-2008, 07:21 PM #8598
- Registriert seit
- Mar 2008
- Beiträge
- 40
- Points
- 2.784
- Level
- 32
- Downloads
- 0
- Uploads
- 0
look, i only just turned 13, i know ALOT about programming, except for LUA.
Zitat von TurtlesPwn
I can do LUA pretty well, but i always seem to get errors...
-
05-10-2008, 07:47 PM #8599
hi my psp screen shows up but the hud isn't working. if any one can help that would be great
-
05-10-2008, 08:25 PM #8600words 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
You're just proving Turtle's point even more by saying that... lol
Zitat von omegaridley
scryeth - that is so vague we can't even begin to help you without atleast some code.
...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
-
05-10-2008, 11:32 PM #8601
-
05-11-2008, 12:54 AM #8602Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
are you sure you posted on the right thread lol
-= Double Post =-
some pointers:
Zitat von omegaridley
1. use a menu
2. System.getDevSize() only returns the size, to show it e.g. System.message(System.get DevSize(),0)
3. that code is bad
4. i made one of these just to test all of the functions here is the code
Code:System.memclean() System.usbDiskModeActivate() white = Color.new(255, 255, 255) red = Color.new(255,0,0) green = Color.new(0,255,0) blue = Color.new(0,0,255) options = { "PSP Information", "Set Cpu Speed To 133", "Set Cpu Speed To 266", "Set Cpu Speed To 333", "Re-Load" } current = 1 function printg(x, y, text, colour, display) if colour == nil then colour = Color.new(255, 255, 255) end if display == nil then display = screen end for xbg = -1, 1 do for ybg = -1, 1 do display:print(x + xbg, y + ybg, text, Color.new(0, 0, 0)) end end display:print(x, y, text, colour) end function printgc(y, text, colour, display) if colour == nil then colour = Color.new(255, 255, 255) end if display == nil then display = screen end x = 240 - ((string.len(text) * 8) / 2) for xbg = -1, 1 do for ybg = -1, 1 do display:print(x + xbg, y + ybg, text, Color.new(0, 0, 0)) end end display:print(x, y, text, colour) end function Display_Menu() for i = 1, table.getn(options) do printgc(30 + ((i - 1) *10), options[i], white) end printgc(30 + ((current - 1) * 10), options[current], green) end if System.powerGetBatteryChargingStatus() == 1 then bat_stat = "Charging" else bat_stat = "In Use" end function Menu_Controls() if pad:up() and not oldpad:up() then if current > 1 then current = current - 1 else current = table.getn(options) end elseif pad:down() and not oldpad:down() then if current < table.getn(options) then current = current + 1 else current = 1 end end if pad:cross() and not oldpad:cross() and current == 1 then System.message("PSP Version: " .. System.cfwVersion() .. "\nNick Name: " .. System.nickName() .. "\nBattery Status: " .. bat_stat .. "\nBattery Percentage: " .. System.powerGetBatteryLifePercent() .. "%" .. "\nTime Left: " .. System.powerGetBatteryLifeTime() .. "\nLua Player HM: V" .. System.playerVer(), 0) elseif pad:cross() and not oldpad:cross() and current == 2 then System.setLow() elseif pad:cross() and not oldpad:cross() and current == 3 then System.setReg() elseif pad:cross() and not oldpad:cross() and current == 4 then System.setHigh() elseif pad:cross() and not oldpad:cross() and current == 5 then dofile("./function_dump.lua") end end oldpad = Controls.read() while true do pad = Controls.read() screen:clear(blue) -- insert your main code here printgc(10, "Lua Player HM Function Dump By [email protected]", green) Display_Menu() Menu_Controls() printgc(260, "Hi " .. System.nickName(), green) -- insert your main code here if pad:start() then break end oldpad = pad screen.waitVblankStart() screen.flip() endGeändert von FaT3oYCG (05-11-2008 um 01:05 AM Uhr) Grund: Automerged Doublepost
------ 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).
-
05-11-2008, 04:11 AM #8603
- Registriert seit
- Mar 2008
- Beiträge
- 40
- Points
- 2.784
- Level
- 32
- Downloads
- 0
- Uploads
- 0
thx [email protected], youve helped me yet again!
ur the best!!!
so now, what you told me should get the rest of my code to work.
this leaves me to 1 more question!
ok, on Ogg playback, the song I have only plays 1 time, How do I make it loop? here is the code I am using:
it works, the music plays, but it doesnt loop, so it only plays onceCode:Ogg.load("SYSTEM/music/system.ogg") Ogg.play
-
05-11-2008, 06:32 AM #8604Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
looking at the commands in luaplayer hm for ogg files i would say it is probably one of these
Code:Ogg.EndOfStream() Ogg.songTime() Ogg.mode()
------ 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).
-
05-11-2008, 01:15 PM #8605words 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, looking at the source Ogg.EndOfStream() returns a string "true" when an Ogg file has finished playing so just put in your main loop:
Code:if Ogg.EndOfStream() == "true" then Ogg.play() end

...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
-
05-11-2008, 02:59 PM #8606
- Registriert seit
- Mar 2008
- Beiträge
- 40
- Points
- 2.784
- Level
- 32
- Downloads
- 0
- Uploads
- 0
ok, i understand now, but after I put in that line of code, it game me this error:
Zitat von SG57
:16: attempt to call field 'EndOfStream' (a nil value)
here is line 16:
it wont work, and the functions.txt even shows the function!!!Code:if Ogg.EndOfStream() == "true" then
any ideas?
-
05-11-2008, 03:21 PM #8607QJ Gamer Blue
- Registriert seit
- Apr 2008
- Beiträge
- 497
- Points
- 4.268
- Level
- 41
- Downloads
- 0
- Uploads
- 0
did you acctually put code after
if Ogg.EndOfStream() == "true" then
??
or is that it?
cause if thats all you put, then you need to add
Ogg.play() end
-
05-11-2008, 03:40 PM #8608
- Registriert seit
- Mar 2008
- Beiträge
- 40
- Points
- 2.784
- Level
- 32
- Downloads
- 0
- Uploads
- 0
yes, i put code after
Zitat von PSProgramer
and it still isnt working...Code:if Ogg.EndOfStream() == "true" then
-
05-11-2008, 03:49 PM #8609words 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
Do you have an Ogg loaded? Looking at the source code of LP, the eof integer is initialized to 0 when an Ogg is loaded so trying to access it before an Ogg is loaded will return nil..

...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
-
05-11-2008, 04:02 PM #8610
- Registriert seit
- Mar 2008
- Beiträge
- 40
- Points
- 2.784
- Level
- 32
- Downloads
- 0
- Uploads
- 0
so ur saying to load the Ogg AFTER this code is executed?:
Zitat von SG57
cause, i can easily move the loading code below itCode:if Ogg.EndOfStream() == "true" then
-= Double Post =-
no that didnt work either, i dont understand, is it a bug
Zitat von omegaridley
i am using LuaPlayerHM v6.6, and the code u have me is in the functions list!Geändert von omegaridley (05-11-2008 um 04:23 PM Uhr) Grund: Automerged Doublepost


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