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 myschoo ok coz i needed file check , i didnt know exactly how to do it so i ...
-
03-22-2007, 12:44 PM #6331QJ Gamer Green
- Registriert seit
- Jan 2006
- Beiträge
- 508
- Points
- 5.382
- Level
- 47
- Downloads
- 0
- Uploads
- 0
do this:
Zitat von myschoo
if io.open("file", "r") then
...do stuff...
io.close("file")
else
...print("file does not exist")
end
-
03-22-2007, 01:06 PM #6332QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
hey that looks good, i will try :)
edit.
works great,thx again ;)Geändert von myschoo (03-22-2007 um 01:30 PM Uhr)
[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]
-
03-22-2007, 06:40 PM #6333
Thanks! but now how do i read them?
Zitat von Fuzzie360
Geändert von ro0kie42 (03-22-2007 um 07:07 PM Uhr)
-
03-23-2007, 02:12 AM #6334QJ Gamer Green
- Registriert seit
- Jan 2007
- Ort
- beside my PC
- Beiträge
- 520
- Points
- 6.446
- Level
- 52
- Downloads
- 0
- Uploads
- 0
Zitat von xpack
already tried that...
-= Double Post =-
hmm this is really bad...
i cant try my flashing program since it stoped working...
it works on other psp'sGeändert von ai3gtmc (03-23-2007 um 05:36 AM Uhr) Grund: Automerged Doublepost
-
03-23-2007, 06:14 AM #6335QJ Gamer Gold
- Registriert seit
- Aug 2006
- Ort
- Under Your Bed
- Beiträge
- 3.083
- Points
- 12.189
- Level
- 72
- Downloads
- 0
- Uploads
- 0
Use my program FileFlasher to see if it works. If not I recomend a downgrade then an upgrade to see if that fixes the problem
-
03-23-2007, 09:21 AM #6336Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
He's having flash issues and your recommending that he formats his Flash0?
Bad advice. Unless you can diagnose the problem dont be too quick to give out that kind of advice.
-
03-23-2007, 09:25 AM #6337QJ Gamer Gold
- Registriert seit
- Aug 2006
- Ort
- Under Your Bed
- Beiträge
- 3.083
- Points
- 12.189
- Level
- 72
- Downloads
- 0
- Uploads
- 0
Can you at least flash USB mode
-
03-23-2007, 09:49 AM #6338QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
ai3: post your code here, maybe we can test it or fix something ;)
[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]
-
03-23-2007, 10:27 AM #6339QJ Gamer Gold
- Registriert seit
- Aug 2006
- Ort
- Under Your Bed
- Beiträge
- 3.083
- Points
- 12.189
- Level
- 72
- Downloads
- 0
- Uploads
- 0
I'll take a look at it if you want also
-
03-23-2007, 12:24 PM #6340
I made some animation code for character movement and I made some code for when the character is standing still. I don't know how to get it so that when the player is pressing nothing it will display the character standing still. Could someone help?
I basically want something to set walkflag = true when nothing is being pressed.
Code:dofile("animLib.lua") background = Image.load("background2.jpg") cleo = Image.load("cleofacedown.png") cleowalkdown = ANIM.new(4, "down", "png", "walkdown/") cleowalkup = ANIM.new(4, "up", "png", "walkup/") cleowalkleft = ANIM.new(4, "left", "png", "walkleft/") cleowalkright = ANIM.new(4, "right", "png", "walkright/") CleoX = 100 CleoY = 100 walkflag = true cleodown = true --WALKING AND CONTROL ANIMATIONS-- while true do pad=Controls.read() screen:blit(0,0,background) if pad:down() then walkflag = false CleoY = (CleoY + 4) cleowalkdown:blit(CleoX,CleoY,100) cleodown = true cleoup = false cleoright = false cleoleft = false end if pad:up() then walkflag = false CleoY = (CleoY - 4) cleowalkup:blit(CleoX,CleoY,100) cleodown = false cleoup = true cleoright = false cleoleft = false end if pad:left() then walkflag = false CleoX = (CleoX - 4) cleowalkleft:blit(CleoX,CleoY,100) cleodown = false cleoup = false cleoright = false cleoleft = true end if pad:right() then walkflag = false CleoX = (CleoX + 4) cleowalkright:blit(CleoX,CleoY,100) cleodown = false cleoup = false cleoright = true cleoleft = false end --RESET FACE POSITION-- if walkflag then if cleodown then cleo = Image.load("cleofacedown.png") screen:blit(CleoX,CleoY,cleo) end if cleoleft then cleo = Image.load("cleofaceleft.png") screen:blit(CleoX,CleoY,cleo) end if cleoright then cleo = Image.load("cleofaceright.png") screen:blit(CleoX,CleoY,cleo) end if cleoup then cleo = Image.load("cleofaceup.png") screen:blit(CleoX,CleoY,cleo) end end screen.flip() screen.waitVblankStart() end
-
03-23-2007, 01:03 PM #6341
try this:
one thing, in the "reset face position" section, instead of re-loading images each time you stop after changing direction it would be better to load all four images at the start of your program and put them into a table like this:Code:if not pad:right() and not pad:left() and not pad:up() and not pad:down() then walkflag = true end
then, in "reset face position" you could do this:Code:cleo = {} cleo[1] = Image.load("cleofacedown.png") cleo[2] = Image.load("cleofaceleft.png") cleo[3] = Image.load("cleofaceright.png") cleo[4] = Image.load("cleofaceup.png") end
Code:if walkflag then if cleodown then direction = 1 end if cleoleft then direction = 2 end if cleoright then direction = 3 end if cleoup then direction = 4 end screen:blit(CleoX,CleoY,cleo[direction]) end
Geändert von Merick (03-23-2007 um 01:15 PM Uhr)
-
03-23-2007, 01:14 PM #6342
PERFECT!
Thank you SO much.
-
03-23-2007, 01:15 PM #6343Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
next time. Use animlib
-
03-23-2007, 01:22 PM #6344Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
remember, states dont automatically reset themselves. ;) dont forget to set a state to false, if its not true anymore. and also, you should use else and elseif's a lot more. it gives you many more extra CPU cycles. you whole code can be made much better just by adding elseif's:
-= Double Post =-Code:dofile("animLib.lua") background = Image.load("background2.jpg") cleo = Image.load("cleofacedown.png") cleowalkdown = ANIM.new(4, "down", "png", "walkdown/") cleowalkup = ANIM.new(4, "up", "png", "walkup/") cleowalkleft = ANIM.new(4, "left", "png", "walkleft/") cleowalkright = ANIM.new(4, "right", "png", "walkright/") CleoX = 100 CleoY = 100 walkflag = true cleodown = true --WALKING AND CONTROL ANIMATIONS-- while true do pad=Controls.read() screen:blit(0,0,background) if pad:down() then walkflag = false CleoY = (CleoY + 4) cleowalkdown:blit(CleoX,CleoY,100) cleodown = true cleoup = false cleoright = false cleoleft = false elseif pad:up() then walkflag = false CleoY = (CleoY - 4) cleowalkup:blit(CleoX,CleoY,100) cleodown = false cleoup = true cleoright = false cleoleft = false end if pad:left() then walkflag = false CleoX = (CleoX - 4) cleowalkleft:blit(CleoX,CleoY,100) cleodown = false cleoup = false cleoright = false cleoleft = true elseif pad:right() then walkflag = false CleoX = (CleoX + 4) cleowalkright:blit(CleoX,CleoY,100) cleodown = false cleoup = false cleoright = true cleoleft = false end if not pad:right() and not pad:left() and not pad:up() and not pad:down() then walkflag = true end --RESET FACE POSITION-- if walkflag then if cleodown then cleo = Image.load("cleofacedown.png") screen:blit(CleoX,CleoY,cleo) elseif cleoleft then cleo = Image.load("cleofaceleft.png") screen:blit(CleoX,CleoY,cleo) elseif cleoright then cleo = Image.load("cleofaceright.png") screen:blit(CleoX,CleoY,cleo) elseif cleoup then cleo = Image.load("cleofaceup.png") screen:blit(CleoX,CleoY,cleo) end end screen.flip() screen.waitVblankStart() end
he is already using it.
Zitat von eldiablov
Geändert von Grimfate126 (03-23-2007 um 01:27 PM Uhr) Grund: Automerged Doublepost
--------------------------------------------------------------------------------------
-
03-23-2007, 02:03 PM #6345
Mmhmm, I see what you mean Grim. Thank you.
@Merick: Tables you say? I think I'll give it a go. Thanks.
-
03-23-2007, 04:45 PM #6346.info

