Overview (MAS Script Effect) |
Print Previous Next |
Introduction The MAS Script effect provides the potential to create your own light effects. If you want to create a completely new effect MADRIX does not offer, this is the right place for you offering numerous functions. Basically, the MAS Script effect is an effect like any other effect in MADRIX, except that it interprets a script written in MADRIX Script to calculate the effect. In this way, the MAS Script effect has full control over the effect matrix. It is called continuously to render the effect onto the matrix. A script of the MAS script effect can also manipulate the effect speed in order to let the effect run slower or faster, for example. It was already mentioned that scripts are stored as part of the effect. This means that they are part of a stored effect or setup. Moreover, it is possible to save scripts as separate files. The extension of a script for the MAS script effect is *.mas. The extension of a compiled script is *.macs. Remember the MAS Script effect is an usual effect of MADRIX. For that reason, its result can be controlled and manipulated by a macro like all the other effects. The MAS Script Effect is a normal effect of MADRIX and can be selected from the effect list like all the other effects.
There are several functions called by MADRIX in order to let the script react to different events.
If a function is not needed by a script, it is not necessary to implement it. Regarding InitEffect and RenderEffect a message is printed out if one of them is missing. This is not an error, but only an information for the developer of the script. InitEffect (automatically included in a new script) InitEffect is called by MADRIX whenever the script needs to be initialized. This is the case after compiling and starting a new script or when the user pressed the "Start" button of the Script Editor. A script can assume that any global variable is initialized with 0 and that any global field is empty as long as it has not been initialized with any value. This function is the right place to initialize global variables, reset any fields, set the speed of an effect, or whatever is necessary to (re)start the script. RenderEffect (automatically included in a new script) This function is called whenever the effect needs to be rendered. The number of calls per second depends on the currently set speed of the effect. It can be received with the help of the function GetSpeed() and set with the function SetSpeed. This is the right place to calculate the effect and draw it onto the matrix. MartrixSizeChanged (automatically included in a new script) MatixSizeChanged is called after the size of the matrix has been changed. This may be due to a change to the matrix settings or because a new map setting was set, e.g. caused by the call of a map function.
Standard Outline A newly created macro for an effect will look like this: @scriptname=""; @author=""; @version=""; @description="";
void InitEffect() {
}
void RenderEffect() {
}
void MatrixSizeChanged() { InitEffect(); }
|