Skip to content

Refactor Lua API - #12

Merged
atpogue merged 6 commits into
mainfrom
refactor/lua-api
Sep 30, 2026
Merged

atpogue merged 6 commits into
mainfrom
refactor/lua-api

Conversation

@atpogue

@atpogue atpogue commented Sep 30, 2026

Copy link
Copy Markdown
Owner

Lua:

  • Move Lua out of the simulation layer.
  • Content scripts are now read by the App layer, which creates the terrain definitions in the game catalog and builds the matching sprites.
  • New API: State, Reference, Value, Table and Key.
  • Every value remembers its Lua path (i.e. "content.terrain.grass.sprite"), and errors report that path.

Game:

  • Game::World replaces Simulation and the Context capability types. Read-only access is now expressed with World const&.
  • Put game code in the Game namespace.
  • Move texture, sprite, scene and load code from game/ to app/.

App:

  • App::State replaces Application.
  • Pilot moved to app/.
  • load_content collects errors from every definition before failing.

Build:

  • Remove MSVC support. Build with -fno-exceptions everywhere.

atpogue and others added 6 commits September 4, 2026 17:59
Consolidate the WIP SDK around an owned Lua state, registry-backed nodes, path-aware type errors, deterministic table traversal, and erased schema field translators.

Compile the existing terrain content through nested Sprite and Rectangle schemas, remove abandoned API experiments, and add focused Catch2 coverage.

Co-authored-by: Andrew Pogue <atpogue@outlook.com>
Assisted-by: ChatGPT
refactor(lua): finish table translation API
Complete the WIP move of Lua-based content loading from the game layer
into app, and bring the whole branch back to a compiling state.

Lua library (app/lua):
- Fallible operations return std::optional (or bool) and print their
  diagnostic to stdout, prefixed with the value's path.
- Values and tables carry their path as a std::string, formatted the way
  it would be written in Lua (i.e. content.terrain["grass-1"].sprite).
- Reference holds the lua_State* directly so it survives the owning
  State being moved.
- Table::keys() returns integer keys ascending, then names sorted, so
  traversal order is deterministic.
- Integer reads clamp to the destination type's range; number reads
  accept Lua integers.

App:
- load_content() runs the script, defines Game::Terrain in the world's
  catalog, and builds sprites parallel to the terrain definitions.
  Errors accumulate across definitions before failing.
- App::State replaces Application and works on Game::World directly.
- Port the deleted sdk Lua tests to app/tests.

Game:
- Finish the Game::World API and fix the grassland and cave generators.
- Fix Command::is_empty(), which returned the inverse.

Core:
- Qualify detail::panic in PANIC so it works inside namespaces that
  have their own detail namespace.
- Fix BasicCatalog::try_get returning a value instead of a pointer, and
  initialize its generation.
- Give DEFER a unique, non-reserved variable name.

Build:
- Link game against GLM, which it uses for Pose and command movement.
- README: require Clang 19+, the first version whose concepts support
  enables std::expected in libstdc++.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EukP9918Z3pX9d2utk9WWE
refactor(lua): finish moving content authorship to app
@atpogue
atpogue merged commit 4ccb061 into main Sep 30, 2026
2 checks passed
@atpogue
atpogue deleted the refactor/lua-api branch September 30, 2026 03:58
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.

2 participants