Page 1 of 1

Self reference conditional statement

Posted: 16 May 2014 17:26
by worldoftwilights
Hello!

I was wondering if it is possible to have this sort of code:

if(nameoftheobject==banana1) do this
if(nameoftheobject==banana2) do that


this is because I have a cluster of the same object and since i change the code quite a bit, I would love the possibility to just copy and paste another element (which will have a sequential number) and get the result done :)

Hope I made myself clear, let me know.

1000 thanks
Bye for now.
Gio.

Re: Self reference conditional statement

Posted: 18 May 2014 11:52
by Softcore
With this script residing inside an object

Code: Select all

getattribute(getobject(), 'name') 
The name of the object will be returned.

Re: Self reference conditional statement

Posted: 19 May 2014 03:16
by Macciza
Hi
Another option is a variable in each object with the same code - this can then be easily queried from anywhere . . .

More to the point though is where is the code going to run from, what are you wanting to do, what are the other objects etc etc
Code can be structured in numerous ways to achieve the same thing - with varying performance and for various reasons
Encapsulation of objects into containers as modules can help in easing duplication issues

So sorry but no hard and fast answer here - more info needed . . .

MM

Re: Self reference conditional statement

Posted: 26 May 2014 10:27
by worldoftwilights
Softcore wrote:

Code: Select all

getattribute(getobject(), 'name') 
Thanks man! I'll try it ASAP!
Macciza wrote:Hi
Another option is a variable in each object with the same code - this can then be easily queried from anywhere . . .
MM
Thanks Macciza, that's exactly how I've solved it in this moment.

Every object in the cluster has an index variable inside the object and I change only that.
It seems to work smoothly, I'll let you know.

You're right about the lackness of information, but I was asking the question while writing the code, while thinking about the logistics of the interface... Everything was "in the cloud" and I couldn't give more info on that, because I didn't know exactly where I was going with the code :) .


Thanks a lot guys!
See you soon.