QJ.NET | Videos | Forums | iPhone | MMORPG | Nintendo DS | Wii | PlayStation 3 | PSP | Xbox 360 | PC | Downloads | Contact Us
Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact

QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides

Go Back   QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides > Developers Corner > PSP Development, Hacks, and Homebrew > PSP Development Forum
The above video goes away if you are a member and logged in, so log in now!

lua help thread 2

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 ...

Reply
 
LinkBack Thread Tools
Old 10-22-2005, 11:14 PM   #1

Developer
 
slicer4ever's Avatar
 
Join Date: Jul 2005
Location: everywhere
Posts: 3,357
Trader Feedback: 0
Talking lua help thread 2

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
slicer4ever is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-22-2005, 11:20 PM   #2
 
Join Date: Jul 2005
Location: My house in California where else?!?!?
Posts: 367
Trader Feedback: 0
Default

Quote:
Originally Posted by slicer4ever
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
are you trying to ask help for your background for your PSP? I dont know what question your trying to get at but that was my guess. Is this a picture slideshow question? agh
SlayerX7 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-22-2005, 11:23 PM   #3

Developer
 
slicer4ever's Avatar
 
Join Date: Jul 2005
Location: everywhere
Posts: 3,357
Trader Feedback: 0
Talking

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
slicer4ever is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-23-2005, 01:10 AM   #4
Premium Member
 
Lancer's Avatar
 
Join Date: Sep 2005
Posts: 44
Trader Feedback: 0
Default

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
Edit: Okay, it works now. I can't believe how hard/impossible it is to code something without making an error. Anyway, if there is anything in the code you don't understand, I'd be happy to explain.

Last edited by Lancer; 10-23-2005 at 01:32 AM..
Lancer is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-23-2005, 01:35 AM   #5

Developer
 
slicer4ever's Avatar
 
Join Date: Jul 2005
Location: everywhere
Posts: 3,357
Trader Feedback: 0
Talking

k i'm trying it now thanks
__________________
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
slicer4ever is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-23-2005, 01:37 AM   #6

Developer
 
slicer4ever's Avatar
 
Join Date: Jul 2005
Location: everywhere
Posts: 3,357
Trader Feedback: 0
Talking

[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
thats the part i do not completly understand
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..
slicer4ever is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-23-2005, 02:00 AM   #7
Premium Member
 
Lancer's Avatar
 
Join Date: Sep 2005
Posts: 44
Trader Feedback: 0
Default

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
1: Okay, this function is called readinput and it takes no arguments (arguments are the things you would put in the parenthesis).

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:
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?
All you have to do if you want to add more images is add a Image.load("filename.png" ) command for each picture and put the name of the image (ex: bg1, bg2, etc) in the bglist table in the order you want.

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..
Lancer is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-23-2005, 02:07 AM   #8

Developer
 
slicer4ever's Avatar
 
Join Date: Jul 2005
Location: everywhere
Posts: 3,357
Trader Feedback: 0
Talking

dam my code keeps returnings errors maybe you can help better if i post my code:

Quote:

System.usbDiskModeActivat e()

blue=Color.new(0,0,255)

oldinput = Controls.read()
input = controls.read()
screen:clear()
gun1=Image.load("pics/gun1.png")
gun2=Image.load("pics/gun2.png")
gun3=Image.load("pics/gun3.png")
gun4=Image.load("pics/gun4.png")
gun5=Image.load("pics/gun5.png")
gun6=Image.load("pics/gun6.png")
gun7=Image.load("pics/gun7.png")
gun8=Image.load("pics/gun8.png")
gun9=Image.load("pics/gun9.png")
gun10=Image.load("pics/gun10.png")
gun11=Image.load("pics/gun11.png")
gun12=Image.load("pics/gun12.png")
gun13=Image.load("pics/gun13.png")
gun14=Image.load("pics/gun14.png")
gun15=Image.load("pics/gun15.png")
gun16=Image.load("pics/gun16.png")
gunlist=(gun1)
gunlist=(gun2)
gunlist=(gun3)
gunlist=(gun4)
gunlist=(gun5)
gunlist=(gun6)
gunlist=(gun7)
gunlist=(gun8)
gunlist=(gun9)
gunlist=(gun10)
gunlist=(gun11)
gunlist=(gun12)
gunlist=(gun13)
gunlist=(gun14)
gunlist=(gun15)
gunlist=(gun16)
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(gunlist) then
listpos = listpos + 1
end
oldinput = input
end

function drawgun()
screen:blit(0,0,gunlist[listpos])
screen.flip()
end

while not input:start() do
read:input()
drawgun()
screen.waitVblankStart()
screen:clear()
end

while true do
cotrols.read()
if pad:cross() then break
end
end
__________________
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
slicer4ever is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-23-2005, 02:21 AM   #9
Premium Member
 
Lancer's Avatar
 
Join Date: Sep 2005
Posts: 44
Trader Feedback: 0
Default

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}
Second, the last 5 lines of code you added are useless. My loop starts with "while not input:start() do" which makes the loop repeat until you press start. When you do press start, it will do exactly the same thing as break. If you want, you can replace "input:start()" with "input:cross()" or any other key for that matter (except for left and right, for obvious reasons =P).

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..
Lancer is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-23-2005, 07:30 PM   #10

Developer
 
slicer4ever's Avatar
 
Join Date: Jul 2005
Location: everywhere
Posts: 3,357
Trader Feedback: 0
Talking

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:
System.usbDiskModeActivat e()

blue=Color.new(0,0,255)

oldinput = Controls.read()
input = Controls.read()
screen:clear()
gun1=Image.load("pics/gun1.png")
gun2=Image.load("pics/gun2.png")
gun3=Image.load("pics/gun3.png")
gun4=Image.load("pics/gun4.png")
gun5=Image.load("pics/gun5.png")
gun6=Image.load("pics/gun6.png")
gun7=Image.load("pics/gun7.png")
gun8=Image.load("pics/gun8.png")
gun9=Image.load("pics/gun9.png")
gun10=Image.load("pics/gun10.png")
gun11=Image.load("pics/gun11.png")
gun12=Image.load("pics/gun12.png")
gun13=Image.load("pics/gun13.png")
gun14=Image.load("pics/gun14.png")
gun15=Image.load("pics/gun15.png")
gun16=Image.load("pics/gun16.png")
gunlist= {gun1,gun2,gun3,gun4,gun5 ,gun6,gun7,gun8,gun9,gun1 0,gun11,gun12,gun13,gun14 ,gun15,gun16}
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(gunlist) then
listpos = listpos + 1
end
oldinput = input
end

function drawgun()
screen:blit(0,0,gunlist[listpos])
screen.flip()
end

while not input:start() do
read:input()
drawgun()
screen.waitVblankStart()
screen:clear()
end
end
__________________
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..
slicer4ever is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
lua , thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -8. The time now is 02:53 AM.



Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © 2009, QJ.NET. All Rights Reserved.
Contact Us