View Full Version : Objectreferenz to itself

02 February 2004, 12:37 PM
I'm still working with MAX 3.1 and want to check out the scripting language.
But I have still a beginner problem:
How do I reference to my object as in javascript self, this

like: this.pos.x

I don't wanna use its name.


02 February 2004, 04:48 PM
you can use $ to get the currently selected object(s), so $.pos.x gives you the x pos of the current object. but this will not work in scripted controllers as far as i know.

02 February 2004, 08:29 AM
Yepp .. It works, but $ is like 'root'. So if you have more than one object it doesn't work.

I wanna make a script were the color of an object depends on it's position. But I can't use something like $object01.pos.x because when I duplicate it the second objekt have it's color from object01, what is wrong.
And I have to copy a lot of ;)

Is there any other way ?

02 February 2004, 07:48 PM
if i understand you correctly, then you will need a loop that goes through each object:

objList = getCurrentSelection()
for obj in objList do
xpos = obj.pos.x

what this does is, in the first line gets the currently selected objects and puts them into a list. the for-loop will now do the following commands for every object in the objectlist, where obj is a reference to the object.

hope this helps you...

02 February 2004, 08:29 AM
THX .. I'll give it a try :)

P.S. You are still from the Gothic + GothicII team.
Best game forever !! ;) ;)

02 February 2004, 03:57 PM
hehe, yes, thank you :) and currently working with high speed on the third part, which will be totally awesome, of course :buttrock:

CGTalk Moderation
01 January 2006, 11:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.