Sends the gameplay events of a bus to the scripts of a state, while it lives.
More...
Sends the gameplay events of a bus to the scripts of a state, while it lives.
Each ecs::Explosion reaches the scripts as an "Explosion" event (entity, killer, x, y), each ecs::LifeLost as a "LifeLost" one (player, lives_left, score). Destroy it before the state or the bus. Defined in the header: the bus finds its handlers by typeid, which differs between the engine's libraries and the game with libc++.
events.on("Explosion", function(event)
ecs.create({Transform = {x = event.x, y = event.y}, Velocity = {y = -60}})
end)
)");
Sends the gameplay events of a bus to the scripts of a state, while it lives.
Definition events.hpp:54
A Lua state for the game's scripts, sandboxed.
Definition state.hpp:52
bool run(std::string_view code, std::string_view chunk="script")
Runs Lua code.
void bind_components(ScriptState &lua, ecs::Registry ®istry)
Gives the scripts of a state the common components of a registry.
Definition components.hpp:278