Skip to content

feat: init LUA#1683

Draft
dderevjanik wants to merge 24 commits intoKeriew:masterfrom
dderevjanik:feat/lua-int
Draft

feat: init LUA#1683
dderevjanik wants to merge 24 commits intoKeriew:masterfrom
dderevjanik:feat/lua-int

Conversation

@dderevjanik
Copy link
Copy Markdown

@dderevjanik dderevjanik commented Feb 9, 2026

This PR initializes Lua integration, giving scenario creators more flexibility when building custom scenarios.

To add scripting to a scenario, simply create a .lua file with the same name as the scenario file and place it in the same folder. The game will automatically load and execute the script.

This PR includes a test script (Valentia.lua). To try it out, place it in the same folder as C3.

What's included

  • External library lua
  • LUA API / C Bridge
    • building, city, core, empire, finance, game, map, population, resource, sound, ui
    • persists LUA script & state between loads
  • New Choice Dialog that calls different lua functions
  • Quake style terminal
    • Contains logs from stdout
    • Contains logs from lua
    • Allows interaction (evaluate Lua) with scenario Lua scripts
    • Copy/Paste
  • Scenario version bump (in order to persist lua state)
  • Lua API for IDE Intellisense
  • Document lua usage in README

Quake style terminal
image

Choices dialog
image

@dderevjanik dderevjanik marked this pull request as draft February 10, 2026 09:09
@dderevjanik dderevjanik changed the title [DRAFT] Feat init LUA feat: init LUA Feb 10, 2026
lua: update lua apis

lua(refactor): apis
@crudelios
Copy link
Copy Markdown
Collaborator

I need to look into this.

I do think this would get a bit more use of it was possible to convert to/from the current event editor ui to the lua scripting.

I think it's possible to convert from the editor to lua, but I'm not sure about the other way around as lua provides way more features that the editor can handle...

@dderevjanik
Copy link
Copy Markdown
Author

No rush with the review of this PR. Even though it’s quite large, there aren’t many logic changes -apart from integrating the external Lua library and adding the API layer between C and Lua. The Lua state (including the script) is stored inside the save game.

Regarding the feature itself, I see Lua as an extension of the existing scenario events system. I don’t expect scenario designers to switch from events to Lua anytime soon. Still, Lua feels like the right step toward more dynamic scenarios in the future.

It also opens the door to modding -for example, creating custom mechanics or introducing features like an emperor with a dynamic personality or a more dynamic Empire map.

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