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; Ok, I guess i might have to test it out to see if i can notice a difference....
-
02-01-2007, 04:13 PM #5491lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
Ok, I guess i might have to test it out to see if i can notice a difference.
-
02-01-2007, 04:55 PM #5492Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von SG57
that would just overwrite the first definition. not sure if thats what you wanted though.--------------------------------------------------------------------------------------
-
02-01-2007, 05:45 PM #5493words 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
Gah - you guys are idiots... That snippet was for TP, he said nil frees an image, true, but i said reload, meaning just overwrite it with another image's data as ive done in the snippet. AS for loading from memory, there wont be any noticeable difference, since your still loading an image off the memory stick into RAM, than into an image class if you wish... To be honest, take snakesp that comes with luaplayer, change all image loading routines with a load from memory routine, and see if there is a difference.

...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
-
02-02-2007, 01:06 AM #5494QJ 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
I got a question!
Im editing TP's browser snippet, and I want to make it so that if you click on a directory with an "index.lua" OR "index.LUA" in it, it runs that file.
this is what i have so far.....
first off,Code:if pad:cross() and bfold == true and fl[s].directory == true then System.currentDirectory("./APPS/"..fl[s].name) dofile("index.LUA") System.currentDirectory("./../..") end
fl=System.listDirectory()
and
fl[s].name = the file/directory that you are curretly on
and
nf=table.getn(fl)
I hope that helps, Thanks in advanceNEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
02-02-2007, 10:53 AM #5495QJ Gamer Silver
- Registriert seit
- Oct 2006
- Ort
- 貴方
- Beiträge
- 1.159
- Points
- 7.371
- Level
- 57
- Downloads
- 0
- Uploads
- 0
now i got a new question
with this bullet fireing method
then the collision
Zitat von code
it says
Zitat von collision code
error
attempt to index feild '?' (a nil value)
for the bolded line
what is the y coordinant of the bullet???Geändert von HeaD_ShOt (02-02-2007 um 12:58 PM Uhr)
-
02-02-2007, 01:47 PM #5496QJ Gamer Gold
- Registriert seit
- Nov 2006
- Ort
- ...
- Beiträge
- 2.080
- Points
- 11.942
- Level
- 71
- Downloads
- 0
- Uploads
- 0
I get a bad blit error on line 123, and I need help fixing it
thanks in advance
Code:dofile("animLib.lua") white=Color.new(255,255,255) Background=Image.load("training.png") spritesheet=Image.load("naruto8ad.png") spritesheet1=Image.load("naruto8ad1.png") Punch1=Image.load("punchrt1.png") Punch2=Image.load("punchrt2.png") Punch3=Image.load("punchrt3.png") Sasuke=Image.load("sasukeleft.png") r1=Image.createEmpty(30,38) r2=Image.createEmpty(30,38) r3=Image.createEmpty(30,38) r4=Image.createEmpty(30,38) l1=Image.createEmpty(30,38) l2=Image.createEmpty(30,38) l3=Image.createEmpty(30,38) l4=Image.createEmpty(30,38) l1:blit(0,0,spritesheet1,430,103,30,38) l2:blit(0,0,spritesheet1,432,155,30,38) l3:blit(0,0,spritesheet1,399,155,30,38) l4:blit(0,0,spritesheet1,366,155,30,38) r1:blit(0,0,spritesheet,52,104,30,38) r2:blit(0,0,spritesheet,49,155,30,38) r3:blit(0,0,spritesheet,83,155,30,38) r4:blit(0,0,spritesheet,116,155,30,38) r={r1,r2,r3,r4} l={l1,l2,l3,l4} rt={rt1,rt2,rt3} Player={x=0,y=200,w=30,h=38,d=r,s=1,animt=0,img=r1,oldimg=l1,} Sasuke={x=400,y=200,w=32,h=38,img=Sasuke} PlayerHeight=38 PlayerWidth=32 function collision(ob1,ob2) if (ob1.x + ob1.w > ob2.x) and (ob1.x < ob2.x + ob2.w) then ob1.x=ob1.img end end function anim(ob) ob.animt = ob.animt + 1 if ob.animt > 30 then ob.animt = 1 end if ob.animt < 6 then ob.img = ob.d[1] end if ob.animt > 5 then ob.img = ob.d[2] end if ob.animt > 10 then ob.img = ob.d[3] end if ob.animt > 15 then ob.img = ob.d[4] end end function movePlayer() pad=Controls.read() if pad:right() then Player.d=r anim(Player) Player.x=Player.x+Player.s else Player.img=Player.d[1] end if pad:left() then Player.d=l anim(Player) Player.x=Player.x-Player.s end if pad:cross() then Player.oldimg = Player.img if Player.d == r then Player.img=block elseif Player.d == l then Player.img = block1 end defending=true end if defending and not pad:cross() then defending=false Player.img=Player.oldimg end if pad:down() then Player.oldimg = Player.img if Player.d == r then Player.img=crouch elseif Player.d == l then Player.img=crouch1 end crouching=true end if crouching and not pad:down() then crouching=false Player.img=Player.oldimg end end oldpad=Controls.read() block1=Image.load("block1.png") block=Image.load("block.png") crouch=Image.load("crouch.png") crouch1=Image.load("crouch1.png") crouching=false defending=false punching=false while true do movePlayer() --check collision for Sasuke if collision(Player,Sasuke) then Sasuke.img=Sasuke.img screen:print(100,100,"It works",white) end --paste player to screen screen:blit(0,0,Background,true) screen:blit(Player.x,Player.y,Player.img) screen:blit(400,200,Sasuke.img) screen.flip() screen.waitVblankStart() oldpad=pad end
-
02-02-2007, 03:04 PM #5497QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Hey blackshark, add me on MSN or AIM and I can help you with whatever you're trying to do with my filebrowser snippet.
Also, SG, you said REload. But when you UNload an image (making it need REloading) it has been set to nil and dropped from ram. I know that you can change an images value and stuff, your interpretation of reload was just different from mine.
Also [email protected] bullet snippet. You want a real bullet system to use?
Also kinghiei, here's your problem:
You're defining Sasuke = Image.load("sasukeleft.pn g")
And then redefining it as a table with its original value inside:
Sasuke = {blahblah,img = Sasuke}
Either change the name of the imageload or the table. You cant use the image of Sasuke any more since you redefined Sasuke as a table.
E.G. Sasukeimg = Image.load("sasukeleft.pn g")
Sasuke = {blahblah,img = Sasukeimg}
-
02-02-2007, 03:25 PM #5498QJ Gamer Gold
- Registriert seit
- Nov 2006
- Ort
- ...
- Beiträge
- 2.080
- Points
- 11.942
- Level
- 71
- Downloads
- 0
- Uploads
- 0
I still got the bad blit error
-
02-02-2007, 04:12 PM #5499QJ Gamer Silver
- Registriert seit
- Oct 2006
- Ort
- 貴方
- Beiträge
- 1.159
- Points
- 7.371
- Level
- 57
- Downloads
- 0
- Uploads
- 0
yes,
Zitat von TaticalPenguin
i want a real bullet system
-
02-02-2007, 05:31 PM #5500
kinghiei, your missing the clip part of the blit function:
screen:blit(0, 0, Background, 0, 0, Background.width(), Background.height(), true)
-
02-02-2007, 06:05 PM #5501words 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
A 'real' bullet system is game specific.

