
<a href="https://gist.github.com/goblinHordes/6894527" rel="nofollow">https://gist.github.com/goblinHordes/6894527</a> CommandTokens Associate tokens to API functions and trigger functions when the token is moved. CommandTokens provide an easy way to trigger API functions without typing or complicated layer manipulation by the GM. CommandTokens are powered through an ugly-but-effective naming convention: __[function]_(:[variable_1]:[variable_2]...)__ where [function] is the function to call and the [variable_x] elements are replaced by a colon delimited list of parameters to pass to the function. Parameters are optional (as long as the underlying function is ok with that) and do not require a trailing colon. Functions are indirect - they require registration in the script, tying a function name to a real or anonymous API function. A very simple example is included in the code: ctRegister("ctTogglePositionLock", ctTogglePositionLock) ctRegister is a registered virtual function that will toggle the position lock for CommandTokens by calling the real function ctTogglePositionLock. Moving or rotating a CommandToken causes it to trigger its associated function. Since there is an abstraction between the actual function called and the CommandToken virtual function, all parameters are passed as a single array and require parsing by the receiving function. As long as CT_POSITION_LOCK == true, all CommandTokens are locked in their current position and rotation. The ctTogglePositionLock function can be used to disable the position lock for moving tokens. You can also deactivate a specific token by prepending its name with a semicolon: ;__ctTogglePositionLock__