Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

ScriptController

The ScriptController enables to control the movement of a controllable entity via a LUA-script.

The Process

There are two important new classes. The ControllerDirector class and the ScrpitController class.

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

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.

Within every clockcycle the ScriptController's tick function checks if the time to execute the first event in the vector has come yet. After an event has been executed, it is erased from the vector.

Last modified 10 years ago Last modified on May 22, 2014, 1:55:42 PM