-
Notifications
You must be signed in to change notification settings - Fork 0
Hooks
Hooks are functions to call after some events happens. Defined with cr.hook() function.
Usage:
cr.hook("<event>", function(args...)
-- some action
end)These events does not take any argument and does not return a value.
-
start: Runned before everything and main menu. -
reload: Runned when plugins are reloaded. -
draw: Runned aftercr.draw_cards(). -
level_gen: Runned aftercr.generate_levels() -
after_refresh: Always runned after UI refresh. -
before_refresh: Always runned before UI refresh. -
game_start: When a new game starts. -
game_end: When a game ends. -
die: Runned when player dies. -
ending: Runned when player finds Amulet of Yendor.
These events takes arguments in varius types and may return a bool value.
Runned when a key pressed on main game loop.
No return type. Takes an integer argument: the key pressed.
Handle the key with string.char() and string.byte() functions, and cr.curses.KEY_ variables.
Runned when exit gate found.
No return type. Takes an integer argument: current level index.
Runned when a slot picked.
Has bool return type: if true, slot will be skipped for now. Takes an integer argument: slots number (1, 2, 3)
Runned when user wants to use an item.
Has bool return type: if true, using item is canceled. Takes an shared card argument: the item used.
Runned when cr.basic_card_event called.
Has bool return type: if true, card event is canceled. Takes following arguments:
- Shared card : the card
- integer : extra damage value
-- show a log
cr.hook("start", function()
cr.log("This log is added before everything")
end)
-- handle keyboard
cr.hook("key", function(key)
if key == 27 then
cr.log("pressed ESC")
elseif key == cr.curses.BACKSPACE then
cr.log("pressed backspace")
elseif key == string.byte("a") then
cr.log("pressed a")
end
end)
-- disable cr.stat.slot1
cr.hook("slot", function(slot_id)
if slot_id == 3 then
return true
end
return false
end)Runned after a save loaded (s_load) or created/updated (s_save).
No return type. Takes 1 string argument: save data as json.
Example save data:
{
"_filepath": "/home/melon/.local/share/crogue/saves/7992049797823664169_1786440919.json",
"created_with_plugins": {
"test": "local",
"vanilla": "https://codeberg.org/HasanAgitUnal/CROGUE-Vanilla.git"
},
"hp": 100,
"inventory": [
"vanilla:teleporter",
"vanilla:apple",
"vanilla:apple",
"vanilla:apple",
"vanilla:apple",
null,
null,
null,
null,
null
],
"last_played": 1786440919,
"level": 1,
"name": "No name",
"plugins_changed": false,
"seed": 7992049797823664169
}-
Getting Started
-
Metadata
-
Variable Types and Variables
-
Game Status
-
TUI