Notifications
Clear all

[Closed] Objectreferenz to itself

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.

THX

5 Replies

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.

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 ?

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…

THX … I’ll give it a try

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

hehe, yes, thank you and currently working with high speed on the third part, which will be totally awesome, of course :buttrock: