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; screen.watiVblankStart(18 0) needs to be screen. wait VblankStart(180)...
-
03-16-2007, 10:37 AM #6091
screen.watiVblankStart(18 0)
needs to be
screen.waitVblankStart(180)
牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
03-16-2007, 10:40 AM #6092QJ Gamer Green
- Registriert seit
- Jan 2007
- Ort
- beside my PC
- Beiträge
- 520
- Points
- 6.446
- Level
- 52
- Downloads
- 0
- Uploads
- 0
WOAH i cant believe i didnt see that! lol thx ill try it again
i really nid to use my glasses...
-= Double Post =-
hmm i dont get errors but the credits picture wont show
please leave a message i need to sleep now:) its 5:00AM here...
need to sleep
thxGeändert von ai3gtmc (03-16-2007 um 11:01 AM Uhr) Grund: Automerged Doublepost
-
03-16-2007, 11:20 AM #6093
I've tried many times to make shake die and all have failed
well here's what I tried, did something wrong 
Code:--///////////////// Aquateen Created By : pspfreak101, Thanks To Evilmana Tutorials\\\\\\\\\\\\\\\\\\ --///////////////// Special Thanks : Jason215, Evilmana Forums splash = Image.load("splashScreen.png") --OPENING SPLASH SCREEN screen:clear() screen:blit(0,0,splash) screen.flip() screen.waitVblankStart(200) green = Color.new(0,255,0) white = Color.new(255,255,255) red = Color.new(255,0,0) black = Color.new(0,0,0) --// Player, Enemy, Ground , bullet backgroundCache = Image.load("image.png") backgroundCache2 = Image.load("image2.png") backgroundCache3 = Image.load("image3.png") backgroundCache4 = Image.load("image4.png") light = Sound.load("light.wav", false) light:play() gunshot = Sound.load("gunshot.wav"), false bullet = Image.createEmpty(4,4) bullet:clear(green) player1 = Image.load("figure.png") Player = {} Player[1] ={ x = 50, y = 200, gravity = 200, jumpspeed = 10, jumpstate= "ground"} enemy1 = Image.load("shake.png") --// enemy image Enemy= {} Enemy[1] ={x = 300, y = 150, health=100, gravity = 200, jumpspeed = 10, jumpstate= "ground"} BulletInfo = {} for a = 1,5 do BulletInfo[a] = { pic = bullet , firing = false, direction = "right", x = Player[1].x + 32, y = Player[1].y + 16 } end Back1 = {} --------first scrolling background ( standard image 480 x 272) Back1.x = 0 ----positioned at the start Back1.y = 0 Back1.img = backgroundCache --- first background Back2 = {} --------Second scrolling background ( standard image 480 x 272) Back2.x = 480 ---- positioned precisely after the first background Back2.y = 0 Back2.img = backgroundCache2 --- second background to scroll after first Back3 = {} --------Third scrolling background ( standard image 480 x 272) Back3.x = 960 ---- positioned precisely after the second background Back3.y = 0 Back3.img = backgroundCache3 --- second background to scroll after second Back4 = {} Back4.x = 1440 Back4.y = 0 Back4.img = backgroundCache4 ground = Image.load("ground.png") frame1 = Image.load("frame1.png") frame2 = Image.load("frame2.png") frame3 = Image.load("frame3.png") currentFrame = 1 --this represents which frame is displaying counter = 0 --this is the frame counter which is used to determine when to change frames --// Variable oldpad = Controls.read() currentBullet = 0 direction = "right" --// Functions function bulletFire() for i = 1,5 do if BulletInfo[i].firing == true then if BulletInfo[i].direction == "right" then BulletInfo[i].x = BulletInfo[i].x + 10 end if BulletInfo[i].direction == "left" then BulletInfo[i].x = BulletInfo[i].x - 10 end screen:blit(BulletInfo[i].x,BulletInfo[i].y,BulletInfo[i].pic) end if (BulletInfo[i].x+bullet>Enemy[1].x)and(BulletInfo[i].x<Enemy[1].x)and(BulletInfo[i].y>Enemy[1].y)and (BulletInfo[i].y<Enemy[1].y) then Enemy[1].health=Enemy[1].health-10 end if BulletInfo[i].x < 0 or BulletInfo[i].x > 480 or BulletInfo[i].y < 0 or BulletInfo[i].y > 272 then BulletInfo[i].firing = false end end end function bulletSetup() --Increase the current bullet by one, or reset it to 1 if currentBullet < 5 then currentBullet = currentBullet + 1 else currentBullet = 1 end if direction == "left" then BulletInfo[currentBullet].x = Player[1].x BulletInfo[currentBullet].y = Player[1].y + 16 end if direction == "right" then BulletInfo[currentBullet].x = Player[1].x + 32 BulletInfo[currentBullet].y = Player[1].y + 16 end BulletInfo[currentBullet].direction = direction BulletInfo[currentBullet].firing = true end function movePlayer() if pad:left() then Back1.x = Back1.x + 1.5 ------ moves the background to scroll in the !!!opposite!!! direction you are going Back2.x = Back2.x + 1.5 ------ moves the background to scroll in the !!!opposite!!! direction you are going Back3.x = Back3.x + 1.5 ------ moves the background to scroll in the !!!opposite!!! direction you are going Back4.x = Back4.x + 1.5 ------ moves the background to scroll in the !!!opposite!!! direction you are going direction = "left" if Player[1].x >= 70 then -------!!!only if x is more than or = to 70 do you want to move, so you don't go offscreen. Change 70 to 150 or 0 and see what happens!!! Player[1].x = Player[1].x - 1.5 end -------- !!!END the if pad left part end -------- !!! now END the if x >= 70 part, so it'll only check player[1].x if pad is left, too !!! if pad:right() then Back1.x = Back1.x - 1.5 ------ moves the background to scroll in the !!!opposite!!! direction you are going Back2.x = Back2.x - 1.5 ------ moves the background to scroll in the !!!opposite!!! direction you are going Back3.x = Back3.x - 1.5 ------ moves the background to scroll in the !!!opposite!!! direction you are going Back4.x = Back4.x - 1.5 ------ moves the background to scroll in the !!!opposite!!! direction you are going direction = "right" if Player[1].x <= 300 then -------!!!only if x is less than or = to 300 do you want to move, so you don't go offscreen. Change 300 to 450 or 100 and see what happens!!! Player[1].x = Player[1].x + 1.5 end -------- !!!END the if pad left part end -------- !!! now END the if x <= 300 part, so it'll only check player[1].x if pad is right, too !!! if pad:up() then Player[1].y = Player[1].y - 1.5 direction = "up" end if pad:down() then Player[1].y = Player[1].y + 1.5 direction = "down" end end function chasePlayer() stallchase = math.random(2) if stallchase == 1 then if Enemy[1].x > Player[1].x then Enemy[1].x = Enemy[1].x - 1 elseif Enemy[1].x < Player[1].x then Enemy[1].x = Enemy[1].x + 1 end end end function Jump() --// Function to jump if pad:cross() and Player[1].jumpstate == "ground" then Player[1].jumpstate = "jumping" end if Player[1].jumpstate == "jumping" then Player[1].jumpspeed = Player[1].jumpspeed - 0.5 Player[1].gravity = Player[1].gravity - Player[1].jumpspeed end if Player[1].gravity < 0 then Player[1].jumpstate = "falling" end if Player[1].gravity < 200 and Player[1].jumpstate == "falling" then Player[1].gravity = Player[1].gravity + (Player[1].jumpspeed + 3) end if Player[1].gravity == 200 then Player[1].jumpspeed = 10 Player[1].jumpstate = "ground" end if Player[1].gravity > 200 then Player[1].gravity = 200 end Player[1].y = Player[1].gravity end while true do pad = Controls.read() screen:clear() counter = counter + 1 screen:clear() if counter > 60 then --if 60 frames have passed if currentFrame == 3 then --if we are on the last frame currentFrame = 1 --go back to first frame (loops animation) else currentFrame = currentFrame + 1 --else goto the next frame end counter = 0 --reset the counter end if pad:circle() and oldpad:circle() ~= pad:circle() then bulletSetup() gunshot:play() end --// Loads Functions movePlayer() chasePlayer() Jump() -- --// blitting Image to screen and text !!!first is the bottom layer, last is the top layer!!! if Back1.x <= 480 and Back1.x >= -480 then ----!!!if it should be visible, blit it, otherwise you're blitting stuff offscreen and slowing down the game!!! screen:blit(Back1.x, Back1.y, Back1.img) --- blits first background to the screen end if Back2.x <= 480 and Back2.x >= -480 then ----!!!if it should be visible, blit it, otherwise you're blitting stuff offscreen and slowing down the game!!! screen:blit(Back2.x, Back2.y, Back2.img) --- blits second background to the screen end if Back3.x <= 480 and Back3.x >= -480 then ----!!!if it should be visible, blit it, otherwise you're blitting stuff offscreen and slowing down the game!!! screen:blit(Back3.x, Back3.y, Back3.img) --- blits third background to the screen end if Back4.x <= 480 and Back4.x >= -480 then screen:blit(Back4.x, Back4.y, Back4.img) end bulletFire() ----!!!Blits bullets after background, but before player,enemy,text and ground-switch it up however you like !!! screen:blit(Player[1].x, Player[1].y, player1) screen:blit(Enemy[1].x, Enemy[1].y, enemy1) screen:blit(0,262,ground) if currentFrame == 1 then --draw first frame screen:blit(Back4.x - -50,50,frame1) screen:blit(Back4.x - -300,50,frame2) elseif currentFrame == 2 then --draw second frame screen:blit(Back4.x - -50,50,frame2) screen:blit(Back4.x - -300,50,frame3) elseif currentFrame == 3 then --draw third frame screen:blit(Back4.x - -50,50,frame3) screen:blit(Back4.x - -300,50,frame1) end screen:print(10,10,"X: "..Player[1].x.." Y: "..Player[1].y,green) screen:print(10,20,"Jumpstate: "..Player[1].jumpstate,green) screen:print(400,10,"You Suck",green) screen:print(200,200,"you killed shake", red) screen.waitVblankStart(200) dofile("script.lua") -- screen.waitVblankStart() screen.flip() endGeändert von pspaquaforce (03-16-2007 um 11:32 AM Uhr) Grund: Automerged Doublepost
-
03-16-2007, 11:26 AM #6094
You need to screen.flip() then do the waitVblankStart
Zitat von ai3gtmc
Geändert von youresam (03-16-2007 um 11:28 AM Uhr) Grund: Automerged Doublepost
牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
03-16-2007, 05:40 PM #6095
ok, in my program i have lots of loops for just about everything.
My loops start and end at different values, and loop different numbers of times. Is there any way to combine all of these into one loop, or minimize my loops in some way that anyone knows of?
-
03-16-2007, 05:49 PM #6096
Well, it depends on what the program looks like. Although the loops use different values, is the code inside the loops the same?
-
03-16-2007, 08:15 PM #6097QJ Gamer Green
- Registriert seit
- Jan 2007
- Ort
- beside my PC
- Beiträge
- 520
- Points
- 6.446
- Level
- 52
- Downloads
- 0
- Uploads
- 0
YAY it works now:)!!!
but i still have a question...whats the code that copy the whole directory
e.g. ms0:\psp\game\LuaPlayer <----COPY
ms0:\psp\game150\LuaPlaye r <----PASTE
thx:)
-
03-16-2007, 09:56 PM #6098Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
what kind of loops? for loops? while loops? we need to see code before reaching a conclusion. although usually, for loops arent combined unless two of them do the exact same thing. then they are usually made into a function.
Zitat von emericaska8r
--------------------------------------------------------------------------------------
-
03-16-2007, 11:50 PM #6099QJ Gamer Green
- Registriert seit
- Jan 2007
- Ort
- beside my PC
- Beiträge
- 520
- Points
- 6.446
- Level
- 52
- Downloads
- 0
- Uploads
- 0
maybe he can do DOFILE ?
-
03-17-2007, 06:54 AM #6100Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
that also depends. its useless to dofile if you just have a bunch of for loops.
Zitat von ai3gtmc
--------------------------------------------------------------------------------------
-
03-17-2007, 09:57 AM #6101QJ Gamer Green
- Registriert seit
- Jan 2007
- Ort
- beside my PC
- Beiträge
- 520
- Points
- 6.446
- Level
- 52
- Downloads
- 0
- Uploads
- 0
whats the code that copy the whole directory
e.g. ms0:\psp\game\LuaPlayer <----COPY
ms0:\psp\game150\LuaPlaye r <----PASTE
thx:)
-
03-17-2007, 10:07 AM #6102QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
i think there isnt code for copying WHOLE directory
[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-17-2007, 10:14 AM #6103
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
Can lua create a file (not a directory)?
-
03-17-2007, 10:17 AM #6104QJ Gamer Blue
- Registriert seit
- Dec 2006
- Beiträge
- 347
- Points
- 5.056
- Level
- 45
- Downloads
- 0
- Uploads
- 0
i think this will help many of the lua developers, especially beginners:
http://www.lua.org/manual/5.1/
A quick search on google, and voila! A lua reference manual.
EDIT: Also found another resource:
http://www.lua.org/pil/
Its an online book on lua programming.
Hope these help you guys.
-
03-17-2007, 10:19 AM #6105Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
I know how to create a text file in c not in lua.
-
03-17-2007, 10:20 AM #6106
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
well can you show me that...
-
03-17-2007, 10:23 AM #6107Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
i could show you but i dont think it would work in lua.
1.It's not psp specific.
ill post it if you want it though
-
03-17-2007, 10:27 AM #6108QJ Gamer Blue
- Registriert seit
- Dec 2006
- Beiträge
- 347
- Points
- 5.056
- Level
- 45
- Downloads
- 0
- Uploads
- 0
to the people who were wondering if there was an easy way to get a file's size, here you go:
Zitat von Programming in Lua, 1st Edition
-
03-17-2007, 10:50 AM #6109
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
Yeah, just post it, i know it wont work in lua and hopefully it works with the psp.
Zitat von eldiablov
-
03-17-2007, 10:51 AM #6110Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
kk one momento
-= Double Post =-
#include <stdio.h>
int main()
{
FILE *file_ptr;
file_ptr = fopen("data.txt", "w");
if(file_ptr !=NULL)
{
printf("file created\n");
fclose(file_ptr);
return 0;
}
else
{
printf("File creation failed\n");
return 1;
}
That code "should work" but im learning C so it is not certainGeändert von eldiablov (03-17-2007 um 10:57 AM Uhr) Grund: Automerged Doublepost
-
03-17-2007, 11:25 AM #6111Developer

- Registriert seit
- Jul 2006
- Beiträge
- 205
- Points
- 4.318
- Level
- 41
- Downloads
- 0
- Uploads
- 0
Same idea as C
Zitat von pspfreak9
io.open("newfile.txt","w" )
It would if they would look at it. Unfortunately, it's easier to ask somebody. To be fair, though, the question I just answered isn't really apparent from reading either of those resources.
Zitat von parm289
-
03-17-2007, 11:42 AM #6112QJ Gamer Blue
- Registriert seit
- Dec 2006
- Beiträge
- 347
- Points
- 5.056
- Level
- 45
- Downloads
- 0
- Uploads
- 0
I was just including those sites as general help, because most people don't wanna take the time to search for what they need. The post was not specific to your question - I was actually searching for a more efficient way to get a file's size when i came across those resources, and decided to post them here.
Zitat von LMelior
-
03-17-2007, 01:19 PM #6113
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
Can Some Please Check My Source.
Here, I moded youersams code to make a four player internet game. Can someone please check if everything is alright. As in logical stuff and netlib(I dont really know to much on how it works). I want to do this before I ask someone to test it with me. here is my source: (yes i know it is in a txt format)
SOURCE
-
03-17-2007, 01:46 PM #6114
I cant check it, but I highly doubt itll work. Just based on the fact that hardly anyone knows how to use netlib and that modding my 2 player script to be 4 player is near impossible.
Zitat von pspfreak9
牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
03-17-2007, 01:47 PM #6115
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
^ Why can't you check it? Anyways if you cant i'll just test it.
-
03-17-2007, 02:21 PM #6116Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
youresam i expect compensation for the inconvenience you caused me :)
-
03-17-2007, 02:21 PM #6117
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
Anyone wanna help me test BlackShark isnt online right now
-
03-17-2007, 02:22 PM #6118Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
i cant sorry man
-
03-17-2007, 02:26 PM #6119
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
Thats ok, maybe someone else, well can you check my code please. I dont see anything wrong with it though.
-
03-17-2007, 02:32 PM #6120
sure i'll help you [email protected]
Zitat von pspfreak9


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