new lua hooks into mp_settings

Discussion of Lua and LuaWML support, development, and ideas.

Moderator: Forum Moderators

Post Reply
User avatar
iceiceice
Posts: 1056
Joined: August 23rd, 2013, 2:10 am

new lua hooks into mp_settings

Post by iceiceice »

Hi Everyone,

I decided to write some lua hooks which will, for example, let you read mp_era, get a list of currently active modifications, and some other things. (Previous feature requests here,here). My proposal is now a github pull request. But I wanted to explain what it is here and solicit feedback from the forums.

The proposal is that all the info that appears at the start of an uncompressed savefile under the [multiplayer] tag:
Spoiler:
will become read-only accessible to lua via a proxy table "wesnoth.game_config.mp_settings". For example you could use expressions like "wesnoth.game_config.mp_settings.mp_era" or "wesnoth.game_config.mp_settings.mp_countdown_reservoir_time". All the names should match what appears in the save file exactly. Everything is a string, int or bool, and things that are lists like "wesnoth.game_config.mp_settings.active_mods" will become a comma delimited string.

These fields will only be accessible in a multiplayer game, otherwise mp_settings will not be a child of wesnoth.game_config .

*Additionally*, you can check the campaign type using the field "wesnoth.game_config.campaign_type". If this is equal to "multiplayer" then queries to wesnoth.game_config.mp_settings will work.

I think that this will be useful because
  • MP developers will be able to detect the game settings like fog, shroud, random start time, and adapt their scenarios / campaigns, or give warnings to the user.
  • MP/AI developers will be able to detect if other mods or eras are being used, which has previously been impossible, and adapt or give warnings.
  • MP/AI developers will be able to detect how the timer has been configured, which has previously been impossible, and adapt or give warnings.
~iceiceice~
Post Reply