mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2024-11-25 09:44:02 +00:00
Updated entity scripting (markdown)
parent
05fcd27cae
commit
538cb79023
1 changed files with 6 additions and 1 deletions
|
@ -24,7 +24,7 @@ Interface functions are called by the game to notify an entity of certain events
|
|||
Most of them are optional; the game will try to call it and if that doesn't work, it remembers that and won't call the same function again.
|
||||
|
||||
Beware! This means that if your interface function throws an error, it will be considered non-existent and never called again for the entity that caused the error. This is probably not what you want, so have an eye on the error log and fix your code if that happens.
|
||||
If you get errors like `jellysmall : Attempt to call a nil value (???:0) animationKey` this is usually the normal clutter that appears when an interface function isn't defined.
|
||||
If you get errors like `jellysmall : Attempt to call a nil value (???:0) animationKey` this is usually the normal clutter that appears when an interface function (in this case `animationKey`) isn't defined.
|
||||
|
||||
## List of interface functions
|
||||
|
||||
|
@ -36,10 +36,15 @@ Called once when an entity is spawned. Usually used to set health, textures, att
|
|||
When a map is loaded, all scripted entities on the map have their `init()` function called.
|
||||
When an entity is spawned dynamically while the map is already going, `init()` is called the same way.
|
||||
|
||||
_Warning_: Do not spawn or delete entities in `init()` as this may lead to problems. Use `postInit()` for that.
|
||||
|
||||
### `function postInit(me)`
|
||||
|
||||
Useful to set properties that depend on other entities being already inititalized.
|
||||
When a map is loaded, all entities' `init()` is called first, _then_ all entities' `postInit()` is called.
|
||||
When an entity is spawned dynamically while the map is already going, `init()` is called first, and `postInit()` immediately afterwards.
|
||||
|
||||
_Compatibility note_: `postInit()` is not called when an entity is spawned via an [[SE-node|nodes]].
|
||||
|
||||
### `function update(me, dt)` __[mandatory]__
|
||||
|
||||
|
|
Loading…
Reference in a new issue