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 sony psp player Code: if pad:start() then oldpad = pad while true do pad = Controls.read() if pad:start() ...
-
08-29-2007, 10:35 AM #7981Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
thats lovely thank you.
Zitat von sony psp player
-
08-29-2007, 11:57 AM #7982
I'd rather do it like this:
Zitat von eldiablov
That way you don't need to check with the IF every timeCode:while not Controls.read():start() do screen:flip() screen.waitVblankStart() end
Cheers
-
08-30-2007, 02:48 AM #7983Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
sony_psp_player the pausing function works fine but it wont unpause

oh wait ill try placos way
-= Double Post =-
ok the pause function is working but how would i release a script from the memory ?Geändert von eldiablov (08-30-2007 um 05:13 AM Uhr) Grund: Automerged Doublepost
-
08-30-2007, 12:38 PM #7984Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
that wont work. you used a while loop, so he'll have to press start to update each frame. use an if statement instead:
Zitat von placo23
or better yet, make a state system.Code:if not pad:start() then screen:flip() screen.waitVblankStart() end
--------------------------------------------------------------------------------------
-
08-30-2007, 11:15 PM #7985
Course it works. I use it all the time. Anyways.. that's just another way to do it.
Zitat von Grimfate126
Cheers
-
09-05-2007, 10:58 AM #7986Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
HHHHHHEEEEELLLPPPPPPPP
ok im no noob to lua but i cant get the keyboard intergration to work properly it chucks out an error every time i try to run it and i have just used sg57's example
here is the code
it is slightly modded but not so that it wouldnt work
any ideas maybee the example has an old function or something anyway
thanks in advance if you can helpCode:White = Color.new(255, 255, 255) Controls.IRkeyboardInit() string = "" shift = 0 oldpad = Controls.read() while true do pad = Controls.read() screen:clear() string = string .. Controls.IRKeyboardGetKey(shift) screen:print(10, 10, string, White) if Controls.read():start() then break end screen.waitVblankStart() screen.flip() 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).
-
09-06-2007, 02:06 PM #7987QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 550
- Points
- 5.381
- Level
- 47
- Downloads
- 1
- Uploads
- 0
I have no experience with IR keyboards, but wouldn't Controls.IRKeyboardGetKey (shift) be a boolean(true or false) value?
-
09-06-2007, 04:17 PM #7988QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
i'm guessing so Nielkie, seems logical
but i dont know reallyif pad:start() then
end
if Controls.IRKeyboardGetKey (shift) then
end
-
09-07-2007, 08:59 AM #7989
please help
i need delete folder with some files but
dont workCode:System.removeDirectory("ms0:/tmp")
or delete all files from this folder - something like this:
Code:System.removeFile("ms0:/tmp/*.*")
-
09-07-2007, 10:17 AM #7990Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
this would take quite a while to code something that operates in this way and would involve useing lots more cod than you are useing your best bet is to name each file that you want deleted r wait for about a month while i code it for you
Zitat von lps
------ 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).
-
09-07-2007, 04:46 PM #7991QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 550
- Points
- 5.381
- Level
- 47
- Downloads
- 1
- Uploads
- 0
Or something like this:
Zitat von FaT3oYCG
Code:local files = System.listDirectory("ms0:/tmp") for i = 3, table.getn(files) do -- 3 to avoid "." and ".." System.removeFile("ms0:/tmp/" .. files[i].name) end System.removeDirectory("ms0:/tmp")Geändert von Nielkie (09-11-2007 um 11:54 PM Uhr)
-
09-08-2007, 08:30 AM #7992lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
Zitat von FaT3oYCG
I lol'd.
Zitat von Nielkie
-
09-11-2007, 01:29 AM #7993
That was quick mate :ROFL:
-
09-11-2007, 12:29 PM #7994QJ Gamer Blue
- Registriert seit
- Jul 2007
- Beiträge
- 296
- Points
- 3.795
- Level
- 38
- Downloads
- 0
- Uploads
- 0
Er, '.' and '..' come first, so doing that would just skip the last two files in the directory instead of not including '.' and '..', no?
Zitat von Nielkie
-
09-11-2007, 03:21 PM #7995
i was just writing up a thing about how you are wrong when i realized you were right lol.
the correct loop would read:
the - 2 you had subtracts two from the loops limit, not from how many times the loop loops.Code:for i = 3, table.getn(files)
nice catch dysfunctional
-
09-11-2007, 03:40 PM #7996QJ Gamer Blue
- Registriert seit
- Jul 2007
- Beiträge
- 296
- Points
- 3.795
- Level
- 38
- Downloads
- 0
- Uploads
- 0
Actually, I lied, his loop started at 3. His is correct.
-
09-11-2007, 05:05 PM #7997
yea but you still wouldn't need that -2 in there would you?
-
09-11-2007, 05:18 PM #7998QJ Gamer Blue
- Registriert seit
- Jul 2007
- Beiträge
- 296
- Points
- 3.795
- Level
- 38
- Downloads
- 0
- Uploads
- 0
Yeah, you would, because if you didn't have it you would be going two items past the end of the array.
-
09-11-2007, 09:57 PM #7999Developer