...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
-
02-02-2007, 06:22 PM #5502QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Yea, it usually is, but if the evilmana one will do what he needs so will the one I sent him.
-
02-02-2007, 06:54 PM #5503QJ 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
I do not have either,
Zitat von TacticalPinguin
sorry.
NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
02-02-2007, 07:04 PM #5504
can i ask everyone what they think of this:
http://www.sendspace.com/file/e44t0q
its a game i just started, just tried to add a walking animation witch didn't work as well as i had hoped so its kind of low on fps and moving looks lame IMO.
-
02-02-2007, 07:44 PM #5505QJ Gamer Silver
- Registriert seit
- Oct 2006
- Ort
- 貴方
- Beiträge
- 1.159
- Points
- 7.371
- Level
- 57
- Downloads
- 0
- Uploads
- 0
i tried using os.exit() to exit to the xmb
but all it does is cause a freeze...
-
02-02-2007, 07:51 PM #5506words 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
eyece - Check out my game, Be Thou' for the People - it is a FMA Beat em up and has all animations in, except alchemic animations.
http://JordanSg57.googlepages.com/Be...rThePeople.rar
WAlking animation, kicking animation, jumping animation, and enemies.
Maybe take a look? Or if you really want tohelp me, do the enemies AI ;) Ive done everything except that, and thats the only thing stopping me from completeing hte game.
...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
-
02-02-2007, 08:06 PM #5507
its pretty cool. i'm not sure what moving the legs actually does, but I think it's a good idea to actually use physics concepts in a game like you do.
Zitat von eyece
good luck with it.
-
02-03-2007, 06:46 AM #5508QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
use System.Quit()
Zitat von HeaD_ShOt
but u must have cools Luaplayer mod
-= Double Post =-
can anyone explain why this:
doesnt work....Code:print("about " .. System.getFreeMemory() / 1024 / 1024 .. " megabytes free memory available")
but when i use this:
then it works ok... o_OCode:System.getFreeMemory() / 1024 / 1024 * 16,37152777777777778
Geändert von myschoo (02-03-2007 um 06:49 AM Uhr) Grund: Automerged Doublepost
[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]
-
02-03-2007, 06:51 AM #5509QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Try something like:
memfree = System.getFreeMemory()/1024/1024
print("About "..math.floor(memfree+0.5 ).." megabytes of free memory")
The math.floor(memfree+0.5) part rounds it to the nearest number. It's about, not exactly.
-
02-03-2007, 09:24 AM #5510
did that person ever change their name so you could be penguin again?
-
02-03-2007, 04:50 PM #5511QJ Gamer Silver
- Registriert seit
- Oct 2006
- Ort
- 貴方
- Beiträge
- 1.159
- Points
- 7.371
- Level
- 57
- Downloads
- 0
- Uploads
- 0
i have a question
is there any way to have mutiple locations of x
like enemy.x = enemy.x and everything between enemy.x + 15
?
-
02-03-2007, 05:06 PM #5512QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
um..no.
Zitat von HeaD_ShOt
but you could use tables instead.
Code:enemy[1].x = enemy[2].x or enemy.1.x = enemy.2.x (tables inside tables lol)
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
02-03-2007, 06:07 PM #5513QJ Gamer Silver
- Registriert seit
- Oct 2006
- Ort
- 貴方
- Beiträge
- 1.159
- Points
- 7.371
- Level
- 57
- Downloads
- 0
- Uploads
- 0
so u cant do
like
enemy.x through enemy.x + 15
in lua
-
02-03-2007, 06:30 PM #5514
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
Hey guys in my code this wont work:
But when I modded the netlib example and did this it worked in the example:Code:netget("p1") while true do netrecv() buffer = netvalue("p1") if buffer == "0" then screen:print(0,0,buffer,red) screen.waitVblankStart(); screen.flip() end end
The first one is from my game dosent work thx for all help.Code:netget("p1") while true do netrecv() buffer = netvalue("p1") if buffer == "0" then print(buffer) break end
-
02-03-2007, 06:56 PM #5515QJ Gamer Blue
- Registriert seit
- Jan 2007
- Ort
- U.S.
- Beiträge
- 405
- Points
- 7.014
- Level
- 55
- Downloads
- 0
- Uploads
- 0
Does anyone know of a way to do something if a certain button is being pressed and it hasn't been pressed for a certain amount of time? For example, I want to use the l trigger to go back one "page" in my new app, Todo Espanol. However, I don't want it to go back so quickly that it just flies through. I want it to go back just one page, and be able to press it again to go back again (no oldpad stuff). Thanks for any help.
-
02-03-2007, 08:37 PM #5516QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- Sydney, Australia
- Beiträge
- 117
- Points
- 4.210
- Level
- 41
- Downloads
- 0
- Uploads
- 0
Tryin my hand at making a simple program in LUA.
Need to know two things:
1. Is it possible to copy a file and then paste it in another folder using LUA ?
2. I heard speak of LUA being able to write to flash1 (I'm not interested in flash0, too risky). Is this possible ? And if so, how ? :)
-
02-03-2007, 09:00 PM #5517QJ 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
you MIGHT be able to write to flash1 (not flash0) MIGHT...not too sure...but you CAN read flash1 and flash0 easily.
as for copying and pasteing to a file, I don't know, good question though.NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
02-03-2007, 09:05 PM #5518QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
To copy and paste a file try somethin like:
copyingfile = io.open("fileyouwannacopy .ext","r")
copyingtofile = io.open("nameoffileuwanna copyitto.ext","w")
for line in copyingfile:lines() do
copyingtofile:write(line. ."\n")
end
The copyingtofile doesnt have to exist, itll create it.
-
02-03-2007, 09:16 PM #5519QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- Sydney, Australia
- Beiträge
- 117
- Points
- 4.210
- Level
- 41
- Downloads
- 0
- Uploads
- 0
I get an error with that code:
error: modified.lua:85: attempt to index global 'copyingfile' (a nil value)
Any insights TP ?
Zitat von Code
-
02-03-2007, 09:21 PM #5520lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
To copy and paste wouldn't you copy the file then make a new file and paste?


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