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 

Assign a function to a Table???

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



Joined: 04 Mar 2006
Posts: 14
Location: Computer Chair

PostPosted: Wed Mar 08, 2006 3:31 am    Post subject: Assign a function to a Table??? Reply with quote

Well... Hello my fellow PSP Lua coders... OK so I know it's posible to create a table with a function, I just don't know exactlly how to do what I need to do, which is:
1. I am creating a ScrollingCanvas table and I want to assign the function 'Move' to the table, to move the picture(canvas) around the screen using the tables position data (X, Y).
2. The question for you is: How do I create the table, so I can call the move method like this:
Code:
AScrollingCanvas:Move(X, Y)


Please Help.

PS. If I didn't give enough information, plz just PM me.
Back to top
View user's profile Send private message Yahoo Messenger
KawaGeo



Joined: 27 Aug 2005
Posts: 191
Location: Calif Mountains

PostPosted: Wed Mar 08, 2006 4:07 am    Post subject: Reply with quote

Code:

function foo()
  print "foo"
end

function bar()
  print "bar"
end

my = {f=foo, b=bar} -- by named keys

my.f()
my.b()

-- OR

my = {foo, bar}     -- by indices

my[1]()
my[2]()

Is this what you wanted to know?
_________________
Geo Massar
Retired Engineer
Back to top
View user's profile Send private message Send e-mail
CT_Bolt



Joined: 04 Mar 2006
Posts: 14
Location: Computer Chair

PostPosted: Wed Mar 08, 2006 5:34 am    Post subject: Not quite... Reply with quote

Well... I actually knew how to do that(I have pretty good knowledge of Lua now) but, Thank you for replying.

The basic difference between what you have showed me and what I mean is I need to use values from 'AScrollCanvas' ( X & Y ) and then change them accordingly (change only the current table's X & Y values).

Although I might use that way, do you understand what I mean now?

Oh B-T-W Thanks anyway for you're help!!!
Back to top
View user's profile Send private message Yahoo Messenger
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