Code: Select all
keypadloc = {x = 0, y = 0}
locTopRight = {x = 330, y = 10}
locTopLeft = {x = 10, y = 10}
locBottomRight = {x = 330, y = 122}
locBottomLeft = {x = 10, y = 122}
keypad = Image.load("pad.png")
function drawPad()
screen:blit(keypadloc.x,keypadloc.y,keypad)
end
while true do
pad = Controls.read()
screen:clear()
screen:blit(0,0,bg,false)
if (pad ~= oldPad) then
if pad:start() then
break
end
if pad:l() then
if (keypadloc == locTopLeft) then
keypadloc = locTopRight
elseif (keypadloc == locTopRight) then
keypadloc = BottomRight
elseif (keypadloc == locBottomRight) then
keypadloc = locBottomLeft
else
keypadloc = locTopLeft
end
end
oldPad = pad
end
if (showpad == true) then
drawPad()
end
screen:waitVblankStart(10)
screen:flip()
end
It seems to me that this should work, but what happens is, after I have set the keypadloc to each location, when you set it to one of the locations a second time, it says 'attempt to index global 'keypadloc' (a nil value). Why is it nil all of the sudden? Do you have to copy a table, and not set it equal to? Am I just doing something wrong?
Thanks,
LiQuiD8d