Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Version 1 and Version 2 of ~archive/ScriptingHowTo


Ignore:
Timestamp:
Nov 28, 2007, 12:45:43 AM (16 years ago)
Author:
landauf
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • ~archive/ScriptingHowTo

    v1 v2  
    66
    77=== 1.1. The script ===
    8 Every *.lua file is wrapped in a script. A script in orxonox is an object of the class "Script" and this object contains all the data that the script needs. The script is the link between C++ and lua. Whenever a lua function is called from C++, it is the script that actually calls the function. On creation the script loads the file and then parses the loaded file. While parsing everything in the global scope of the script is executed. (If you write io.write("test") in the global scope, then "test" is printed when the file gets loaded). After parsing the script registers the standard classes "SpaceTrigger", "TimeTrigger" and "TickTrigger", so you don't have to register it if you want to use !ScriptTriggers in the script. [[br]]
     8Every *.lua file is wrapped in a script. A script in orxonox is an object of the class "Script" and this object contains all the data that the script needs. The script is the link between C++ and lua. Whenever a lua function is called from C++, it is the script that actually calls the function. On creation the script loads the file and then parses the loaded file. While parsing everything in the global scope of the script is executed. (If you write io.write("test") in the global scope, then "test" is printed when the file gets loaded). After parsing the script registers the standard classes "!SpaceTrigger", "!TimeTrigger" and "!TickTrigger", so you don't have to register it if you want to use !ScriptTriggers in the script. [[br]]
    99Every '''Orxonox object''' has to be scriptable to be used in a script, that is a scriptable_class has to be created for the Orxonox class. Please read the Section "How to make an Orxonox object (C++) scriptable" for further information.[[br]]
    1010
    1111=== 1.2. Scripttrigger ===
    12 Scripttriggers are responsible for calling a function of a script on runtime. When the !ScriptTrigger is triggered it executes the specified function of the Luascript. There are different types of scripttriggers: The '''SpaceTrigger''' calls a script whenever a specified !WorldEntity is in range. The '''TickTrigger''' calls the Script in every tick. The '''TimeTrigger''' calls its Script when a certain amount of time has passed. The '''ActionTrigger''' triggers the script if the player hits the actionkey within its range.[[br]]
     12Scripttriggers are responsible for calling a function of a script on runtime. When the !ScriptTrigger is triggered it executes the specified function of the Luascript. There are different types of scripttriggers: The '''!SpaceTrigger''' calls a script whenever a specified !WorldEntity is in range. The '''!TickTrigger''' calls the Script in every tick. The '''!TimeTrigger''' calls its Script when a certain amount of time has passed. The '''!ActionTrigger''' triggers the script if the player hits the actionkey within its range.[[br]]
    1313
    1414=== 1.3. Scriptmanager ===