Save & Load System
Internal functions used by the engine to handle state persistence (Save/Load).
Core Functions
Booktasy.get_game_state()
Serializes the entire game world (rooms, items, entities, custom globals) into a table.
Booktasy.save_initial_state()
Captures the state at init() to allow for restarting.
Booktasy.restore_state(state)
Reconstructs the Lua objects from a saved state table.
Booktasy.serialize(obj)
Helper for recursive table serialization. This is critical for preventing circular reference crashes during saving.
Usage Example
-- Register a global variable for saving
PLAYER_HP = 100
Booktasy.save("PLAYER_HP")
-- Save the game to a slot
-- (Called automatically by the 'save' command)
-- Player types: save 1
-- Load the game from a slot
-- (Called automatically by the 'load' command)
-- Player types: load 1
-- Restart the game
-- (Called automatically by the 'restart' command)
-- Player types: restart
Best Practices
- Always register global variables you want to persist using
Booktasy.save(var_name) - Call
Booktasy.save_initial_state()at the end of yourinit()function - Test your save/load functionality early in development
- Be careful with circular references in custom data structures