Lua - self? I kind of sort of understand "self"...

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Lua - self? I kind of sort of understand "self"...

Post by heyvern »

There are several tables that hold all the bone info. Just trying to figure out how they are used in the two separate copy/paste scripts so I can combine them.

I finally got my script working except none of the bone attributes are being applied at the end... I think because of this incorrect reference to the big table with all the stuff in it. I don't get an error so I think there are two tables being created with the same name.

For instance:

Code: Select all

self.pasteOptions
and

Code: Select all

HV_PasteBones.pasteOptions
I know that originally the the name of the table variable was needed to be accessed and used by the second paste script. Everything happens in one script now.

Is this the same thing? I need to create new bones on a layer from the table and then apply the attributes copied from the other layer from this same table to the new bones.

If the table itself is used both for copying and pasting do I need to use "self" at all?

I will probably figure this out 5 minutes after posting... but it gets my brain rolling to write it down.

-vern
User avatar
Rasheed
Posts: 2008
Joined: Tue May 17, 2005 8:30 am
Location: The Netherlands

Post by Rasheed »

Please, carefully read chapter 16 of Programming in Lua. This introduces you to the concept of self.

I cannot give good advice at this moment, because I haven't studied beyond chapter 2 yet. I'm a slow learner.
Post Reply