forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

strange table.. or is it just me?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
liquid8d



Joined: 30 Jun 2005
Posts: 66

PostPosted: Sat Aug 27, 2005 7:43 am    Post subject: strange table.. or is it just me? Reply with quote

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
View user's profile Send private message AIM Address
Shine



Joined: 03 Dec 2004
Posts: 728
Location: Germany

PostPosted: Sat Aug 27, 2005 8:13 am    Post subject: Reply with quote

BottomRight is undefined.
Back to top
View user's profile Send private message
liquid8d



Joined: 30 Jun 2005
Posts: 66

PostPosted: Sat Aug 27, 2005 8:27 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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