Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

ScriptableController

With the ScriptableController you can easily make scripts to control various things in orxonox and react to certain events. To do that, add a script to your level:

<Level script="scripts/myLevelScript.lua" ...> ... </Level>

The script has to be written in lua and will be executed as soon as the player spawns. The path to the script is relative to data/levels and you preferably put your scripts in the scripts folder with the same name as your level. You can find a list of all functions that are available in lua in the documentation of ScriptableControllerAPI in src/orxonox/scriptablecontroller/scriptable_controller_api.h. If you call a function, make sure it has the correct number of arguments, there are no optional arguments at the moment! Also keep the type of the arguments in mind, if the function expects a string, pass it a string and not a number.

Things that could be implemented next in the ScriptableController:

  • Fix the spawning of new objects
  • Notify the scripts when the player respawns
  • Waypoints
  • Firing weapons
  • Setting the orientation with lookAt
  • Cutscene tools
    • Hide/unhide the HUD
    • Enable/disable user controls
    • Move the camera around
  • Register to pickup events
  • Integration of the quest system

Things that need basic knowledge of the lua stack and advanced knowledge of C++ templates:

  • Make it possible to return values from C++ functions to lua or the other way around
  • Make optional arguments possible
  • Add a 'state' argument that can be passed to register* functions and that will be passed back again to lua when the callback gets called (like a 'this', makes it a bit more object oriented and reduces the number of global variables in lua)
Last modified 7 years ago Last modified on Dec 14, 2017, 4:52:12 PM