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; its still not working Ok heres part of my code here Quote: if pad:r() then computer = math.random(3,5) end but ...
-
11-14-2006, 04:48 PM #4111Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
its still not working
Ok heres part of my code here
Quote:
if pad:r() then
computer = math.random(3,5)
end
but the problem is as soon as i press r my pic goes away and the variable returns to its orginal state. how can i make it so that one press of r and boom the pic stays blitted and the variable stays at the random selection. also i tried holding r and since its random it doesnt work it just keeps changing.
when i hold down r it keeps doing generating the random numbers. how can i make it so that once i hold down r it gets that number and sticks with it until r is let go???? HELP plz im soo close to v0.2 i even have a menu this stupid random thing is killin me.
If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
Gold donations are highly appreciated!
-
11-14-2006, 04:51 PM #4112Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von GuitarGod1134
ok, you can use oldpad, but its not very responsive, try this:
Code:-- BEFORE YOUR MAIN LOOP, OUTSIDE OF ANY FUNCTIONS, PUT THIS -- pressedR = false -- WHEREVER YOU DO "if pad:r() then..." put this-- if pad:r() then if not pressedR then computer = math.random(3,5) end pressedR = true else pressedR = false end--------------------------------------------------------------------------------------
-
11-14-2006, 05:02 PM #4113Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
Thanks a bunch grim im gonna try it now.
-= Double Post =-
wow wasnnt that funny but yah on the code snippet i saw the funtion and the variable had a very similar name and as i skimmed down it pretty fast i got confused.
Zitat von Grimfate126
EDIT: Well worst has come to worst. I was pushing really hard to get v0.2 out but its 2 in the morning and I have a Algebra test and I still have spanish2 homework to do. So grim if you find out the problem in the code i gave you can u fix it? if so thanks o and i can send you the pics too.Geändert von GuitarGod1134 (11-14-2006 um 05:07 PM Uhr) Grund: Automerged Doublepost
If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
Gold donations are highly appreciated!
-
11-14-2006, 05:34 PM #4114Designs

- Registriert seit
- Jul 2006
- Ort
- Canada
- Beiträge
- 1.395
- Points
- 14.040
- Level
- 76
- Downloads
- 0
- Uploads
- 0
can anyone asner my question
Zitat von yoyomacy
-= Double Post =-
anyone?Geändert von yoyomacy (11-14-2006 um 05:34 PM Uhr) Grund: Automerged Doublepost

-
11-14-2006, 06:01 PM #4115
--Anwser to Yoyomacy
Actualy when doing dofile its like merging 2 files in 1 so you just have to make you function in one file then dofiles the other.So just do your collision check as if evcerything whas in the same file.
--My question--
here is my code i just don't under stand why it doesn't work.
when i press up the screen goes black when i press down twice same thing.Any one know why?Code:--Define's Place Red = Color.new(255,0,0) Green =Color.new(0,255,0) Blue = Color.new(0,0,255) CurrentSelection = 1 MenuBG1 = Image.load("Menu/menu1.png") MenuBG2 = Image.load("Menu/menu2.png") oldpad = Controls.read() while true do screen:clear() pad = Controls.read() --Menu1 Controls if pad:down() and oldpad:down() ~= pad:down() then CurrentSelection = CurrentSelection + 1 elseif CurrentSelection == 2 then CurrentSelection = 1 elseif pad:up() and oldpad:up() ~= pad:up() then CurrentSelection = CurrentSelection - 1 elseif CurrentSelection == 0 then CurrentSelection = 2 end if CurrentSelection == 1 then screen:blit(0,0,MenuBG1) elseif CurrentSelection == 2 then screen:blit(0,0,MenuBG2) end screen.waitVblankStart() screen.flip() endFree Prizes at Prizerebel Join us!
I already got 11 Gifts. Ask me for details or proof.
-
11-14-2006, 06:04 PM #4116Designs

- Registriert seit
- Jul 2006
- Ort
- Canada
- Beiträge
- 1.395
- Points
- 14.040
- Level
- 76
- Downloads
- 0
- Uploads
- 0
wow thanks for the great reply
Zitat von ZereoX

also take out the ELSE from the elseif, see if that works
-
11-14-2006, 06:14 PM #4117
Thanks Yoyo it works. i don't know where my else if statement Fu** but il try do add some elseif statement until i get the error again so my code i shorther and i just have to remove maybe one elseif.
Free Prizes at Prizerebel Join us!
I already got 11 Gifts. Ask me for details or proof.
-
11-14-2006, 06:42 PM #4118I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
ZeroX, you also need to add "oldpad = pad" at the end of your file.

-
11-14-2006, 08:08 PM #4119
Access_Denied i added Oldpad = Controls.read() at the begining of the code and my code works perfect.
Free Prizes at Prizerebel Join us!
I already got 11 Gifts. Ask me for details or proof.
-
11-14-2006, 11:17 PM #4120.info

- Registriert seit
- Jun 2006
- Ort
- ACT, Australia
- Beiträge
- 1.674
- Points
- 15.395
- Level
- 80
- Downloads
- 0
- Uploads
- 0
I need to know: Is it possible to set screen brightness in LUA? (like when you press the little button next to the note, the brightness adjuster) I need it for a power saving purposes :)
-
11-14-2006, 11:30 PM #4121Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
Still got my q over here
its still not working
Ok heres part of my code here
Quote:
if pad:r() then
computer = math.random(3,5)
end
but the problem is as soon as i press r my pic goes away and the variable returns to its orginal state. how can i make it so that one press of r and boom the pic stays blitted and the variable stays at the random selection. also i tried holding r and since its random it doesnt work it just keeps changing.
when i hold down r it keeps doing generating the random numbers. how can i make it so that once i hold down r it gets that number and sticks with it until r is let go???? HELP plz im soo close to v0.2 i even have a menu this stupid random thing is killin me.If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
Gold donations are highly appreciated!
-
11-14-2006, 11:39 PM #4122.info

- Registriert seit
- Jun 2006
- Ort
- ACT, Australia
- Beiträge
- 1.674
- Points
- 15.395
- Level
- 80
- Downloads
- 0
- Uploads
- 0
Does anyone know how to set the brightness in LUA? I need it for power conserving feature for my next app
-
11-14-2006, 11:56 PM #4123Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
I dont really know but maybe you could put in the readme like set psp to power screen off or whatever after so and so minutes.
Zitat von Yongobongo
If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
Gold donations are highly appreciated!
-
11-15-2006, 06:08 AM #4124QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
What about that button right there that does it by itself?
-
11-15-2006, 06:19 AM #4125Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
umm, i think it would be easier for the user to just press the brightness key then press multiple buttons. besides, no homebrew so far has the need to go to extreme measuers just to "save" power. so unless youre makeing another halo, this is pretty much un-needed.
Zitat von Yongobongo
--------------------------------------------------------------------------------------
-
11-15-2006, 08:28 AM #4126QJ Gamer Silver
- Registriert seit
- Oct 2006
- Ort
- 貴方
- Beiträge
- 1.159
- Points
- 7.371
- Level
- 57
- Downloads
- 0
- Uploads
- 0
can sombody help me with my second program in Lua i made it based on the tutorial
it keeps coming up with an error
here it is
http://www.megaupload.com/?d=B9VYWJSZ
-
11-15-2006, 08:41 AM #4127Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
still here!!!
--------------------------------------------------------------------------------
Still got my q over here
its still not working
Ok heres part of my code here
Quote:
if pad:r() then
computer = math.random(3,5)
end
but the problem is as soon as i press r my pic goes away and the variable returns to its orginal state. how can i make it so that one press of r and boom the pic stays blitted and the variable stays at the random selection. also i tried holding r and since its random it doesnt work it just keeps changing.
when i hold down r it keeps doing generating the random numbers. how can i make it so that once i hold down r it gets that number and sticks with it until r is let go???? HELP plz im soo close to v0.2 i even have a menu this stupid random thing is killin me.
__________________If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
Gold donations are highly appreciated!
-
11-15-2006, 01:56 PM #4128I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
You have to use the oldpad method.
Zitat von GuitarGod1134
if pad:r() and oldpad:r() ~= pad:r() then
computer = math.random(3,5)
endGeändert von Access_Denied (11-15-2006 um 02:14 PM Uhr)

-
11-15-2006, 02:38 PM #4129Designs

- Registriert seit
- Jul 2006
- Ort
- Canada
- Beiträge
- 1.395
- Points
- 14.040
- Level
- 76
- Downloads
- 0
- Uploads
- 0
i want a collision with the bullet and the spot1 spot2 spot3 spot4, i have tried over 60 times differant things it wont work, so here is the 2 file, bullet.ua and index.lua, as they work right now with no collision so the bullet does nothing but shoot
Code:function bulletInfo() bullet = Image.load("Bullet.png") currentBullet = 0 direction = "right" BulletInfo = {} for a = 1,5 do BulletInfo[a] = { pic = bullet , firing = false, direction = "right", x = spot.x + 32, y = spot.y + 16 } end function bulletSetup() if currentBullet < 5 then currentBullet = currentBullet + 1 else currentBullet = 1 end if direction == "right" then BulletInfo[currentBullet].x = spot.x + 32 BulletInfo[currentBullet].y = spot.y + 16 end BulletInfo[currentBullet].direction = direction BulletInfo[currentBullet].firing = true end 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 screen:blit(BulletInfo[i].x,BulletInfo[i].y,BulletInfo[i].pic) 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 endCode:red = Color.new(255,0,0) blue = Color.new(0,0,255) green =Color.new(0,255,0) white = Color.new(255,255,255) speed = 100 score = 0 level = 1 obst1 = Image.load("enemy1.png") obst2 = Image.load("enemy2.png") obst3 = Image.load("enemy3.png") obst4= Image.load("enemy4.png") car = Image.load("play.png") oldpad = Controls.read() dofile("Bullet.lua") bg = Image.load("bg.png") bullet = Image.load("bullet.png") System.usbDiskModeActivate() spot = {x = 10, y = 30, height = car:height(), width = car:width() } spot1 = {x = 110, y = 120, height = obst1:height(), width = obst1:width()} spot2 = {x = 130, y = 250, height = obst2:height(), width = obst2:width()} spot3 = {x = 360, y = 250, height = obst3:height(), width = obst3:width()} spot4 = {x = 470, y = 170, height = obst4:height(), width = obst4:width()} function collisionCheck(object) if (spot.x + spot.width > object.x) and (spot.x < object.x + object.width) and (spot.y + spot.height > object.y) and (spot.y < object.y + object.height) then speed = speed - 1 end end bulletInfo() bgy = 0 while true do oldinput = input input = Controls.read() if input:select() then break end screen:clear() pad = Controls.read() score = score + 1 if score>=500 and score<=500 then level = level + 1 / 1 end if score>=1100 and score<=1100 then level = level + 1 / 1 end if score>=1600 and score<=1600 then level = level + 1 / 1 end bgy = bgy - 2 if bgy<=-482 then bgy = 0 end if bgy>1 then bgy = bgy - 481 end collisionCheck(spot1) collisionCheck(spot2) collisionCheck(spot3) collisionCheck(spot4) if pad:up() and spot.y > 1 then spot.y = spot.y - 5 end if pad:down() and spot.y < 270 then spot.y = spot.y + 5 end if pad:cross() then spot1.x = spot1.x - 6 spot2.x = spot2.x - 6 spot3.x = spot3.x - 6 spot4.x = spot4.x - 6 bgy = bgy - 5 end spot1.x = spot1.x - 3 spot2.x = spot2.x - 3 spot3.x = spot3.x - 3 spot4.x = spot4.x - 3 if spot1.x < 0 then spot1.x = math.random(480,520) spot1.y = math.random(20,252) end if spot2.x < 0 then spot2.x = math.random(480,520) spot2.y = math.random(20,252) end if spot3.x < 0 then spot3.x = math.random(480,520) spot3.y = math.random(20,252) end if spot4.x < 0 then spot4.x = math.random(480,520) spot4.y = math.random(20,252) end screen:blit(bgy,0,bg) screen:blit(bgy+bg:width(),0,bg) screen:blit(spot1.x,spot1.y,obst1) screen:blit(spot2.x,spot2.y,obst2) screen:blit(spot3.x,spot3.y,obst3) screen:blit(spot4.x,spot4.y,obst4) screen:blit(spot.x,spot.y,car) if pad:circle() and oldpad:circle() ~= pad:circle() then bulletSetup() end bulletFire() if score>=500 and score<=600 then screen:print(220,150,"LEVEL UP",red) end if score>=1100 and score<=1200 then screen:print(220,150,"LEVEL UP",red) end if score>=1600 and score<=1700 then screen:print(220,150,"LEVEL UP",red) end screen:print(220,0,"Level: "..level,red) screen:print(0,0,"plane health: "..speed,red) screen:print(380,0,"score: "..score,red) screen.waitVblankStart() screen.flip() oldpad = pad end
-
11-15-2006, 02:41 PM #4130QJ Gamer Green
- Registriert seit
- Aug 2006
- Ort
- Cross Country Course
- Beiträge
- 794
- Points
- 6.863
- Level
- 54
- Downloads
- 0
- Uploads
- 0
What does the error message say?
Zitat von cheese the psp
never mind.
Right off the bat I found an error. When you where putting in you colors you did not capitalize the c.
This is what you put:
black = color.new(0, 0, 0)
What it needs to be:
black = Color.new(0, 0, 0)
-
11-15-2006, 02:52 PM #4131Designs

