instancer


Synopsis


module instancer {
int+read+req  Value;
group+nonotify+read+req  *Group;
int+read  active;
};

Description

instancer is used to dynamically change the state of the instanced property on an object.

•      See

You should use this module when you want to dynamically activate or deactivate a portion of your network.If instanced=0, the actual widget is not created resulting in a sometimes substantial performance gain.

Parameters

Value

Specifies the integer value for the instanced property. This value should be 1 or 0. The module runs when this parameter changes. Input port

Group

The value of this parameter specifies the object whose instanced property should be changed. Changing this parameter does not cause this module to rerun. Input port.

active

This integer can be one of three values:

•      0 means do not instance or deinstance the object even if Value changes.

•      1 (the default) means instance the object when Value changes from 0 to 1 and de-instance when values changes from 1 to 0.

•      2 means instance the object when Value changes from 0 to 1 but do not de-instance the object when value changes from 1 to 0.

Example

This example defines a macro that contains a shell. The instancer module attaches the instanced state of the shell to its visibility. When the shell is made visible, it is instanced at the same time. When it is made invisible, it is deinstanced. This example sets the default instanced property on the shell to 0 so that the shell is not instanced initially when the network is instanced.


macro Dialog {
int visible = 0;
GMOD.instancer instancer {
Group => Dialog_shell;
Value => visible;
};
macro Dialog_shell<instanced=0> {
UIshell my_shell {
visible => <-.<-.visible;
};
UIdial my_dial {
parent => my_shell;
};
};
};