![]() |
VR-Forces Developer's Guide
|
The Add Script Variable example demonstrates the following:
The Add Script Variable example shows how to add a new scripted task or set variable to the script system, in this case a boolean list of values. It will show how to add the gui component as well as the component to transfer the data to/from reader/writer variables (which is the foundation of getting this information into lua scripts).
Since this example is loaded as a plugin, it will need to be enabled in the Launcher. In the Launcher, click the Plug-ins button to bring up the Plug-ins Selection dialog. Enable the plugin. To use this example you can load the add script variable toolkit developer example. This example has an entity with a plan that contains a task that uses the new 'Boolean List' variable type in that task. Or, you can create a new scenario with a scenario script that adds the 'Boolean List' variable type to a scripted task. See below on how to recreate the behavior.
To view the new behavior:
In the init method add lua code to loop over the table entries for the new 'Boolean List' variable and printWarn each entry.
myBools = {}
function init()
myBools = table.copy(taskParameters.booleans)
for index,value in pairs(myBools) do
printWarn(value)
end
vrf:setTickPeriod(0.5)
end
| DtScriptedTaskRwBooleanListVariableConverter | The variable converter that converts to/from scripted task variable. |