The Lua entities are notified of system and entity events through the engine callback functions. These are optional functions within your Lua entity that will be called automatically. An example of this is the OnUsed()
function, which is called when the player tries to use your entity.
There are a lot of Lua script callbacks defined in CryENGINE that allow you to work more efficiently with your scripts. We have used some of the basic engine callbacks, such as the following, in our example script:
OnReset
OnPropertyChange
OnInit
These three callbacks, for example, are used in almost every Lua entity and make your life a lot easier. OnReset
, for example, is called automatically every time the script is reloaded, while OnPropertyChange
is called whenever you change one of the entity's properties in Sandbox. The OnInit
callback is triggered when the actual game is started or you jump into game mode in Sandbox. Utilizing these callbacks makes it very easy to set up and...