class

PointClickEngine::Scripting::ScriptEngine

Inherits Reference < Object

Main script engine using component-based architecture

This refactored ScriptEngine delegates responsibilities to specialized components:

  • LuaEnvironment: Lua setup and utility functions
  • ScriptAPIRegistry: Crystal function registration
  • SceneScriptAPI: Scene-related Lua API
  • CharacterScriptAPI: Character-related Lua API
  • InventoryScriptAPI: Inventory management Lua API
  • DialogScriptAPI: Dialog system Lua API
  • UtilityScriptAPI: Game state, timers, sequences, quests Lua API
  • CameraScriptAPI: Camera control Lua API
  • AudioScriptAPI: Audio control Lua API
  • HotspotScriptAPI: Hotspot interaction Lua API
  • LuaStateManager: Script-accessible Lua state

EventBus Integration: Scripts register Lua handlers (e.g., scene.on_enter, hotspot.on_click) ScriptEngine subscribes to EventBus events and calls the Lua handlers

Constructors

Instance methods

call_function(function_name : String, *args) : Luajit::LuaAny | Nil

Call a Lua function

Source
cleanup

Clean up Lua state

Source
execute_script(script_content : String) : Bool

Execute a script string

Source
execute_script_file(file_path : String) : Bool

Execute a script file

Source
game_state

Legacy property for compatibility

Source
get_global(name : String) : Luajit::LuaAny | Nil

Get a global variable

Source
set_global(name : String, value)

Set a global variable

Source
subscribe_to_events(event_bus : Core::Events::EventBus)

Subscribe to EventBus events - call this after engine is initialized

Source
unsubscribe_from_events(event_bus : Core::Events::EventBus)

Unsubscribe from all events

Source