Function sets in Script Objects?

About Truespace Archives

These pages are a copy of the official truespace forums prior to their removal somewhere around 2011.

They are retained here for archive purposes only.

Function sets in Script Objects? // Scriptorium

1  |  

Post by Paul_Martinsen // Feb 5, 2009, 1:50pm

Total Posts: 5

I was wondering if there is an equivalent or workaround to use function sets from script objects?

If I create a function set and, in a script object (instead of a script command) use:

var f = Node.AccessNearFnSet('Displacement Engine');

var x = f.Displacement(0);

I get an error message that Node is null. The same code works inside a command object, but I'm using proceedural animation to animate several objects. I was hoping I could use function sets to save duplicating the code for calculating current position in each object (it isn't just a constant that I can link through).

Kind regards


Post by Jack Edwards // Feb 5, 2009, 3:09pm

Jack Edwards
Total Posts: 4062
Hi Paul, you need to use the full path to the Function Set brick.

So if the FnSet was at the same level as the calling object you could use:

var f = Node.AccessFnSet(System.ThisOwner() + '/Displacement Engine');

Post by frootee // Feb 5, 2009, 3:12pm

Total Posts: 2667
Hi Paul.

I do not believe you can call a function set from a script object.

But you could use a script command to call the function set, then use the script command to 'Push' the updated data onto connectors of the script objects.

Script objects execute when their connectors get updated. So, if the script command calls the function set, then updates each script object's connectors using Node.Value(...) = value, you should be able to achieve your desired result.

Post by Jack Edwards // Feb 5, 2009, 3:19pm

Jack Edwards
Total Posts: 4062
Ack. You're right Froo, "Node" is undefined in Script Objects.

Did we every figure out a way to cause something to update on RsTime.CurrentTime() update?

Post by frootee // Feb 5, 2009, 3:51pm

Total Posts: 2667
We use RsTime.SetTime() to set the current animation time: RsTime.CurrentTime()

We can also use RsTime.NextFrame and RsTime.PrevFrame to move in animation time one frame at a time.

So, in a script command, we can use these functions, then access the current time and perform some function, like loading a new Rsobj file, or, even, calling the yafaray exporter which will render the current animation frame.

Post by Jack Edwards // Feb 5, 2009, 6:38pm

Jack Edwards
Total Posts: 4062
Those solutions all *set* the current frame. Still no way for a scripter to make an object that updates to match the current frame -- well other than say using a timer to fire a command script to poll the current frame I guess. But that method would eat up resources and could still lead to jerky animation and possible missed frames if TS gets bogged down.

Hmm... I wonder if there's a way to do it with the SDK. Basically what is needed is a brick that sends out a command pulse every time the current frame (time) changes and also outputs the current frame (time).

Post by trueBlue // Feb 5, 2009, 6:57pm

Total Posts: 1761
Check out the Animation Manager in System. Looks like that is where AnimTime is stored. If you look at the Exp aspect and scrub through an Animation you'll see it update. You should be able to Get/Set AnimTime I would think. is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2020. All Rights Reserved.   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn