PDA

View Full Version : Local variables in positioncontroller-skript?


kogen
01-19-2007, 11:18 AM
Hello everybody,

Although I'm new to CGTalk, I hope there's someone who would help me.
I guess to start the first posting with a question doesn't look very well, but nevertheless, I'd like to know if it's possible to use loval variables such as those I define in structures within PositionController-Skripts. For example: I've got a structure (just an example):
struct Example
(scircn, sdummy,
sdummy = dummy(),
scircn = circle()
)

and I want to assign a PositionController-Skript to this Circle via Max-Skript, saying, that the Position of this circle depends on the Relation to the Position of the dummy. If the circle reaches a maximum Value, th circle should be stopped.
The problem I'm facing at the moment is, that PositionController-Scripts don't work with the local variable "scircn" within the Structure. Like:

struct Example
(--open structure
scircn, sdummy,
sdummy = dummy(),
scircn = circle()

fn MakeLimit =
(
sdummyn.Position.Controller = ps;
ps.script =
"dependsOn scircn
If scircn.pos.x > 5 then scircn.pos.x = 5
[-5, -5, 0]" –- Dummy position obligatory
)
--close structure)


Everything works well with a global variable or an array instead of a structure. But with a local variable I always get an "IscriptControl::SetExpression"-error and after that an "scircn is undefined"-error in the PositionController-Skript-Panel.

Does anybody know this problem and maybe what I should try or change?

Cheers "ko'gen".

kogen
01-24-2007, 08:58 PM
Hello again,

if someone is interested in the problem: I fixed it myself. The script works fine now. The problem was that I was trying to assign a variable instead of a name of the object. The process of finding out the right combination to enter the name and to use this name, not the variable was terrible. But I've learned that it's not scrpt = "dependsOn var; etc." but scrpt = "dependsOn $'"+var+"'; etc." to use the name of the object var holds as a variable. Very confusing.

But I got another question right now: It is said in the Max-Skript help, that one shouldn't use dependsOn anymore. But it ain't said what one should use instead of dependsOn!?

Could anyone help me?

Cheers "ko'gen".

MerlinEl
01-25-2007, 05:03 PM
i dont uderstud what you exactly go to do but:

struct Example
(--open structure
scircn, sdummy,
sdummy = dummy(),
scircn = circle() --here you mis something --> ,

fn MakeLimit =
(
sdummyn.Position.Controller = ps;
ps.script =
"dependsOn scircn
If scircn.pos.x > 5 then scircn.pos.x = 5
[-5, -5, 0]" –- Dummy position obligatory
)
--close structure)

CGTalk Moderation
01-25-2007, 05:03 PM
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.