This document is a draft! It's not complete!
In this tutorial we explain a few mechanisms of yake::ent and illustrate them using the Lua based scripting plugin.
The following is a list of built-in events which are integral to yake::ent:
Lua
In this example we create a custom event “TimeToDie” in the “onSpawned” event handler. This event callback is called right after the entity has been created and initialised.
events = {
onSpawned = function()
{
theEntity:createEvent("TimeToDie");
}
}
Lua:
Let's fire the event in Lua:
theEntity:fireEvent("TimeToDie");
This instruction can be used in any event handler or other Lua function in entity scripts.
Lua:
events = {
onTimeToDie = function()
{
console.outLn("Dying...");
}
}
C++:
// Using signals: // CODE TO COME // Using derived callback object: // CODE TO COME
States and some events are synchronized between servers and clients. The actual entity code between server and client may differ.
Use the same Lua code for clients and server:
events = {
onSpawn = function() {
}
}
Seperate code for clients:
events = {
client = {
onSpawn = function() {
}
}
}
DESCRIPTION TO COME.