API Reference › Entities & the ECS › world_model_id
function

world_model_id

world_model_id(name) -> int

world_model_id looks up a model by name and returns its stable numeric id, or a negative value if no model of that name exists. It is part of Ludic's reflection ABI — the dynamic, id-based view of the world that mods and tools use alongside the static spawn/query forms. You typically resolve a name to an id once and then feed that id to id-based calls such as world_spawn or world_kind. Because the id is stable for a given build, it is safe to cache in a var.

Parameters

namethe model's name, as a string, e.g. "Player"

Example

program ResolveModel {
  property Position { column: int = 0, row: int = 0 }
  model Player { Position }

  handler Boot phase Start {
    spawn Hero { Position { column: 3, row: 3 } }
  }

  handler Inspect phase Update {
    let player_model = world_model_id("Player")
    Screen.status(string(player_model))
  }
}
← All symbols