| 1 | = ScriptController = |
| 2 | |
| 3 | The ScriptController enables to control the movement of a controllable entity via a LUA-script. |
| 4 | |
| 5 | == The Process == |
| 6 | |
| 7 | There are two important new classes. The ControllerDirector class and the ScrpitController class. |
| 8 | |
| 9 | The ControllerDirector waits for an event to be triggered by the specified entity and saves a pointer to it. Then the LUA-file is parsed (the game is suspended during this but it doesn't take long). |
| 10 | The LUA-file contains all necessary parameters (the function's name, coordinates, execution time) to create a new event and instantiates a ScriptController object. Inside that object, time (variable: scTime) begins now at zero, all events will be executed relative to this time. |
| 11 | |
| 12 | The ScriptController-object gets its instructions via the eventScheduler function and stores them in a vector of events (struct) in ascending order of their execution time. The LUA part is done now. |
| 13 | |
| 14 | Within every clockcycle the ScriptController's tick function checks if the time to execute the first event in the vector has come yet. |
| 15 | After an event has been executed, it is erased from the vector. |
| 16 | |
| 17 | |