run_lua
Execute arbitrary Lua code in Civilization VI to query or modify game state, using gamecore for read-only access or ingame for full API commands.
Instructions
Run arbitrary Lua code in the game. Advanced escape hatch — prefer built-in tools.
Args:
code: Lua code to execute. Use print() for output, end with print("---END---").
context: "gamecore" (default) for read-only state queries.
"ingame" for commands and UI-dependent queries.
Context differences:
gamecore: Players[], GameInfo.*, Map.*, Game.* — safe read-only access.
CANNOT use: UI.*, UnitManager.*, CityManager.*, notifications.
ingame: All APIs including UI.*, UnitManager.*, CityManager.*.
Use for: moving units, setting research, diplomacy actions.
Always use print() for output (not return).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | ||
| context | No | gamecore |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |