 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
liquid8d
Joined: 30 Jun 2005 Posts: 66
|
Posted: Sat Aug 27, 2005 7:43 am Post subject: strange table.. or is it just me? |
|
|
Not quite sure what is going on here.. I have looked over the lua tutorials on tables, and it seems to me like this should work, so here goes:
| Code: |
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 |
|
| Back to top |
|
 |
Shine
Joined: 03 Dec 2004 Posts: 728 Location: Germany
|
Posted: Sat Aug 27, 2005 8:13 am Post subject: |
|
|
| BottomRight is undefined. |
|
| Back to top |
|
 |
liquid8d
Joined: 30 Jun 2005 Posts: 66
|
Posted: Sat Aug 27, 2005 8:27 am Post subject: |
|
|
son of a %@#% .. I don't know how you guys continue to answer everyones questions, including stupid ones like that, and continue to work on your project :) Keep it up :)
MY BAD.
LiQuiD8d |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|