Skip to content

feat: add spatial queries, zone spawning, and world recovery to Lua API#3

Open
Taure wants to merge 1 commit intomainfrom
feat/spatial-spawning-lua-api
Open

feat: add spatial queries, zone spawning, and world recovery to Lua API#3
Taure wants to merge 1 commit intomainfrom
feat/spatial-spawning-lua-api

Conversation

@Taure
Copy link
Copy Markdown
Contributor

@Taure Taure commented Apr 12, 2026

Summary

  • game.spatial.*query_radius, nearest, in_range, distance operating on Lua entity tables. Handles binary→atom key conversion automatically so Lua tables work with asobi_spatial.
  • game.zone.spawn/despawn — template-based entity spawning from Lua scripts (requires zone context, world mode only).
  • spawn_templates(config) — new optional Lua callback returning a template registry table with respawn rules.
  • on_world_recovered(snapshots, state) — new optional Lua callback invoked when a world restarts from DB snapshots.

Bumps asobi dependency to pick up zone persistence, spawner, and spatial features from widgrensit/asobi#63.

Test plan

  • 6 new EUnit tests (spatial query_radius, nearest, in_range, distance, zone spawn, zone despawn)
  • All 47 tests pass
  • dialyzer clean, xref clean, fmt clean

Expose the three new asobi features to Lua scripts:

- game.spatial.query_radius/nearest/in_range/distance — spatial queries
  on entity tables with automatic binary-to-atom key conversion
- game.zone.spawn/despawn — template-based entity spawning (world mode)
- spawn_templates(config) callback — define spawn templates from Lua
- on_world_recovered(snapshots, state) callback — handle snapshot recovery
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant