![]() |
| Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact |
| ||||||
This is a discussion on lua help thread 2 within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; will it seems the other help thread has died so i've created a second one and i guess i'll go ...
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 |
![]() ![]() Developer
|
will it seems the other help thread has died so i've created a second one and i guess i'll go first how do i change a picture from one to the next like pressing right changes the picture to a new one but if i want to back it up i just press a certain button and it goes back one pic
p.s. ask for my code if helps and post and lua help needed
__________________
1. Failed....again... 2. http://slicer.gibbocool.com/ stay updated on all my projects |
|
|
|
|
|
#2 | |
![]() |
Quote:
|
|
|
|
|
|
|
#3 |
![]() ![]() Developer
|
yea kind of like a slide show but each time you press the right button it changes to the next pic and if you press left it goes back a pic
__________________
1. Failed....again... 2. http://slicer.gibbocool.com/ stay updated on all my projects |
|
|
|
|
|
#4 |
![]() Premium Member
|
Try this, slicer4ever. I'll test it myself to make sure it works in a second.
Code:
oldinput = Controls.read()
input = Controls.read()
screen:clear()
bg1 = Image.load("bg1.png")
bg2 = Image.load("bg2.png")
bg3 = Image.load("bg3.png")
bglist = {bg1, bg2, bg3}
listpos = 1
function readinput()
input = Controls.read()
if input ~= oldinput then
if input:left() and listpos > 1 then
listpos = listpos - 1
end
if input:right() and listpos < table.getn(bglist) then
listpos = listpos + 1
end
oldinput = input
end
end
function drawbg()
screen:blit(0,0,bglist[listpos])
screen:flip()
end
while not input:start() do
readinput()
drawbg()
screen.waitVblankStart()
screen:clear()
end
Last edited by Lancer; 10-23-2005 at 01:32 AM.. |
|
|
|
|
|
#5 |
![]() ![]() Developer
|
k i'm trying it now thanks
__________________
1. Failed....again... 2. http://slicer.gibbocool.com/ stay updated on all my projects |
|
|
|
|
|
#6 |
![]() ![]() Developer
|
[QUOTE=Lancer]Try this, slicer4ever. I'll test it myself to make sure it works in a second.
Code:
listpos = 1 function readinput() input = Controls.read() if input ~= oldinput then if input:left() and listpos > 1 then listpos = listpos - 1 end if input:right() and listpos < table.getn(bglist) then listpos = listpos + 1 end oldinput = input end end end also i wrote the code and made some variations but i have 16 pics that need to do that so i had it load all 17 than i made my list which started on line 24 and an error came up saying ) expected near , am i supose to have an , while i make the list?
__________________
1. Failed....again... 2. http://slicer.gibbocool.com/ stay updated on all my projects Last edited by slicer4ever; 10-23-2005 at 01:52 AM.. |
|
|
|
|
|
#7 | |
![]() Premium Member
|
Code:
1:function readinput() 2: input = Controls.read() 3: if input ~= oldinput then 4: if input:left() and listpos > 1 then 5: listpos = listpos - 1 6: end 7: 8: if input:right() and listpos < table.getn(bglist) then 9: listpos = listpos + 1 10: end 11: oldinput = input 12: end 13:end 2: Detect what keys im pressing and put them into the varible "input". 3: If the keys we are pressing are the same as the ones in the variable "oldinput" then skip to line 12. If the values are different, then go to line 4. 4: If the left arrow is pressed and our position on the list is greater than 1 then go to line 5. If not, go to line 6. 5: Change our position on the list to 1 less then it is right now. 6: End the if statement on line 4. 7: Spacer to make code look cleaner. 8: If the right arrow is pressed and our position in the list is less than the number of elements in the table "bglist" (in this case, there are 3), then go to line 9. If not, go to line 10. 9: Change our position on the list to one greater than it is right now. 10: End the if statement on line 8. 11: Put the keys we pressed from "input" into "oldinput" (now line 3 will make us skip lines 4-11 until we release the button, making "input" and "oldinput" different). 12: End the if statement on line 3. 13: End the readinput function. Phew, I hope that helped. =P Edit: Quote:
Code:
oldinput = Controls.read()
input = Controls.read()
screen:clear()
bg1 = Image.load("bg1.png")
bg2 = Image.load("bg2.png")
bg3 = Image.load("bg3.png")
bg4 = Image.load("bg4.png")
bg5 = Image.load("bg5.png")
bg6 = Image.load("bg6.png")
bg7 = Image.load("bg7.png")
bg8 = Image.load("bg8.png")
bg9 = Image.load("bg9.png")
bg10 = Image.load("bg10.png")
bg11 = Image.load("bg11.png")
bg12 = Image.load("bg12.png")
bg13 = Image.load("bg13.png")
bg14 = Image.load("bg14.png")
bg15 = Image.load("bg15.png")
bg16 = Image.load("bg16.png")
bg17 = Image.load("bg17.png")
bglist = {bg1, bg2, bg3, bg4, bg5, bg6, bg7, bg8, bg9, bg10, bg11, bg12, bg13, bg14, bg15, bg16, bg17}
listpos = 1
function readinput()
input = Controls.read()
if input ~= oldinput then
if input:left() and listpos > 1 then
listpos = listpos - 1
end
if input:right() and listpos < table.getn(bglist) then
listpos = listpos + 1
end
oldinput = input
end
end
function drawbg()
screen:blit(0,0,bglist[listpos])
screen:flip()
end
while not input:start() do
readinput()
drawbg()
screen.waitVblankStart()
screen:clear()
end
Last edited by Lancer; 10-23-2005 at 02:09 AM.. |
|
|
|
|
|
|
#8 | |
![]() ![]() Developer
|
dam my code keeps returnings errors maybe you can help better if i post my code:
Quote:
__________________
1. Failed....again... 2. http://slicer.gibbocool.com/ stay updated on all my projects |
|
|
|
|
|
|
#9 |
![]() Premium Member
|
Lol, these messages are getting huge. =|
Your script has a couple large problems. First, your "gunlist=(gun#)" commands should have curly brackets instead of parenthesis because gunlist is a table. You also keep reassigning gunlist to different values. The correct way to do it is to put them all in a single table, like this: Code:
gunlist = {gun1,gun2,gun3,gun4,gun5,gun6,gun7,gun8,gun9,gun10,gun11,gun12,gun13,gun14,gun15,gun16}
If you want some more info on tables, look here and then here for a list of commands relating to tables. In fact I suggest you read and understand everything on the wiki here. Last edited by Lancer; 10-23-2005 at 02:27 AM.. |
|
|
|
|
|
#10 | |
![]() ![]() Developer
|
k thanks
i got my code to stop sending errors when ever i start the program but now it says running script at bottom and nutin happens heres my current code: Quote:
__________________
1. Failed....again... 2. http://slicer.gibbocool.com/ stay updated on all my projects Last edited by slicer4ever; 10-23-2005 at 07:36 PM.. |
|
|
|
|
![]() |
| Tags |
| lua , thread |
| Thread Tools | |
|
|