Hooks are triggered at a predefined moment. Hooks can come with variables added to a lua table and passed in as a parameter, most values are provided as Type > String and therefore have to be converted to a number, if needed.
If the hook function returns false the hook is automatically removed.
Example:
addHook("onCharacterCreate", function(variables)
game.print(getCharacterData(variables["character"], "extra", "name"))
end)
addHook("onPreTimePassed", function(variables)
addCharacterData("player", "budgetcurrent", "hunger", tonumber(variables["timePassed"]) * -1.5)
end)
Triggers every frame.
Variables: None
Triggers before Assets are loaded.
Variables: None
Triggers after Assets are loaded.
Variables: None
Triggers after a game is started. Triggers after "onPostNewGame" or "onPostLoadGame".
Variables: None
Triggers after the new game window opened.
Variables: None
Triggers after a new game is started.
Variables: None
Triggers before a save game is saved.
Variables: None
Triggers after a save game is saved.
Variables: None
Triggers before a save game is loaded.
Variables: None
Triggers after a save game is loaded.
Variables: None
Triggers after a character is created.
Variables:
Triggers before time is passing.
Variables:
Triggers after time is passing.
Variables:
Triggers after an options is edited.
Variables: None
Triggers when an interaction starts.
Variables:
Triggers when an interaction stops.
Triggers after characters attendance is calculated. Usually when time passes.
Variables:
Triggers after an item is equipped by a character.
Variables:
Triggers after an item is unequipped by a character.
Variables:
Triggers when a location is visited.
Variables:
Triggers when a place is visited.
Variables:
Triggers when a item is "visited".
Variables:
Triggers when an item is added to an inventory.
Variables:
Return Hooks trigger whenever a hooked value is changed. The return value (variables["return"]) can be changed by the hook and is applied after all hooks are executed.
Hooks: "onCharacterExtraSet", "onCharacterSkillSet", "onCharacterAttributeSet", "onCharacterBudgetCurrentSet", "onCharacterBudgetMaxSet", "onCharacterFeatureSet", "onCharacterOutfitSet"
Triggers when a Character Value is set.
Variables:
Triggers when the activities of a character are requested. This usually happens right before the attendance is calculated. The return determines the weight that is used to decide which place the character will attend, most of the times it should be between 0.0 and 1.0.
Variables:
Triggers when characters attendance is calculated. Usually when time passes.
Variables:
Hooks: "onPlaceExtraSet", "onPlaceAssignedSet", "onPlaceSlotSet"
Triggers when a Place Value is set.
Variables:
Triggers when a Resource Value is set.
Variables:
Triggers when a Resource Value is added to.
Variables:
Triggers when a Resource Value is checked against another value.
Variables: