Page 1 of 1
refer to self (this)
Posted: 18 Feb 2012 06:38
by nikisoko
Is there a way to refer to the object that a script is acting on? What I mean is if I'm doing something like the following:
round(x*getattribute(MultiSlider, 'nbr'))
I would like to change MultiSlider to something like 'this' or 'self' so that I don't have to go in and edit the script every time I make change the name of the object or make a copy of the object.
Thanks,
-Nick
Re: refer to self (this)
Posted: 18 Feb 2012 09:20
by Macciza
Hi
I think you want 'getobject()' passing nothing as the argument returns the enclosing object , ,
Use it by declaring something like
decl this = getobject();
out = round(x*getattribute(this, 'nbr'));
Can also be used to get/store references to any object
An implicit 'this' function has also been requested on the wishlist from memory . . .
Cheers
MM
Re: refer to self (this)
Posted: 19 Feb 2012 02:03
by nikisoko
that works! thanks!
Re: refer to self (this)
Posted: 21 Feb 2012 14:20
by analog604
Thanks for asking about this Nick i've been asking myself how to do this, but have just moved on and continued working.
Macciza thank you sir for the answer! I remember someone asking for a ob ref 'this' as well.
Macciza wrote:Hi
I think you want 'getobject()' passing nothing as the argument returns the enclosing object , ,
Use it by declaring something like
decl this = getobject();
out = round(x*getattribute(this, 'nbr'));
Can also be used to get/store references to any object
An implicit 'this' function has also been requested on the wishlist from memory . . .
Cheers
MM