ludic/docs/language/ecs/fn-world_spawn.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.2 KiB

id name category kind tokens sig tip order
fn-world_spawn world_spawn ecs builtin world_spawn world_spawn(model) -> entity Spawn an instance of a model chosen by numeric id at runtime. 50

world_spawn creates a new instance of a model chosen by numeric id and returns its entity handle — the reflection-ABI counterpart of the static spawn Label { … }. Because the model is given as an id (from world_model_id) rather than a name written in source, a mod or tool can decide at runtime which kind to create. The new instance is seeded exactly as the static spawn would seed it — every property in the model attached with default field values — after which you can set fields with world_set. Use the ordinary spawn statement in normal handler code; reach for world_spawn when the kind is data, not a literal.

Parameters:

  • model — the model id to instantiate, from world_model_id
program Reinforcements {
  property Position { column: int = 0, row: int = 0 }
  model Enemy { Position }

  handler Reinforce phase Update {
    if Input.key() == ' ' {
      let enemy_model = world_model_id("Enemy")
      let new_enemy = world_spawn(enemy_model)
      Screen.status(string(new_enemy))
    }
  }
}