Scripting events in Vanda Engine are functions written in Lua language with specified and reserved names that are executed by Vanda Engine at certain times. Not all objects support all of the introduced events. For example, the camera object supports Init() and Update() events, while the trigger object supports the OnTriggerEnter(otherActorName), OnTriggerStay(otherActorName), and OnTriggerExit(otherActorName) events.
Events are written in the following general form:
function function_name(optional_parameter) end
For example, the Init() event of Vanda Engine in Lua language would be written as follows:
function Init() end
While the OnTriggerEnter(otherActorName) event of Vanda Engine in Lua language would be written as follows:
function OnTriggerEnter(otherActorName) end
In the examples above, the Init() event accepts no arguments, while the OnTriggerEnter(otherActorName) event accepts an argument that is the name of the physics actor entered into the trigger –This name is automatically sent to the event by Vanda Engine.
You have to write your desired code inside the event function. For example, to display a text in the console when the Init() event is called, you can use the following code:
function Init() PrintConsole("\nSample message") end
Below are the objects available in Vanda Engine along with the script events they support:
Button
- OnSelectMouseLButtonDown()
- OnSelectMouseRButtonDown()
- OnSelectMouseEnter()
Main Character
- Init()
- Update()
- OnTriggerEnter(otherActorName)
- OnTriggerStay(otherActorName)
- OnTriggerExit(otherActorName)
Prefab
- Init()
- Update()
- OnTriggerEnter(otherActorName)
- OnTriggerStay(otherActorName)
- OnTriggerExit(otherActorName)
- OnSelect()
Trigger
- OnTriggerEnter(otherActorName)
- OnTriggerStay(otherActorName)
- OnTriggerExit(otherActorName)
Video
- Init()
- Update()
- OnExit()
Other Objects
- Init()
- Update()
In this section, we explain the scripting events supported by Vanda Engine:
- Init Event
- OnExit Event
- OnSelect Event
- OnSelectMouseEnter Event
- OnSelectMouseLButtonDown Event
- OnSelectMouseRButtonDown Event
- OnTriggerEnter Event
- OnTriggerExit Event
- OnTriggerStay Event
- Update Event