PDA

View Full Version : whats wrong with my code??



one winged angel
July 11th, 2006, 13:32
im learning lua now and i get an eroow saying: loop in gettable
my code look like this

white=Color.new(255,255,255)
upPressed='You are pressing the "UP" button'
downPressed='You are pressing the "DOWN" button'
leftPressed='You are pressing the "LEFT" button'
rightPressed='You are pressing the "Right" button'
crossPressed='You are pressing the "CROSS" button'
trianglePressed='You are pressing the "TRIANGLE" button'
squarePressed='You are pressing the "SQUARE" button'
circlePressed='You are pressing the "CIRCLE" button'
LPressed='You are pressing the "L" button'
RPressed='You are pressing the "R" button'
while true do
screen:clear()
pad=Controls.read()
if pad:up()then
screen: print(100,100,upPressed,white)
end
if pad:left()then
screen: print(100,100,leftPressed,white)
end
if pad:right()then
screen: print(100,100,rightPressed,white)
end
if pad:up()then
screen: print(100,100,upPressed,white)
end
if pad:down()then
screen: print(100,100,downPressed,white)
end
if pad:L()then
screen: print(100,100,LPressed,white)
end
if pad:R()then
screen: print(100,100,RPressed,white)
end
if pad:cross()then
screen: print(100,100,crossPressed,white)
end
if pad:square()then
screen: print(100,100,squarePressed,white)
end
if pad:triangle()then
screen: print(100,100,trianglePressed,white)
end
if pad:circle()then
screen: print(100,100,circlePressed,white)
end
screen.waitVblankStart()
screen.flip()
end

edit: i know that between : and print no pace come but if a hadnt done it it would look like this screen:print

dalejrrocks
July 11th, 2006, 21:11
put " instead of ' and make it look like this : screen:print . is that all the code? what does the error say exactly?

yaustar
July 11th, 2006, 23:36
if pad:L()then
screen: print(100,100,LPressed,white)
end
if pad:R()then
screen: print(100,100,RPressed,white)
end
should be

if pad:l()then
screen: print(100,100,LPressed,white)
end
if pad:r()then
screen: print(100,100,RPressed,white)
end

Notice the lower case L and R.

MasterChafed
July 12th, 2006, 00:28
you have to remember that lua is always case sensitive. so if you make a variable somthing like Image and later put image, it will think of it as a different variable. or sumtin like that.

dalejrrocks
July 12th, 2006, 02:50
yeah, that's right. that too.

one winged angel
July 12th, 2006, 14:04
thx yaustar now it works

one winged angel
July 15th, 2006, 10:53
i have another question
i want to print a image to the screen if no button is pressed not always just if no button is pressed

one winged angel
July 15th, 2006, 10:55
kind like this:
if pad:nil() then
screen:blit(............)
nil is if no button is pressed

one winged angel
July 15th, 2006, 16:19
yaustar maybe