A set of events that can be listened for using the Event
module.
local Event = ELONA.require("core.Event")
local function my_chara_moved_handler(e)
local chara = e.chara
-- your code here
end
Event.register("core.character_moved", my_chara_moved_handler)
core.game_initialized | Fired after the game has finished initially loading. |
core.character_created | Fired after a character has been initially created (but not loaded from a savefile). |
core.item_created | Fired after an item has been initially created (but not loaded from a savefile). |
core.character_removed | Fired after a character is no longer valid for use inside scripts. |
core.item_removed | Fired after an item is no longer valid for use inside scripts. |
core.character_refreshed | Fired after a character is refreshed. |
core.calc_character_damage | Fired before a character is damaged. |
core.character_damaged | Fired after a character is damaged. |
core.character_killed | Fired after a character was killed. |
core.character_moved | Fired when a character is about to start moving. |
core.player_turn_started | Fired when a player's turn has just started. |
core.all_turns_finished | Fired when all characters have finished their actions this turn. |
core.map_initialized | Fired after a map has been initialized. |
core.before_map_unload | Fired before the current map is unloaded. |
core.all_mods_loaded | Fired when all mods have finished loading. |
core.script_loaded | Fired when the startup script finished loading. |
core.script_loaded | Fired when a nefia is created. |
Fired after the game has finished initially loading.
This will only ever be fired once per game session. The starting map will be initialized before this is called.
Fired after a character has been initially created (but not loaded from a savefile).
Event Parameters:
Fired after an item has been initially created (but not loaded from a savefile).
Event Parameters:
Fired after a character is no longer valid for use inside scripts.
Event Parameters:
Fired after an item is no longer valid for use inside scripts.
Event Parameters:
Fired after a character is refreshed.
This means various attributes like speed are recalculated. Also, intrinsic character flags (the first 32) will be automatically set from their prototype definitions on refresh. This means that if you want to set a character's intrinsic flag, you have to do so on this event.
Event Parameters:Fired before a character is damaged.
You can change the amount of
damage taken by modifying amount
.
Fired after a character is damaged.
Event Parameters:
Fired after a character was killed.
This might not remove the character, because they might revive at some later time (like NPCs in towns). As such, you shouldn't remove the character's data from global storage here.
Event Parameters:Fired when a character is about to start moving.
Event Parameters:
local GUI = ELONA.require("core.GUI")
local Event = ELONA.require("core.Event")
local function my_chara_moved_handler(e)
GUI.txt("The character " .. e.chara.name .. " is about to move. ")
end
Event.register("core.character_moved", my_chara_moved_handler)
Fired when a player's turn has just started.
Fired when all characters have finished their actions this turn.
Fired after a map has been initialized.
Event Parameters:
local Chara = ELONA.require("core.Chara")
local Event = ELONA.require("core.Event")
local Map = ELONA.require("core.Map")
local function place_characters()
for i=0, 50 do
local pos = Map.random_pos()
Chara.create(pos, "core.putit")
end
end
Event.register("core.map_initialized", place_characters)