VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Add Script Variable (addScriptVariableGui)

Table of Contents

The Add Script Variable example demonstrates the following:

Adding a New Lua Script Variable

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 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).
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.

How to Run the Example

Usage

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 view the new behavior:

  1. Start VR-Forces GUI and SIM.
  2. Create a new Scenario - e.g. EntityLevel SMS on Ground_DB II terrain.
  3. Create a new scripted task. Scripted tasks are accessed from the Simulation menu item - Simulation -> Scripts... Press New Script button within the Scripts dialog..
  4. Add a new task parameter of 'Boolean List' scripted variable type.
  5. Set a script Name and Edit the lua script for the scripted task
  6. 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
    

  7. Press Add button within the Scripts dialog to add the new scripted task.
  8. Close both the Edit script and the Scripts dialogs.
  9. Create a new entity, bring up the entity information dialog and set the notify level to Warn.
  10. Task the entity to perform the new scripted task and add a few boolean values to the 'Boolean List' task parameter.
  11. The entity information dialog and the back-end console window should display the boolean values

Classes

DtScriptedTaskRwBooleanListVariableConverterThe variable converter that converts to/from scripted task variable.
DtBooleanListEntryWidgetThe variable converter that converts to/from scripted task variable.

Plugin Entry Points

/*******************************************************************************
** Copyright (c) 2011 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
//\file plugin.cxx
//\brief Contains plugin function
//This file defines the generic DT_DLL_VRF_PLUGIN_EXPORT_MACRO. Use that macro when
//you want to export symbols. Also, in your CMakeLists.txt file, make sure to
//define the VRFPLUGIN_EXPORTS define to tell the compiler to define the macro as an
//export
#include "../addScriptVariableSim/booleanListConverter.h"
{
return true;
}
{
return true;
}
{
info.pluginName = "Add Script Variable Gui";
info.pluginVersion = "1.00";
info.pluginDescription = "Front-end plugin addition to add new boolean list script variable";
info.pluginCreator = "MAK Technologies";
info.pluginCreatorEmail = "sales@mak.com";
info.pluginContactWebPage = "www.mak.com";
info.pluginContactMailingAddress = "10 Fawcett Street, Suite 204, Cambridge, MA 02138 USA";
info.pluginContactPhone = "(617) 876 8085";
}

Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)