Skip to content

Lua: expose more map and player infos#4804

Merged
Loobinex merged 8 commits into
dkfans:masterfrom
Shinthoras0815:Lua-expose-more-map-and-player-infos
May 22, 2026
Merged

Lua: expose more map and player infos#4804
Loobinex merged 8 commits into
dkfans:masterfrom
Shinthoras0815:Lua-expose-more-map-and-player-infos

Conversation

@Shinthoras0815
Copy link
Copy Markdown
Contributor

@Shinthoras0815 Shinthoras0815 commented May 21, 2026

Expose additional map and player information to Lua

Map fields:

  • Map name
  • Map number
  • Campaign/MapPack name
  • Map type (Campaign, MapPack, Multiplayer, Bonus, Moon)
  • Map size
  • Creature pool
  • Map default Texture (read/set)

Player fields:

  • Player type (Human, Computer, Roaming, Inactive, Neutral)
  • Maximum creature limit
  • Player name (mostly for multiplayer, read/set)
  • Player colour (read/set)

Copilot AI review requested due to automatic review settings May 21, 2026 14:03
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the Lua scripting API by exposing additional map- and player-related information (and allowing some of it to be modified from Lua), primarily via a new Map singleton and additional Player fields.

Changes:

  • Registers a new global Lua Map object with readable map metadata and a writable default_texture.
  • Extends Lua Player field accessors to expose type, max_creatures, player_name, and colour, and adds setters for player_name and colour.
  • Updates build output list to compile the new lua_api_map.c translation unit.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/lua_api.c Registers Map_register() so the new Map singleton is available to Lua.
src/lua_api_player.c Adds new Lua-visible player fields and setters (name/colour) to the Player API.
src/lua_api_map.c Introduces the Map Lua singleton and exposes map metadata + texture setter.
Makefile Adds lua_api_map.o to the object list for non-CMake builds.
config/fxdata/lua/classes/Player.lua Updates Lua class annotations for newly exposed Player fields.
config/fxdata/lua/classes/Map.lua Adds Lua class annotations for the new Map singleton.
Comments suppressed due to low confidence (1)

src/lua_api_map.c:71

  • The Map.map_type values don’t match the PR description (Campaign, Freeplay, Multiplayer, Bonus). Here LvKind_IsFree is exposed as "MapPack" instead of "Freeplay"; please align the returned string(s) with the documented API or update the PR description accordingly.
        } else if (ltype & LvKind_IsBonus) {
            lua_pushstring(L, "Bonus");
        } else if (ltype & LvKind_IsFree) {
            lua_pushstring(L, "MapPack");
        } else if (ltype & LvKind_IsSingle) {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lua_api_player.c
Comment thread src/lua_api_map.c
Comment thread Makefile
Comment thread config/fxdata/lua/classes/Map.lua Outdated
Comment thread config/fxdata/lua/classes/Player.lua Outdated
@Loobinex Loobinex merged commit 8b644d4 into dkfans:master May 22, 2026
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.

4 participants