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; Obsessive Compulsive Disorder. Like a guy who has to snap his fingers 5 times before opening a door or washing ...
-
05-01-2007, 06:57 PM #7171Developer

- Registriert seit
- Oct 2006
- Ort
- San Diego
- Beiträge
- 177
- Points
- 4.205
- Level
- 41
- Downloads
- 0
- Uploads
- 0
Obsessive Compulsive Disorder. Like a guy who has to snap his fingers 5 times before opening a door or washing his hands every 5.2 minutes on the dot. That kind of thing.
-
05-01-2007, 07:22 PM #7172QJ Gamer Green
- Registriert seit
- Dec 2006
- Ort
- main();
- Beiträge
- 1.071
- Points
- 11.300
- Level
- 70
- Downloads
- 0
- Uploads
- 0
I'm OCD. More on the line of washing my hands than the snapping my fingers...
-
05-01-2007, 07:36 PM #7173QJ Gamer Gold
- Registriert seit
- Nov 2006
- Ort
- ...
- Beiträge
- 2.080
- Points
- 11.942
- Level
- 71
- Downloads
- 0
- Uploads
- 0
i'm just stoopid
-
05-02-2007, 11:41 AM #7174
hii there. i have got somthing strange 2 time by now.... i mean.. i was making some code. testing then turnoff psp, and when i back, the code no longer works.... wy ?... luaplayer corrupt files when turn off playing ?.... how to correct my damaged codes?..
-
05-02-2007, 12:00 PM #7175QJ Gamer Gold
- Registriert seit
- Aug 2006
- Ort
- Under Your Bed
- Beiträge
- 3.083
- Points
- 12.189
- Level
- 72
- Downloads
- 0
- Uploads
- 0
i dont think there is a way to fix "currupted files" you could try deleting them then replacing them. i had a simular problem like this but once i did that it all worked
-
05-02-2007, 12:16 PM #7176QJ Gamer Green
- Registriert seit
- Jan 2007
- Ort
- beside my PC
- Beiträge
- 520
- Points
- 6.446
- Level
- 52
- Downloads
- 0
- Uploads
- 0
u mean everytime we turn off while using it then it corupts?..
-
05-02-2007, 12:20 PM #7177QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
i think it can corrupt if u have usb enabled or something like that
[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]
-
05-02-2007, 12:28 PM #7178QJ Gamer Gold
- Registriert seit
- Aug 2006
- Ort
- Under Your Bed
- Beiträge
- 3.083
- Points
- 12.189
- Level
- 72
- Downloads
- 0
- Uploads
- 0
yeah if you using a certain file at the time and you overwrite it then the file become currupt and windows will not let you delete it so you have to delete it with something like IRSHELL
-
05-02-2007, 01:50 PM #7179
well i can see the content of the files, my images are visible.. jsut causes he wont, my code crash and reset the psp. but i turned it off working... and i wass on street so no usb...
-
05-02-2007, 03:11 PM #7180QJ Gamer Green
- Registriert seit
- Jan 2007
- Ort
- beside my PC
- Beiträge
- 520
- Points
- 6.446
- Level
- 52
- Downloads
- 0
- Uploads
- 0
how can i make my screenshots in different names eg screenshot1,screenshot2,a nd so on..
and also how browse a file then copy it to another location when pressed?
-
05-02-2007, 04:51 PM #7181QJ Gamer Gold
- Registriert seit
- Aug 2006
- Ort
- Under Your Bed
- Beiträge
- 3.083
- Points
- 12.189
- Level
- 72
- Downloads
- 0
- Uploads
- 0
For the screenshot thing yeah you can heres a code from soulkiller
Zitat von ai3gtmc
And the filebrowser just use something like this that tactical penguin made up but edit it so that is moves the file to where you want. Try using SG57's Luaplayer mod w/ flash but instead dont flash it to flash0:/ but to wherever it is you want it to.Code:SUBMITTED BY: Soulkiller oldpad = Controls.read() while true do pad=Controls.read() if pad:select() and pad:select() ~= oldpad:select() then screenshot("ms0:/PSP/PHOTO") end oldpad = pad end Code: function screenshot(folder) local directory = {} local counter = 1 for index, file in System.listDirectory(folder) do directory[counter] = file.name counter = counter+1 end local max = 0 for length = 1,table.getn(directory) do for length2 = 1,table.getn(directory) do if directory[length2] == "screenshot"..length..".png" then max = length end end end max = max+1 screen:save(folder.."screenshot"..max..".png") end
Code:System.currentDirectory("ms0:/") white = Color.new(255,255,255) red = Color.new(255,0,0) fbrowser = {s = 1, fl = System.listDirectory("ms0:/"),ls = 1, sp = 10} fbrowser.nf = table.getn(fbrowser.fl) oldpad = Controls.read() function runfbrowser() for i = ((fbrowser.ls-1)*fbrowser.sp)+1, fbrowser.ls*fbrowser.sp do if fbrowser.nf >= i then screen:print(0,((i-((fbrowser.ls-1)*fbrowser.sp))*10)-10,fbrowser.fl[i].name,white) elseif fbrowser.nf < i then break end end screen:print(0,((fbrowser.s-((fbrowser.ls-1)*fbrowser.sp))*10)-10,fbrowser.fl[fbrowser.s].name,red) if pad:down() and not oldpad:down() then fbrowser.s = fbrowser.s + 1 end if pad:up() and not oldpad:up() then fbrowser.s = fbrowser.s - 1 end if fbrowser.s > fbrowser.nf then fbrowser.s = fbrowser.nf elseif fbrowser.s < 1 then fbrowser.s = 1 end if fbrowser.s > fbrowser.sp*fbrowser.ls then fbrowser.ls = fbrowser.ls + 1 elseif fbrowser.s < ((fbrowser.ls-1) * fbrowser.sp)+1 then fbrowser.ls = fbrowser.ls - 1 fbrowser.s = (fbrowser.ls)*fbrowser.sp end if pad:cross() and not oldpad:cross() then if not fbrowser.fl[fbrowser.s].directory then if string.lower(string.sub(fbrowser.fl[fbrowser.s].name, -4)) == (".png" or ".jpg") then img = Image.load(fbrowser.fl[fbrowser.s].name) screen:clear() screen:blit(240-img:width()/2,136-img:height()/2,img) screen.flip() viewingimg = true while viewingimg do if Controls.read():circle() then viewingimg = false img = nil end screen.waitVblankStart() end end elseif fbrowser.fl[fbrowser.s].directory then System.currentDirectory(fbrowser.fl[fbrowser.s].name) fbrowser.s = 1 fbrowser.fl=System.listDirectory() fbrowser.nf=table.getn(fbrowser.fl) fbrowser.ls = 1 end elseif pad:triangle() and not oldpad:triangle() then if System.currentDirectory ~= "ms0:/" then System.currentDirectory("./..") fbrowser.s = 1 fbrowser.fl=System.listDirectory() fbrowser.nf=table.getn(fbrowser.fl) fbrowser.ls = 1 end end end while true do pad = Controls.read() screen:clear() runfbrowser() screen.waitVblankStart() screen.flip() oldpad = pad if pad:start() then break end end
-
05-02-2007, 04:52 PM #7182words 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
ai -
Whether or not the screen shot function is screen:save is beyond me, so go find it. Also, this will overwrite old screenshots if you restart the app, as g_Screenshot = 0 again. You could use the method above me to get the last screenshot number and assign it to g_Screenshot.Code:g_Screenshot = 0 oldpad = Controls.read() while true do pad = Controls.read() if pad:select() and pad ~= oldpad then g_Screenshot = g_Screenshot + 1 screen:save( "ms0:/PSP/PHOTO/yourGame/screenshot" .. g_Screenshot .. ".png" ) end oladpad = pad end
As for your other question, NO! I will not write a file browser for you and have it copy whatever file pressed to another place. You are so specific I can already tell you're creating a flashing app... You know no one will do what you ask, at least want to... , if they can determine what you're making completely... xpack shouldnt have given you it either, but still...
I advise you to read up on the System.listCurrentDirecto ry function (i believe thats what it's called) and learn to do it yourself to take all the credit...
...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-02-2007, 05:11 PM #7183
I have a question guys. Ok i have collision code but when they collide it just restarts. I want it so that it destroys the object. Removes it from the screen. Can someone tell me how to do this.
Thanks Bob Hoil
-
05-02-2007, 05:14 PM #7184QJ Gamer Gold
- Registriert seit
- Aug 2006
- Ort
- Under Your Bed
- Beiträge
- 3.083
- Points
- 12.189
- Level
- 72
- Downloads
- 0
- Uploads
- 0
Post your code so that we can see whats wrong with it
-
05-02-2007, 05:23 PM #7185QJ Gamer Green
- Registriert seit
- Jan 2007
- Ort
- beside my PC
- Beiträge
- 520
- Points
- 6.446
- Level
- 52
- Downloads
- 0
- Uploads
- 0
ok thx guys:)
Sg57: yeah i did.. its already released.. but my psp's LCD is broken for 1month or so... so i forgot a lil about LUA..
that's why im remaking it:) lol
another question:
if i flash a file but the file im trying to flash is not there, how can i make a warning that the file is not there? so i wont get error
-
05-02-2007, 05:28 PM #7186QJ Gamer Gold
- Registriert seit
- Aug 2006
- Ort
- Under Your Bed
- Beiträge
- 3.083
- Points
- 12.189
- Level
- 72
- Downloads
- 0
- Uploads
- 0
Huh mine too :Argh:
Zitat von ai3gtmc
-
05-02-2007, 05:33 PM #7187QJ Gamer Green
- Registriert seit
- Jan 2007
- Ort
- beside my PC
- Beiträge
- 520
- Points
- 6.446
- Level
- 52
- Downloads
- 0
- Uploads
- 0
so how do i do it xpack?
-
05-02-2007, 05:37 PM #7188QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
blah = io.open(filetocheck,"r")
if blah then
fileexists = true
blah:close()
end
-
05-02-2007, 05:37 PM #7189QJ Gamer Gold
- Registriert seit
- Aug 2006
- Ort
- Under Your Bed
- Beiträge
- 3.083
- Points
- 12.189
- Level
- 72
- Downloads
- 0
- Uploads
- 0
i think its something like
at least i think thats how it works (this was just off the top of my head)...Code:if "ms0:/PSP/GAME/Whatever/whatever.rco" then -- your code here else screen:print(10,10,"File Not Found",color) end
Oh or try tp's way that sound like it might work, i was typing when it was posted
-
05-02-2007, 05:44 PM #7190QJ Gamer Green
- Registriert seit
- Jan 2007
- Ort
- beside my PC
- Beiträge
- 520
- Points
- 6.446
- Level
- 52
- Downloads
- 0
- Uploads
- 0
ok thx to you guys:) ill try it later.. im at school >.< lol
-
05-02-2007, 07:27 PM #7191
Hey guys i am having some problems with my code. On startup i encounter the following error that i cannot figure out how to fix: Error: main.lua:54: attempt to index global 'button' (a function value)Code:background=Image.load("images/menu.png") fb=Image.load("images/fb.png") fbclicked=Image.load("images/fbclicked.png") apps=Image.load("images/apps.png") appsclicked=Image.load("images/appsclicked.png") wb=Image.load("images/wb.png") wbclicked=Image.load("images/wbclicked.png") games=Image.load("images/games.png") gamesclicked=Image.load("images/gamesclicked.png") mp=Image.load("images/mp.png") mpclicked=Image.load("images/mpclicked.png") white=Color.new(255,250,250) cursor = Image.load("images/cursor.png") sensitivity = 40 maxspeed = 3 cursor = {x = 30, y = 100, w = 32, h = 32, oldx = 200, oldy = 50, img = Image.load("images/cursor.png"), s = 4} buttonimg = Image.load("images/fb.png") button={} button[1] = {x = 21, y = 234, h = buttonimg:height(), w = buttonimg:width()} function moveCursor() pad=Controls.read() if pad:analogX() < -sensitivity or pad:analogX() > sensitivity then cursor.x = cursor.x + pad:analogX()/(128/maxspeed) end if pad:analogY() < -sensitivity or pad:analogY() > sensitivity then cursor.y = cursor.y + pad:analogY()/(128/maxspeed) end end 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 screen:print(325, 26,hour..":" ..min .. " "..ampm, white) end function collision(cursor,button1) return (cursor.x + cursor.w > button[1].x) and (cursor.x < button[1].x + button[1].w) and (cursor.y + cursor.h > button[1].y) and (cursor.y < button[1].y + button[1].h) end function button() if pad:cross() and collision(cursor,button1) then dofile("fb.lua") end end function screenPrint() screen:blit(0,0,background) screen:blit(21,234,fb) screen:blit(113,234,mp) screen:blit(210,234,apps) screen:blit(305,234,games) screen:blit(399,234,wb) screen:blit(cursor.x,cursor.y,cursor.img) screen:print(424,26, System.powerGetBatteryLifePercent(),white) end while true do screen:clear() collision(cursor,button1) moveCursor() button() screenPrint() clock() screen.waitVblankStart() screen.flip() end
It is probably something stupid that i just overlooked but thanks for any help anyone gives.
-
05-02-2007, 07:41 PM #7192QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
You made button a table and then made it a function. Need to change the names.
-
05-02-2007, 07:45 PM #7193
Thanks i knew it was something stupid i just noticed that.
-
05-02-2007, 07:46 PM #7194Asleep...