- Registriert seit
- Jul 2006
- Ort
- Canada
- Beiträge
- 1.395
- Points
- 14.040
- Level
- 76
- Downloads
- 0
- Uploads
- 0
can someone help me on my problem 100k reward ;)

-
11-15-2006, 03:13 PM #4132
Yoyomacy can you send me the all the script/image.
Free Prizes at Prizerebel Join us!
I already got 11 Gifts. Ask me for details or proof.
-
11-15-2006, 03:13 PM #4133Designs

- Registriert seit
- Jul 2006
- Ort
- Canada
- Beiträge
- 1.395
- Points
- 14.040
- Level
- 76
- Downloads
- 0
- Uploads
- 0
that is the entire script, look at the page before this
Zitat von ZereoX

-
11-15-2006, 03:16 PM #4134I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
He wants the images to test the code. It would make it easier for me too.
Zitat von yoyomacy

-
11-15-2006, 07:29 PM #4135Designs

- Registriert seit
- Jul 2006
- Ort
- Canada
- Beiträge
- 1.395
- Points
- 14.040
- Level
- 76
- Downloads
- 0
- Uploads
- 0
sent. ok anyone else?
-= Double Post =-
ok. 500k if anyone does it (and works.)Geändert von yoyomacy (11-15-2006 um 07:29 PM Uhr) Grund: Automerged Doublepost

-
11-15-2006, 07:59 PM #4136Developer

- Registriert seit
- Jul 2006
- Beiträge
- 205
- Points
- 4.318
- Level
- 41
- Downloads
- 0
- Uploads
- 0
Not too much different from what you were doing:
Not tested of course.Code:function bulletcollision(object) for i = 1,5 do if BulletInfo[i].firing then if (BulletInfo[i].x + BulletInfo[i].pic:width() > object.x) and (BulletInfo[i].x < object.x + object.width) and (BulletInfo[i].y + BulletInfo[i].pic:height() > object.y) and (BulletInfo[i].y < object.y + object.height) then screen:print(100,100,"BAM!",white) screen.waitVblankStart(6) end end end end bulletcollision(spot1) bulletcollision(spot2) bulletcollision(spot3) bulletcollision(spot4)
The function can go anywhere outside of your while loop, and the function calls go inside, probably right after the bulletFire() call near the bottom. You didn't specify what should happen if the bullets collide with the objects. :)
-
11-15-2006, 08:11 PM #4137Designs

- Registriert seit
- Jul 2006
- Ort
- Canada
- Beiträge
- 1.395
- Points
- 14.040
- Level
- 76
- Downloads
- 0
- Uploads
- 0
I LOVE YOU, IT WORKED THE FIRST TIME, 500k FOR YOU~!!!!!!!
Zitat von LMelior

-
11-15-2006, 08:17 PM #4138Developer

- Registriert seit
- Jul 2006
- Beiträge
- 205
- Points
- 4.318
- Level
- 41
- Downloads
- 0
- Uploads
- 0
Wow, thanks...you just multiplied my points by a factor of 100! :Jump:
Zitat von yoyomacy
-
11-15-2006, 08:20 PM #4139Designs

- Registriert seit
- Jul 2006
- Ort
- Canada
- Beiträge
- 1.395
- Points
- 14.040
- Level
- 76
- Downloads
- 0
- Uploads
- 0
now you can get 300k

-
11-15-2006, 08:22 PM #4140QJ Gamer Silver
- Registriert seit
- Oct 2006
- Ort
- 貴方
- Beiträge
- 1.159
- Points
- 7.371
- Level
- 57
- Downloads
- 0
- Uploads
- 0
i need help with my new program
it isnt loading the images it keeps coming up with an eror what am i doing wrong
System.usbDiskModeActivat e()
white = Color.new(255, 255, 255)
background = Image.load("images/menu.png")
November = Image.load("images/nov.png")
December = Image.load("images/dec.png")
January = Image.load("images/jan.png")
Febuary = Image.load("images/feb.png")
March = Image.load("images/mar.png")
April = Image.load("images/apr.png")
May = Image.load("images/may.png")
June = Image.load("images/june.png")
July = Image.load("images/july.png")
August = Image.load("images/aug.png")
September = Image.load("images/sept.png")
screen:blit(0, 0, background, false)
screen.waitVblankStart()
screen.flip()
while to do
screen:blit(0, 0, background, false)


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