ludic/docs/language/ecs/fn-world_get.md
Orkuncakilkaya b7745a4600 refactor(lang): rename the str type (and stringify builtin) to string
Expand the abbreviated string type and its conversion builtin to the full
word everywhere:
  str            ->  string        (the immutable-string type)
  str(x) -> str  ->  string(x) -> string   (the stringify builtin;
                                            what `{…}` interpolation calls)

Types are recognized by identifier, and llty maps both spellings to LLVM
`ptr`, so this is an atomic source rewrite: type annotations, the Ludic
type tags, the builtin name/dispatch, and the interpolation desugar, plus
the grammars, LSP, docs (type-str -> type-string, fn-str -> fn-string), and
inventory. int/bool stay (universally accepted, like Math).

Reseeded; C-free fixpoint holds; all suites green (45/24/29); site + check.py OK.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-30 01:51:11 +03:00

1.5 KiB

id name category kind tokens sig tip order
fn-world_get world_get ecs builtin world_get world_get(target, property, field) -> int Read one field of a model instance by numeric id (reflection ABI). 50

world_get reads a single field of a model instance entirely by numeric id, returning its value as an int. It is the id-based counterpart to the ordinary position.column field access that queries give you — used when the property is not known at compile time, as in a mod or a generic tool. You supply the target instance (an entity), the property id (from world_prop_id), and the field id (from world_field_id); the result is the stored value. Pair it with world_set to write. Reading a field of an instance that lacks the property is not meaningful, so guard with world_has first if unsure.

Parameters:

  • target — the model instance to read from, an entity handle
  • property — the property id, from world_prop_id
  • field — the field id within that property, from world_field_id
program ReadField {
  property Position { column: int = 0, row: int = 0 }
  model Player { Position }

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

  handler Inspect phase Update {
    let position_property = world_prop_id("Position")
    let column_field = world_field_id(position_property, "column")
    for (position) in query [Position, {Player}] {
      let value = world_get(self(), position_property, column_field)
      Screen.status(string(value))
    }
  }
}