- Registriert seit
- Oct 2005
- Beiträge
- 1.383
- Points
- 11.516
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Is there a way to check a line of text for a specific phrase, and replace it? or a way without replacing? for example:
i load a text file, and read a line off it, and if i see the word "lol" in that line, then replace it with the word omg
just an example^^
-
05-02-2007, 07:47 PM #7195
Awesome it works!!! Thanks a lot to everyone. Now i just need to make the other screens.
-
05-02-2007, 08:13 PM #7196QJ Gamer Gold
- Registriert seit
- Nov 2006
- Ort
- ...
- Beiträge
- 2.080
- Points
- 11.942
- Level
- 71
- Downloads
- 0
- Uploads
- 0
your welcome dude
-
05-02-2007, 08:23 PM #7197
I ma having problems with returning to the previous screen. Is there a way to load the last file info out of ram then use that to load the file?
-
05-02-2007, 08:24 PM #7198Asleep...

- Registriert seit
- Oct 2005
- Beiträge
- 1.383
- Points
- 11.516
- Level
- 70
- Downloads
- 0
- Uploads
- 0
can anyone help with my problem above? also, i searched on google and found a few functions like
string.find, string.sub, and string.gsub... what do these do? thanks for any help
-
05-02-2007, 08:28 PM #7199lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
Doesnt anyone go to lua.org anymore?
Zitat von gmansexfo
http://www.lua.org/manual/5.1/manual.html#5.4
-
05-02-2007, 11:52 PM #7200words 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
Yeah, people do. Stupid question on your part...
Bob Hoil - What? Load the last info out of ram and use it to load the file... wtf... Try syllables and sentences and you may get your answer ;)
...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


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