- Registriert seit
- Oct 2006
- Ort
- San Diego
- Beiträge
- 177
- Points
- 4.205
- Level
- 41
- Downloads
- 0
- Uploads
- 0
Incorrect, table.getn will give you the max array index, so by subtracting 2, you are not removing the last 2 files. by starting at 3 you are skipping the first 2 items and you want it to run to the last index of the array.
Zitat von _dysfunctional
-
09-11-2007, 11:53 PM #8000QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 550
- Points
- 5.381
- Level
- 47
- Downloads
- 1
- Uploads
- 0
Oh, I see. I thought something looked wrong.
P.S. #8000!Geändert von Nielkie (09-13-2007 um 01:07 AM Uhr)
-
09-12-2007, 03:52 PM #8001QJ Gamer Blue
- Registriert seit
- Jul 2007
- Beiträge
- 296
- Points
- 3.795
- Level
- 38
- Downloads
- 0
- Uploads
- 0
Yeah, I've got you now. I misunderstood how lua for loops worked. Sorry about that.
-
09-16-2007, 06:01 AM #8002QJ Gamer Blue
- Registriert seit
- Jan 2007
- Ort
- Sweden
- Beiträge
- 98
- Points
- 3.902
- Level
- 39
- Downloads
- 0
- Uploads
- 0
How do i make so the program will open 1 random .pmf file with any name in a specific folder, ms0:/GAMEBOOTS/ and then flash it?
Code:function flashFiles() -- Set Path gameboot = "ms0:/GAMEBOOTS/file_1.pmf" -- Start flashing file = io.open(gameboot, "r") if file then System.writeFile(gameboot,"flash0:/vsh/resource/gameboot.pmf","no") file:close() end end
-
09-16-2007, 08:06 AM #8003QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
i think this should work.. not tested...Code:System.currentDirectory("ms0:/GAMEBOOTS") files = System.listDirectory() randomNum = math.random(3,table.getn(files)) gameboot = files[randomNum].name file = io.open(files[randomNum].name, "r") if file then file:close() System.writeFile(gameboot,"flash0:/vsh/resource/gameboot.pmf","no") end[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]
-
09-16-2007, 09:37 AM #8004PREMIUM Member
- Registriert seit
- Oct 2005
- Beiträge
- 29
- Points
- 4.816
- Level
- 44
- Downloads
- 0
- Uploads
- 0
Hi guys, I'm using the Luaplayer 0.16 for 1.50, which Noobz recommended for eLoader on the Slim PSP. So I copied the Application and System directories with the EBOOT, but I keep getting this:
Error: No script file found
Press start to restart
The system.lua file is pointing to the right files and directories (Lowser), so I don't know why it's complaining.
It works fine on the Phat PSP, however. Everything's under PSP/GAME.
-
09-16-2007, 09:43 AM #8005QJ Gamer Blue
- Registriert seit
- Jan 2007
- Ort
- Sweden
- Beiträge
- 98
- Points
- 3.902
- Level
- 39
- Downloads
- 0
- Uploads
- 0
It works the first time i run the program but after that it flashes the exact same file :S
Zitat von myschoo
-
09-16-2007, 10:49 AM #8006QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
i forgot
so the code should be like this:Code:math.randomseed(os.time())
Code:math.randomseed(os.time()) System.currentDirectory("ms0:/GAMEBOOTS") files = System.listDirectory() randomNum = math.random(3,table.getn(files)) gameboot = files[randomNum].name file = io.open(files[randomNum].name, "r") if file then file:close() System.writeFile(gameboot,"flash0:/vsh/resource/gameboot.pmf","no") end[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]
-
09-16-2007, 12:45 PM #8007QJ Gamer Blue
- Registriert seit
- Jan 2007
- Ort
- Sweden
- Beiträge
- 98
- Points
- 3.902
- Level
- 39
- Downloads
- 0
- Uploads
- 0
yey it worked. thank youu :humped:
-
09-17-2007, 09:24 AM #8008No longer a community member.
- Registriert seit
- Jun 2006
- Ort
- Nederland
- Beiträge
- 3
- Points
- 17.748
- Level
- 84
- Downloads
- 0
- Uploads
- 0
Could anyone tell me how to print the OS time with a custom TTF font?
I have this now:
Code:background = Image.load("background.png") title_bar = Image.load("bar_title.png") bar_select = Image.load("bar_select.png") while true do screen:blit(0,0,background) screen:blit(0,0,title_bar) screen:blit(0,35,bar_select) font_title = Font.load("font.ttf") font_title:setPixelSizes(0,18) font_top = Font.load("font.ttf") font_top:setPixelSizes(0,24) white = Color.new(255, 255, 255) black = Color.new(0, 0, 0) function clock() time = os.time() timestring = os.date("%c",time) timeinfo = os.date("*t", time) hour = timeinfo.hour if hour > 11 then ampm = "PM" elseif hour < 12 then ampm = "AM" end min = timeinfo.min if min < 10 then min = "0" .. min end hour = timeinfo.hour if hour > 12 then hour = hour - 12 end end screen:fontPrint(font_top,210,25,"I want the OS time here",black) screen:fontPrint(font_title,5,55,"Test.mp3",white) screen.waitVblankStart() screen.flip() end
-
09-17-2007, 01:42 PM #8009
i don't think you can run 1.50 homebrew on a slim. try the 1.00 Eboot version maybe.
Zitat von dsi
-
09-17-2007, 01:55 PM #8010Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Zitat von Savagefreak
i think you would have to define the hours mins and secs as a variablr each and do something like this
try thisCode:hour = whatever your code needs to be min = whatever your code needs to be screen:fontPrint(font_top,210,25,"hour:min",black)
Code:background = Image.load("background.png") title_bar = Image.load("bar_title.png") bar_select = Image.load("bar_select.png") while true do screen:blit(0,0,background) screen:blit(0,0,title_bar) screen:blit(0,35,bar_select) font_title = Font.load("font.ttf") font_title:setPixelSizes(0,18) font_top = Font.load("font.ttf") font_top:setPixelSizes(0,24) white = Color.new(255, 255, 255) black = Color.new(0, 0, 0) function clock() time = os.time() timestring = os.date("%c",time) timeinfo = os.date("*t", time) hour = timeinfo.hour if hour > 11 then ampm = "PM" elseif hour < 12 then ampm = "AM" if hour > 12 then hour = hour - 12 end end min = timeinfo.min if min < 10 then min = "0" .. min end end screen:fontPrint(font_top,210,25,"hour:min",black) screen:fontPrint(font_title,5,55,"Test.mp3",white) screen.waitVblankStart() screen.flip() 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).


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