- Registriert seit
- Jun 2006
- Ort
- ACT, Australia
- Beiträge
- 1.674
- Points
- 15.395
- Level
- 80
- Downloads
- 0
- Uploads
- 0
Ok this is really annoying me. Can someone tell me why "w+" mode is not working on luaplayer 0.20?!?! Is there an alternative way to overwrite all existing data in the text file? This is what i wrote, and when i try to write to it i get 'attempt to call file10 - a nil value'
Code:file10 = io.open("data/load.img","w+")
-
03-23-2007, 05:24 PM #6347
I'm getting a type error I don't understand:
I'm trying to get it so that when you hit the attack button while facing down it will count the attack as taking place if you are pretty much within 10 pixels of the object...Code:if cleodown then if (MobX - 10 >= CleoX >= MobX + 10) and (MobY - 10 >= CleoY >= MobY + 10) then screen:blit(-100,-100,monster) end end
I get the error "Trying to compare number with boolean" for the second line...but MobX is 150 and MobY is 100 and Cleo X and Y are also numbers...
-
03-23-2007, 05:29 PM #6348QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
You must of changed the values of the co-ordinates to a boolean (true/false) somewhere else in the code. Re-check the rest of the code.
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
03-23-2007, 07:33 PM #6349
Here is my entire code and I don't see how CleoX, CleoY, MobX, MobY could be boolean (But I only started coding yesterday).
Code:dofile("animLib.lua") monster = Image.load("monster.png") background = Image.load("background3.jpg") cleowalkdown = ANIM.new(4, "down", "png", "walkdown/") cleowalkup = ANIM.new(4, "up", "png", "walkup/") cleowalkleft = ANIM.new(4, "left", "png", "walkleft/") cleowalkright = ANIM.new(4, "right", "png", "walkright/") CleoX = 100 CleoY = 100 MobX = 200 MobY = 150 walkflag = true cleodown = true cleo = {} cleo[1] = Image.load("cleofacedown.png") cleo[2] = Image.load("cleofaceleft.png") cleo[3] = Image.load("cleofaceright.png") cleo[4] = Image.load("cleofaceup.png") cleo[5] = Image.load("cleoattackdown.png") cleo[6] = Image.load("cleoattackleft.png") cleo[7] = Image.load("cleoattackright.png") cleo[8] = Image.load("cleoattackup.png") --WALKING AND CONTROL ANIMATIONS-- while true do pad=Controls.read() screen:blit(0,0,background) screen:blit(MobX,MobY,monster) --Down-- if pad:down() and not pad:cross() and not pad:left() and not pad:right() then walkflag = false CleoY = (CleoY + 3) cleowalkdown:blit(CleoX,CleoY,100) cleodown = true cleoup = false cleoright = false cleoleft = false elseif pad:down() and pad:right() and not pad:cross() then walkflag = false CleoY = (CleoY + 2) CleoX = (CleoX + 2) cleowalkdown:blit(CleoX,CleoY,100) cleodown = true cleoup = false cleoright = false cleoleft = false elseif pad:down() and pad:left() and not pad:cross() then walkflag = false CleoY = (CleoY + 2) CleoX = (CleoX - 2) cleowalkdown:blit(CleoX,CleoY,100) cleodown = true cleoup = false cleoright = false cleoleft = false end --Up-- if pad:up() and not pad:cross() and not pad:left() and not pad:right() then walkflag = false CleoY = (CleoY - 3) cleowalkup:blit(CleoX,CleoY,100) cleodown = false cleoup = true cleoright = false cleoleft = false elseif pad:up() and pad:right() and not pad:cross() then walkflag = false CleoY = (CleoY - 2) CleoX = (CleoX + 2) cleowalkup:blit(CleoX,CleoY,100) cleodown = false cleoup = true cleoright = false cleoleft = false elseif pad:up() and pad:left() and not pad:cross() then walkflag = false CleoY = (CleoY - 2) CleoX = (CleoX - 2) cleowalkup:blit(CleoX,CleoY,100) cleodown = false cleoup = true cleoright = false cleoleft = false end --Left-- if pad:left() and not pad:cross() and not pad:up() and not pad:down() then walkflag = false CleoX = (CleoX - 3) cleowalkleft:blit(CleoX,CleoY,100) cleodown = false cleoup = false cleoright = false cleoleft = true end --Right-- if pad:right() and not pad:cross() and not pad:up() and not pad:down() then walkflag = false CleoX = (CleoX + 3) cleowalkright:blit(CleoX,CleoY,100) cleodown = false cleoup = false cleoright = true cleoleft = false end if not pad:right() and not pad:left() and not pad:up() and not pad:down() and not pad:cross() then walkflag = true end --RESET FACE POSITION-- if walkflag then if cleodown then direction = 1 end if cleoleft then direction = 2 end if cleoright then direction = 3 end if cleoup then direction = 4 end screen:blit(CleoX,CleoY,cleo[direction]) end --ATTACKING-- if pad:cross() then if cleodown then direction = 5 end if cleoleft then direction = 6 end if cleoright then direction = 7 end if cleoup then direction = 8 end screen:blit(CleoX,CleoY,cleo[direction]) --ATTACKDAMAGE-- if (MobX - 10 <= CleoX <= MobX + 10) and (MobY - 10 <= CleoY <= MobY + 10) then MobX = -100 MobY = -100 end end screen.flip() screen.waitVblankStart() end
-
03-23-2007, 07:42 PM #6350QJ Gamer Green
- Registriert seit
- Jan 2007
- Ort
- beside my PC
- Beiträge
- 520
- Points
- 6.446
- Level
- 52
- Downloads
- 0
- Uploads
- 0
Zitat von myschoo
here..Code:Red = Color.new(255, 0, 0) Blue = Color.new(0,0,200) function PrintCentered(y,string,color) screen:print( 240 - (string.len(string)*8) / 2 ,y,string,color); end Background = Image.load("background1.png") System.Unassign("flash0:" ) System.Assign("flash0:", "lflash0:0,0", "flashfat0:") while true do current = 1 oldpad = Controls.read() while true do pad = Controls.read() screen:blit(0,0,Background) PrintCentered(3,"Lua Theme Flasher", Blue) PrintCentered(18,"By ai3gtmc", Blue) screen:print(137, 96, "=> 01-12.bmp background", Blue) screen:print(137, 106, "=> TopMenu_Plugin", Blue) screen:print(137, 116, "=> Opening_Plugin", Blue) screen:print(137, 126, "=> Gameboot.PMF", Blue) screen:print(137, 136, "=> System_Plugin_bg", Blue) screen:print(137, 146, "=> System_Plugin_fg", Blue) screen:print(137, 156, "=> System_Plugin", Blue) screen:print(137, 166, "=> Game_Plugin", Blue) screen:print(137, 176, "=> photo_plugin", Blue) screen:print(137, 186, "=> impose_plugin", Blue) screen:print(137, 196, "=> ltn0.pgf", Blue) screen:print(137, 210, "=> Enable USB", Blue) screen:print(137, 220, "=> Disable USB",Blue) screen:print(137, 240, "=> EXIT", Blue) if current == 1 then screen:print(137, 96, "=> 01-12.bmp background", Red) end if current == 2 then screen:print(137, 106, "=> TopMenu_Plugin.rco", Red) end if current == 3 then screen:print(137, 116, "=> Opening_Plugin.rco", Red) end if current == 4 then screen:print(137, 126, "=> Gameboot.PMF", Red) end if current == 5 then screen:print(137, 136, "=> System_Plugin_bg.rco", Red) end if current == 6 then screen:print(137, 146, "=> System_Plugin_fg.rco", Red) end if current == 7 then screen:print(137, 156, "=> System_Plugin.rco", red) end if current == 8 then screen:print(137, 166, "=> Game_Plugin.rco", red) end if current == 9 then screen:print(137, 176, "=> photo_plugin.rco", red) end if current == 10 then screen:print(137, 186, "=> impose_plugin.rco", red) end if current == 11 then screen:print(137, 196, "=> ltn0.pgf", red) end if current == 12 then screen:print(137,210, "=> Enable USB!", red) end if current == 13 then screen:print(137,220, "=> Disable USB!", red) end if current == 14 then screen:print(137, 240, "=> EXIT", red) end if pad:up() and oldpad:up() ~= pad:up() then current = current-1 end if pad:down() and oldpad:down() ~= pad:down() then current = current+1 end if current == 15 then current = 1 end if current == 0 then current = 14 end if pad:cross() and current == 1 then System.writeFile("ms0:/theme/01-12.bmp","flash0:/vsh/resource/01-12.bmp","yes") end if pad:cross() and current == 2 then System.writeFile("ms0:/theme/topmenu_plugin.rco","flash0:/vsh/resource/topmenu_plugin.rco","yes") end if pad:cross() and current == 3 then System.writeFile("ms0:/theme/opening_plugin.rco","flash0:/vsh/resource/opening_plugin.rco","yes") end if pad:cross() and current == 4 then System.writeFile("ms0:/theme/gameboot.pmf","flash0:/vsh/resource/gameboot.pmf","yes") end if pad:cross() and current == 5 then System.writeFile("ms0:/theme/system_plugin_bg.rco","flash0:/vsh/resource/system_plugin_bg.rco","yes") end if pad:cross() and current == 6 then System.writeFile("ms0:/theme/system_plugin_fg.rco","flash0:/vsh/resource/system_plugin_fg.rco","yes") end if pad:cross() and current == 7 then System.writeFile("ms0:/theme/system_plugin.rco","flash0:/vsh/resource/system_plugin.rco","yes") end if pad:cross() and current == 8 then System.writeFile("ms0:/theme/game_plugin.rco","flash0:/vsh/resource/game_plugin.rco","yes") end if pad:cross() and current == 9 then System.writeFile("ms0:/theme/photo_plugin.rco","flash0:/vsh/resource/photo_plugin.rco","yes") end if pad:cross() and current == 10 then System.writeFile("ms0:/theme/impose_plugin.rco","flash0:/vsh/resource/impose_plugin.rco","yes") end if pad:cross() and current == 11 then System.writeFile("ms0:/theme/ltn0.pgf","flash0:/vsh/font/ltn0.pgf","yes") end if pad:cross() and current == 12 then System.usbDiskModeActivate() end if pad:cross() and current == 13 then System.usbDiskModeDeactivate() end if pad:cross() and current == 14 then System.Quit() end ---ScreenShot--- if pad:select() then Image:save("screenshot.png") end if pad:start() then System.Quit() end screen.waitVblankStart() screen.flip() oldpad = pad end end
it works on other psp's
worked on my psp few days ago...
I didnt edit anything since it worked....
but now it wont work...
-
03-23-2007, 07:59 PM #6351
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
Looks to me like youve got a extra 'end' at the end. I dont know if thats true I just went through it really fast.
-
03-23-2007, 08:14 PM #6352
If you scroll up you'll see my code...but...I also just noticed something:
I tried replacing all the variables in that line with numbers so the line makes sense but it keeps giving me the same error anyways...and I've tried with and without brackets.
The error is: Attempt to compare boolean with number.Code:--ATTACKDAMAGE-- if 140 <= CleoX <= 160 and 190 <= CleoY <= 210 then MobX = -100 MobY = -100 end
And the line it is listed under is the blank space between --Attack damage-- and the if statement.
-
03-23-2007, 08:21 PM #6353
try this:
also, you need another "end" at the end of this blockCode:if MobX - 10 <= CleoX and CleoX <= MobX + 10 and MobY - 10 <= CleoY and CleoY <= MobY + 10 then
Code:--ATTACKING-- if pad:cross() then if cleodown then direction = 5 end if cleoleft then direction = 6 end if cleoright then direction = 7 end if cleoup then direction = 8 end screen:blit(CleoX,CleoY,cleo[direction])
-
03-23-2007, 08:31 PM #6354QJ Gamer Gold
- Registriert seit
- Nov 2006
- Ort
- ...
- Beiträge
- 2.080
- Points
- 11.942
- Level
- 71
- Downloads
- 0
- Uploads
- 0
I need help with trying to get Urameshi to show animation when following Ichigo, here's my code:
Code:white=Color.new(255,255,255) Level=Image.load("./images/backgrounds/forest1.png") Sasuke=Image.load("./images/Characters/sasukeleft.png") ------------Good Guy Ichigo=Image.load("./images/New Characters/Ichigoright.png") Ichigo1=Image.load("./images/New Characters/Ichigo-left.png") IchigorRight=Image.load("./images/New Characters/IchigorunRight.png") IchigorLeft=Image.load("./images/New Characters/IchigorunLeft.png") IchigobRight=Image.load("./images/New Characters/IchigoblockRight.png") IchigobLeft=Image.load("./images/New Characters/IchigoblockLeft.png") Ichigodeath=Image.load("./images/New Characters/Ichigodeath.png") IchigoPunchr=Image.load("./images/New Characters/IchigofightRight.png") IchigoPunchl=Image.load("./images/New Characters/IchigofightLeft.png") ---------------Bad Guy Urameshi=Image.load("./images/Urameshi/Urameshi.png") Urameshi1=Image.load("./images/Urameshi/Urameshi1.png") UrameshirRight=Image.load("./images/Urameshi/UrameshiRRun.png") UrameshirLeft=Image.load("./images/Urameshi/UrameshiLRun.png") UrameshiPunchr=Image.load("./images/Urameshi/UrameshiPunchRight.png") UrameshiPunchl=Image.load("./images/Urameshi/UrameshiPunchLeft.png") UrameshiHurtR=Image.load("./images/Urameshi/HurtRight.png") UrameshiHurtL=Image.load("./images/Urameshi/HurtLeft.png") --Right empty r1=Image.createEmpty(66,45) r2=Image.createEmpty(66,45) r3=Image.createEmpty(66,45) ur1=Image.createEmpty(48,37) ur2=Image.createEmpty(48,37) ur3=Image.createEmpty(48,37) --Left Empty l1=Image.createEmpty(66,45) l2=Image.createEmpty(66,45) l3=Image.createEmpty(66,45) ul1=Image.createEmpty(48,37) ul2=Image.createEmpty(48,37) ul3=Image.createEmpty(48,37) --Left animation l1:blit(0,0,IchigorLeft,148,3,66,45) l2:blit(0,0,IchigorLeft,70,3,66,45) l3:blit(0,0,IchigorLeft,0,4,66,45) ul1:blit(0,0,UrameshirLeft,114,1,48,37) ul2:blit(0,0,UrameshirLeft,59,0,48,37) ul3:blit(0,0,UrameshirLeft,0,1,48,37) --Right Animation r1:blit(0,0,IchigorRight,0,3,66,45) r2:blit(0,0,IchigorRight,74,3,66,45) r3:blit(0,0,IchigorRight,146,3,66,45) ur1:blit(0,0,UrameshirRight,0,1,48,37) ur2:blit(0,0,UrameshirRight,55,1,48,37) ur3:blit(0,0,UrameshirRight,115,1,48,37) r={Ichigo,r1,r2,r3} l={Ichigo1,l1,l2,l3} ur={Urameshi,ur1,ur2,ur3} ul={Urameshi1,ul1,ul2,ul3} Player={x=0,y=200,w=77,h=54,d=r,f=0,s=2,animt=0,img=Ichigo,oldimg=Ichigo1} Sasuke={x=400,y=200,w=32,h=38,img=Sasuke} Urameshi={x=400,y=200,w=48,h=37,d=ul,s=1,animt=0,img=Urameshi,oldimg=Urameshi1} Timer=0 math.randomseed(os.time()) -------------------------------------------------------functions function Level1() while true do screen:clear() movePlayer() chasePlayer(Urameshi) if collision(Player,Urameshi) and Player.d == r then Player.img=Ichigodeath Player.s=0 elseif collision(Player,Sasuke) and Player.d==l then Player.img=Ichigodeath Player.s=0 end if Player.img == Ichigodeath then Player.x=Player.x end screen:blit(0,0,Level) screen:blit(Player.x,Player.y,Player.img) screen:blit(Urameshi.x,Urameshi.y,Urameshi.oldimg) screen.flip() screen.waitVblankStart() end end ----------------------------------------------------------------Not Levels function pausetillx() while true do --infinite loop used to pause game pad = Controls.read() if pad:cross() then screen:clear() while pad:cross() do screen:clear() pad = Controls.read() end break --breaks loop resuming game end end end function collision(ob1,ob2) if (ob1.x + ob1.w > ob2.x) and (ob1.x < ob2.x + ob2.w) and (ob1.y + ob1.h > ob2.y) and (ob1.y < ob2.y + ob2.h) then return true else return false end end function anim(ob) ob.img=ob.oldimg ob.animt = ob.animt + 1 if ob.animt > 15 then ob.animt = 1 end if ob.animt < 6 then ob.img = ob.d[2] end if ob.animt > 5 then ob.img = ob.d[3] end if ob.animt > 10 then ob.img = ob.d[4] end end function chasePlayer(ob) stallchase = math.random(2) if ob.x > Player.x then ob.x=ob.x - 2 anim(Urameshi) else if ob.x < Player.x then ob.x = ob.x + 2 anim(Urameshi) end 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=IchigobRight elseif Player.d == l then Player.img = IchigobLeft end Player.s=2 defending=true end if defending and not pad:cross() then defending=false Player.img=Player.oldimg Player.s=2 end if pad:square() then Player.oldimg=Player.img if Player.d == r then Player.img=IchigoPunchr else if Player.d == l then Player.img=IchigoPunchl end Player.s=2 punching=true end if punching and not pad:square() then punching=false Player.img=Player.oldimg Player.s=2 end end end oldpad=Controls.read() crouching=false defending=false punching=false alreadycolliding=true numberoftimescollide=3 death=true numberofcollisiontimes=0 movingstate=0 -----------------------------------------------------------------main loop while true do screen:clear() Level1() screen.flip() screen.waitVblankStart() oldpad=pad end
-
03-23-2007, 08:43 PM #6355
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
First of all you have fuctions that you didn't even say what they do from the begining. Like chaseplayer(Urameshi)
-
03-23-2007, 08:50 PM #6356QJ Gamer Gold
- Registriert seit
- Nov 2006
- Ort
- ...
- Beiträge
- 2.080
- Points
- 11.942
- Level
- 71
- Downloads
- 0
- Uploads
- 0
Urameshi chases the Player, but it wont animate the chasing so its like he's moving towards Player but he's not technically moving, he's standing
-
03-23-2007, 08:54 PM #6357
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
Thats not the point, you never said what chaseplayer does you have to have a function like:
Code:function chaseplayer(playername) anim(playername)--I just made that up but you get the point. end
-
03-23-2007, 09:13 PM #6358QJ Gamer Gold
- Registriert seit
- Nov 2006
- Ort
- ...
- Beiträge
- 2.080
- Points
- 11.942
- Level
- 71
- Downloads
- 0
- Uploads
- 0
i already have a chasePlayer function though, do i make another?
-
03-23-2007, 10:11 PM #6359
Works like a charm thank you again for your help. I understand now that I can't check if a variable is between something the traditional way because after the first two steps it'll be either "True" or "False" and True >= 160 makes no sense.
Zitat von Merick
-
03-24-2007, 01:41 AM #6360QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
this works for me, repaired some errors... try itCode:red = Color.new(255, 0, 0) Blue = Color.new(0,0,200) function PrintCentered(y,string,color) screen:print( 240 - (string.len(string)*8) / 2 ,y,string,color); end Background = Image.load("background1.png") System.Unassign("flash0:" ) System.Assign("flash0:", "lflash0:0,0", "flashfat0:") current = 1 oldpad = Controls.read() while true do pad = Controls.read() screen:blit(0,0,Background) PrintCentered(3,"Lua Theme Flasher", Blue) PrintCentered(18,"By ai3gtmc", Blue) screen:print(137, 96, "=> 01-12.bmp background", Blue) screen:print(137, 106, "=> TopMenu_Plugin", Blue) screen:print(137, 116, "=> Opening_Plugin", Blue) screen:print(137, 126, "=> Gameboot.PMF", Blue) screen:print(137, 136, "=> System_Plugin_bg", Blue) screen:print(137, 146, "=> System_Plugin_fg", Blue) screen:print(137, 156, "=> System_Plugin", Blue) screen:print(137, 166, "=> Game_Plugin", Blue) screen:print(137, 176, "=> photo_plugin", Blue) screen:print(137, 186, "=> impose_plugin", Blue) screen:print(137, 196, "=> ltn0.pgf", Blue) screen:print(137, 210, "=> Enable USB", Blue) screen:print(137, 220, "=> Disable USB",Blue) screen:print(137, 240, "=> EXIT", Blue) if current == 1 then screen:print(137, 96, "=> 01-12.bmp background", red) end if current == 2 then screen:print(137, 106, "=> TopMenu_Plugin.rco", red) end if current == 3 then screen:print(137, 116, "=> Opening_Plugin.rco", red) end if current == 4 then screen:print(137, 126, "=> Gameboot.PMF", red) end if current == 5 then screen:print(137, 136, "=> System_Plugin_bg.rco", red) end if current == 6 then screen:print(137, 146, "=> System_Plugin_fg.rco", red) end if current == 7 then screen:print(137, 156, "=> System_Plugin.rco", red) end if current == 8 then screen:print(137, 166, "=> Game_Plugin.rco", red) end if current == 9 then screen:print(137, 176, "=> photo_plugin.rco", red) end if current == 10 then screen:print(137, 186, "=> impose_plugin.rco", red) end if current == 11 then screen:print(137, 196, "=> ltn0.pgf", red) end if current == 12 then screen:print(137,210, "=> Enable USB!", red) end if current == 13 then screen:print(137,220, "=> Disable USB!", red) end if current == 14 then screen:print(137, 240, "=> EXIT", red) end if pad:up() and oldpad:up() ~= pad:up() then current = current-1 end if pad:down() and oldpad:down() ~= pad:down() then current = current+1 end if current == 15 then current = 1 end if current == 0 then current = 14 end if pad:cross() and current == 1 then System.writeFile("ms0:/theme/01-12.bmp","flash0:/vsh/resource/01-12.bmp","yes") end if pad:cross() and current == 2 then System.writeFile("ms0:/theme/topmenu_plugin.rco","flash0:/vsh/resource/topmenu_plugin.rco","yes") end if pad:cross() and current == 3 then System.writeFile("ms0:/theme/opening_plugin.rco","flash0:/vsh/resource/opening_plugin.rco","yes") end if pad:cross() and current == 4 then System.writeFile("ms0:/theme/gameboot.pmf","flash0:/vsh/resource/gameboot.pmf","yes") end if pad:cross() and current == 5 then System.writeFile("ms0:/theme/system_plugin_bg.rco","flash0:/vsh/resource/system_plugin_bg.rco","yes") end if pad:cross() and current == 6 then System.writeFile("ms0:/theme/system_plugin_fg.rco","flash0:/vsh/resource/system_plugin_fg.rco","yes") end if pad:cross() and current == 7 then System.writeFile("ms0:/theme/system_plugin.rco","flash0:/vsh/resource/system_plugin.rco","yes") end if pad:cross() and current == 8 then System.writeFile("ms0:/theme/game_plugin.rco","flash0:/vsh/resource/game_plugin.rco","yes") end if pad:cross() and current == 9 then System.writeFile("ms0:/theme/photo_plugin.rco","flash0:/vsh/resource/photo_plugin.rco","yes") end if pad:cross() and current == 10 then System.writeFile("ms0:/theme/impose_plugin.rco","flash0:/vsh/resource/impose_plugin.rco","yes") end if pad:cross() and current == 11 then System.writeFile("ms0:/theme/ltn0.pgf","flash0:/font/ltn0.pgf","yes") end if pad:cross() and current == 12 then System.usbDiskModeActivate() end if pad:cross() and current == 13 then System.usbDiskModeDeactivate() end if pad:cross() and current == 14 then System.Quit() end ---ScreenShot--- if pad:select() then Image:save("screenshot.png") end if pad:start() then System.Quit() end screen.waitVblankStart() screen.flip() oldpad = pad 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]


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