Home › World Builder from Lua

World Builder from Lua

Status. Everything on this page was read from the decompiled C++ of the Lua wrappers and from the static call graph of the symbol build. The per-method notes were written by an AI assistant and are inferred; nothing here was run by us in a game. A "confidence" column says how sure the reading is. Real mod code that uses these calls is quoted only where it is public (Gedemon's Civ6-GCO).

What it is

The World Builder is the game's map and scenario editor. Its engine side is a set of managers (cities, units, map, players, configuration, mod metadata) and a family of command objects that give the editor undo and redo. The game also registers 99 Lua methods for these managers on 8 objects, in the gameplay Lua state. None of them appear in the community reference, so this page groups them by task.

They reach editor code paths that ordinary gameplay Lua has no method for: placing a building in a city directly, setting the owner of any plot, initializing or removing a player. Mods use them as a workaround where an ordinary method does not exist or does not work (for example the two-step plot owner flip: clear with SetPlotOwner(x, y, false), then assign SetPlotOwner(x, y, city); see also Plot.SetOwner).

local city = Players[playerID]:GetCities():FindID(cityID)     -- an ordinary city object
WorldBuilder.CityManager():CreateBuilding(city, buildingType, 100)
WorldBuilder.CityManager():SetPlotOwner(x, y, false)           -- clear
WorldBuilder.CityManager():SetPlotOwner(x, y, city)            -- assign

The undo model

Probably: WorldBuilder::Manager owns a Command::Manager (at +0x1f0) holding eastl lists of shared_ptr. Lua StartUndoBlock/EndUndoBlock call Command::Manager::StartBlock/EndBlock, which probably create and close a BlockCommand (it has Add/Undo/Redo/CanUndo/CanRedo/GetName/GetType) so that commands passed to Manager::Add inside the block are grouped as one undo step. Edit code uses Command::Manager::Do templates (CommandSetTerrain, SetFeature, SetResource, SetImprovement, SetRoute, EditRiver, EditCliff, SetRevealed, SetStartPos), which probably construct a command, add it and run its Redo. Undo/Redo take commands from the list and call their Undo/Redo; classes include Create/Remove/Initialize/Uninitialize (+ building/district variants with Apply) and property setters (Civic, Era, Faith, Gold, Tech, Leader, PlotOwner). Lua only sees CanUndo/CanRedo and boolean results of Undo/Redo.

Inferred. Manager-level setters (SetID, SetMod, SetWBAdvancedMode, visibility preview) are plain setters, not commands. Behaviour of EndBlock without StartBlock, nested blocks, and Undo while a block is open was not read; keep Start/End balanced. Class details are inferred from names only.

Methods marked undo: yes below construct a command (so they appear in the editor's undo history and are reversible with WorldBuilder.Undo()); no means the call edits state directly or only reads. Whether a missing command means "not undoable" is itself inferred from the call data.

Things to know before you rely on it

WorldBuilder (the global)

Entry point and undo control. WorldBuilder.CityManager(), MapManager(), PlayerManager(), UnitManager(), ModManager() and ConfigurationManager() return the sub-managers below. 21 methods.

Method Call Returns Undo Confidence What it does, and cautions
CanRedo WorldBuilder.CanRedo() 1 boolean no high Reports whether the world builder command manager has something to redo. Query only.
CanUndo WorldBuilder.CanUndo() 1 boolean no high Reports whether the world builder command manager has something to undo. Query only.
CityManager local mgr = WorldBuilder.CityManager() 1 value: sub-manager userdata no high Returns the CityManager sub-manager object (C++ WorldBuilder::City::Manager at WorldBuilder::Manager+0x20) wrapped via ScopedInstance::Push. Takes no arguments; the pushed object refers to the singleton's member, not a copy.
ClearVisibilityPreviewPlayer WorldBuilder.ClearVisibilityPreviewPlayer() nothing no high Clears the visibility preview player by calling SetVisibilityPreviewPlayer with -1 (0xffffffff). No arguments; not recorded as an undo command in the wrapper.
ConfigurationManager local mgr = WorldBuilder.ConfigurationManager() 1 value: sub-manager userdata no high Returns the ConfigurationManager sub-manager object (C++ WorldBuilder::Configuration::Manager at WorldBuilder::Manager+0x228) wrapped via ScopedInstance::Push. Takes no arguments; the pushed object refers to the singleton's member, not a copy.
EndUndoBlock WorldBuilder.EndUndoBlock() nothing no (probably) medium Closes the current undo block on the command manager. Pair with StartUndoBlock; wrapper does no checks, EndBlock internals not read, so behaviour when no block is open is unknown.
GenerateID local id = WorldBuilder.GenerateID() 1 string (GUID text) no high Creates a new GUID and returns it as a string (Platform::CreateGUID + GUIDToString). Only generates; use SetID to apply it. Exact text format (braces/case) not verified.
GetID local id = WorldBuilder.GetID() 1 string no high Returns the current world builder ID (GUID) as a string. Returns whatever GUID the manager holds, even if never set.
GetWBAdvancedMode WorldBuilder.GetWBAdvancedMode() 1 boolean no high Returns whether world builder advanced mode is on. Query only.
IsMod WorldBuilder.IsMod() 1 boolean no high Returns the manager's mod flag. Query only.
MapManager local mgr = WorldBuilder.MapManager() 1 value: sub-manager userdata no high Returns the MapManager sub-manager object (C++ WorldBuilder::Map::Manager at WorldBuilder::Manager+0xe0) wrapped via ScopedInstance::Push. Takes no arguments; the pushed object refers to the singleton's member, not a copy.
ModManager local mgr = WorldBuilder.ModManager() 1 value: sub-manager userdata no high Returns the ModManager sub-manager object (C++ WorldBuilder::Mod::Manager at WorldBuilder::Manager+0x160) wrapped via ScopedInstance::Push. Takes no arguments; the pushed object refers to the singleton's member, not a copy.
PlayerManager local mgr = WorldBuilder.PlayerManager() 1 value: sub-manager userdata no high Returns the PlayerManager sub-manager object (C++ WorldBuilder::Player::Manager at WorldBuilder::Manager+0x18) wrapped via ScopedInstance::Push. Takes no arguments; the pushed object refers to the singleton's member, not a copy.
Redo WorldBuilder.Redo() 1 boolean (result of Command::Manager::Redo) yes (probably) medium Redoes the next undone command via the command manager and returns the result. Check CanRedo first; false presumably means nothing was redone (Redo internals not read).
SetID WorldBuilder.SetID(idString) (also accepted with 2 args, e.g. colon call) 1 boolean: true if parsed and applied, false otherwise no high Parses a GUID string and sets it as the world builder ID and as the mod metadata ID. Any other argument count raises an argument error; an unparsable string silently returns false and changes nothing.
SetMod WorldBuilder.SetMod(bState) nothing no high Sets the manager's mod flag from the truthiness of argument 1. No argument count check; a missing argument acts as false.
SetVisibilityPreviewPlayer WorldBuilder.SetVisibilityPreviewPlayer(playerID) nothing no high Sets the player whose visibility is previewed. Silently does nothing unless exactly one argument is passed. Use ClearVisibilityPreviewPlayer to clear.
SetWBAdvancedMode WorldBuilder.SetWBAdvancedMode(bAdvanced) nothing no (probably) medium Sets advanced mode: false when arg is nil/false/number 0, otherwise true. Silently does nothing unless exactly one argument is passed.
StartUndoBlock WorldBuilder.StartUndoBlock() nothing no (probably) medium Opens a new undo block on the command manager so following edits can be grouped. Pair with EndUndoBlock; behaviour of an unclosed block was not read (probably later edits stay grouped in the open block).
Undo WorldBuilder.Undo() 1 boolean (result of Command::Manager::Undo) yes (probably) medium Undoes the last command (or block) via the command manager and returns the result. Check CanUndo first. Several Command classes in the index list no Undo of their own (e.g. CommandEditCliff, EditRiver, SetRoute, SetRevealed), so undo for them is probably handled elsewhere.
UnitManager local mgr = WorldBuilder.UnitManager() 1 value: sub-manager userdata no high Returns the UnitManager sub-manager object (C++ WorldBuilder::Unit::Manager at WorldBuilder::Manager+0x19 as Manager* pointer arithmetic (scaled, offset not byte-literal)) wrapped via ScopedInstance::Push. Takes no arguments; the pushed object refers to the singleton's member, not a copy.

WorldBuilderManager_Inactive

A separate registration with one method. 1 methods.

Method Call Returns Undo Confidence What it does, and cautions
IsActive IsActive() on the _Inactive registration; global name not verified 1 boolean no (probably) medium Returns whether the world builder is active (WorldBuilder::Manager::IsActive). Separate wrapper class IWorldBuilderManager_Inactive with the same logic; probably registered so the query works when the world builder is not active (not verified).

City manager

Create and remove cities, buildings and districts, move plot ownership, read and write city and district values. 15 methods.

Method Call Returns Undo Confidence What it does, and cautions
Create local pid, cid = mgr:Create(ePlayer, x, y) or mgr:Create(ePlayer, plot) 2 numbers (owner PlayerID, CityID) on success; nothing if fewer than 2 args, invalid plot, or manager returned id -1 yes high Creates a city for a player at a plot and returns its id pair. Wrapper returns nothing (no error) on bad args or failed creation; no check here that plot is free/valid. Player is read via tonumber so nil/strings probably become 0.
CreateBuilding local ok, results = mgr:CreateBuilding(city, eBuilding, uiConstructionPercent [, plot / x, y]) 2 values: boolean success, and a requirements-results object (PushRequirementsResults) yes high Adds a building to a city (with construction percent, optional plot) and reports success and requirement results. If the city is invalid nothing is attempted but it still returns false plus an empty results object. Plot defaults to invalid (-9999,-9999) when omitted. Always check the first return.
CreateDistrict local ok, results = mgr:CreateDistrict(city, eDistrict, uiConstructionPercent [, plot / x, y]) 2 values: boolean success, and requirements-results object yes high Adds a district to a city (construction percent, optional plot) and reports success and requirement results. A district needs a plot; an omitted plot stays (-9999,-9999) and probably fails. Invalid city returns false without acting.
GetCity local city = mgr:GetCity(ePlayer, cityID) 1 City object, or nothing no high Returns the City object for a (playerID, cityID) pair. Only works with exactly 3 stack values (self + 2 args); any other arg count returns nothing. Returns nothing if either id is -1 or the city is not found. Object is an editable City::Instance (EditCity).
GetCityValue local v = mgr:GetCityValue(city, valueType [, name]) 1 value (converted from the stored ValueEntry variant); nothing if city invalid no (probably) medium Reads a WorldBuilder value of a city (by value type id) and returns it to Lua. Returns nothing for an invalid city. Unknown value types probably yield a default entry (FindValueHandler lookup); not verified.
GetDistrictValue local v = mgr:GetDistrictValue(district, valueType [, name]) 1 value; nothing if district id invalid no (probably) medium Reads a WorldBuilder value of a district and returns it to Lua. Returns nothing for an invalid district.
GetPlotOwner local t = mgr:GetPlotOwner(plot) or mgr:GetPlotOwner(x, y); t.PlayerID, t.CityID 1 value: table {PlayerID=, CityID=}, or nil if out of bounds / unowned / bad args no (probably) medium Returns which city owns a plot as a table. Always returns exactly one value (nil when no owner). Reads the map plot directly.
Remove mgr:Remove(city) nothing yes high Removes a city. Silent no-op if no arg or city id invalid.
RemoveAll mgr:RemoveAll(ePlayer) nothing yes (probably) medium Removes all cities of a player, in one command block. Does nothing if called without the argument; a non-number arg probably becomes player 0 (tonumber default), unverified.
RemoveAt mgr:RemoveAt(plot) or mgr:RemoveAt(x, y) nothing yes high Removes the city located on a plot. Silent no-op if no plot arg, bad plot or no city there. Signature marks it static but the plot still starts at argument position 2.
RemoveBuilding local ok = mgr:RemoveBuilding(city, eBuilding) 1 boolean (manager result; false for invalid city) yes high Removes a building from a city. Check the return value; false when city invalid, and probably when the building is absent.
RemoveDistrict mgr:RemoveDistrict(district) or mgr:RemoveDistrict(city, eDistrict) 1 boolean, which in this wrapper is always false yes high Removes a district, given either a district object or city plus district type. Return value is hard-coded false (the manager bool is discarded); do not use it to detect success. Silent no-op for invalid ids.
SetCityValue mgr:SetCityValue(city, valueType, value) nothing no (probably) medium Sets a WorldBuilder value (by type id) on a city. Booleans are not handled specially (string path, probably wrong); use 1/0. Call data shows no Command constructed, so probably not undoable. Silent no-op for invalid city.
SetDistrictValue mgr:SetDistrictValue(district, valueType, value) nothing no (probably) medium Sets a WorldBuilder value on a district. No Command in call data, so probably not undoable. Silent no-op for invalid district. Booleans are handled here (unlike SetCityValue).
SetPlotOwner mgr:SetPlotOwner(plot/x,y, city) or mgr:SetPlotOwner(plot/x,y, false) or mgr:SetPlotOwner(plot/x,y) nothing yes high Assigns a plot to a city, or clears ownership. A boolean or missing owner arg gives city id (-1,-1) meaning unowned. Silent no-op if plot args invalid. A nil (non-boolean) arg goes to GetCityID, behaviour unknown.

Unit manager

Create and remove units. 4 methods.

Method Call Returns Undo Confidence What it does, and cautions
Create local pid, uid = mgr:Create(eUnitType, ePlayer, x, y) or mgr:Create(eUnitType, ePlayer, plot) 2 numbers (owner PlayerID, UnitID); nothing on bad args or failure yes (probably) medium Creates a unit of a type for an owner at a plot and returns its id pair. Arg order inferred from Manager::Create(eUnit, eOwner, loc); the earlier recovered name eOwner for position 2 looks swapped (decompiler parameter mapping is garbled), so medium confidence. Needs more than 3 stack values or returns nothing.
Remove mgr:Remove(unit) nothing yes high Removes a unit. Silent no-op if no arg or invalid id.
RemoveAll mgr:RemoveAll(ePlayer) nothing yes (probably) medium Removes all units of a player, in one command block. No-op without the arg; a non-number arg probably becomes player 0 (unverified).
RemoveAt mgr:RemoveAt(plot) or mgr:RemoveAt(x, y) nothing yes (probably) low Removes units standing on a plot. Decompile is partly mislabelled (a call named Cache::City::Growth::GetAmenitiesLostFromBankruptcy is probably a unit count at the plot); it iterates unit slots at the plot and removes the first valid unit of each index. Probably removes all units on the plot; unverified.

Map manager

Terrain, features, resources, improvements, routes, rivers, cliffs, continents, reveal state and the placement checks. 24 methods.

Method Call Returns Undo Confidence What it does, and cautions
CanPlaceFeature mgr:CanPlaceFeature(x, y, feature [, params/bool]) or mgr:CanPlaceFeature(plot, feature [, params/bool]) 1 boolean no high Asks the terrain builder whether a feature can be placed on a plot. Returns false (no error) when too few args, plot cannot be parsed, plot is outside map bounds or feature param is -1. Read-only check.
CanPlaceImprovement mgr:CanPlaceImprovement(x, y, improvement [, player [, flag]]) 1 boolean no (probably) medium Asks the improvement builder whether an improvement can be placed on a plot. Wrapper requires at least 3 args after self (it passes 3 to the plot helper), so the plot-object form needs a further arg or it returns false. Plot pointer not null-checked in wrapper.
CanPlaceResource mgr:CanPlaceResource(x, y, resource [, flag]) or mgr:CanPlaceResource(plot, resource) 1 boolean no (probably) medium Asks the resource builder whether a resource can be placed on a plot. Form guessed from arg count: exactly 2 args after self is parsed as plot,resource; 3+ as x,y,resource,flag. So plot,resource,flag is read as x,y form. Returns false with <2 args.
DoesPlotBorderRiver mgr:DoesPlotBorderRiver(x, y) or mgr:DoesPlotBorderRiver(plot) 1 boolean no high Returns whether the plot borders a river (WorldBuilder::Map::Manager::DoesPlotBorderRiver). Returns false if the plot cannot be parsed.
EditCliff mgr:EditCliff(x, y, direction, bAdd [, flag]) 1 boolean (result of Manager::EditCliff) yes high Adds or removes a cliff on a plot edge in the given direction through WorldBuilder::Map::Manager::EditCliff. Returns false when args are missing (needs 3+ after self) or plot unparsable. Recorded as CommandEditCliff via Command::Manager::Do.
EditRiver local ok, code = mgr:EditRiver(x, y, direction, bAdd [, flag]) 2 values: boolean (true when result code == 0), number (IResultCode) yes high Adds or removes a river segment on a plot edge through WorldBuilder::Map::Manager::EditRiver, returning success and a result code. On bad args returns false, 0. Non-zero code means the edit was refused; code meanings not decoded.
GetContinentPlots local plots = mgr:GetContinentPlots(continentIndex) 1 table (array of 0-based plot indices) or nil no high Returns the plot indices belonging to a continent (land plots and lakes, excluding other water). Returns nil unless exactly one argument is given and it is a number. Table is empty if the continent has none.
GetDimensionsFromTiled local w, h = mgr:GetDimensionsFromTiled() 2 numbers (width, height); defaults 64 and 48 when the file/attributes cannot be read no high Reads width and height attributes of the root element of the Tiled XML file set as map import filename. Always returns two numbers; failure is silent and yields the 64x48 defaults, so verify the file yourself.
GetFeaturePlacementPlotList WorldBuilder.MapManager.GetFeaturePlacementPlotList(self, x, y, feature [, params]) 1 table of numbers (probably plot indices, inference) or nothing no (probably) medium Returns a list of plots (numbers) related to placing a feature at a plot, from the terrain builder. Registered as static (no instance check). Returns nothing when plot is invalid or list is empty. luaL_checkinteger raises a Lua error on a non-number feature.
GetPlotValue mgr:GetPlotValue(plotIndex, valueType [, name]) 1 value (variant converted by script system) or nothing if plot arg invalid no (probably) medium Returns a stored per-plot value entry (value type, optional name) from WorldBuilder::Map::Manager. Type is read from fixed slot 3, so an x,y plot form would misplace it. Returns nothing on bad plot.
IsImprovementPlaceable WorldBuilder.MapManager.IsImprovementPlaceable(self, resourceType) 1 boolean no (probably) low Checks resource-definition data: true if the resource has valid-feature entries (own list non-empty, or a Resource_ValidFeature row matches its type name). Despite the name the code reads Resource definitions, not improvements; the intent is a guess (probably 'resource needs a feature'). Static; false on missing arg or unknown index.
IsWonderTooClose mgr:IsWonderTooClose(plot, feature) 1 boolean no (probably) medium Returns true when a plot is too close to another natural wonder for the given feature (inverse of NaturalWonderDistanceCheck). False if args missing, plot not found, or plot null. Pass a plot object/index.
LoadPlotsFromTiled mgr:LoadPlotsFromTiled() nothing no (probably) medium Loads the Tiled (.tmx XML) map file named by the map import filename and places terrain/feature/resource/improvement/continent/district/building layers onto the map's plots. Fails silently (map filled/reset, no error) if the file or root is bad. Visible calls use Context::Globals::EditMap directly, not WorldBuilder commands, so it is probably not undoable. Rewrites the whole map.
SetAllRevealed mgr:SetAllRevealed(bRevealed, player) 1 boolean yes high Reveals or hides the whole map for a player, grouped as one command block. Returns false unless both args given. No player validation in wrapper.
SetCoastalLowland mgr:SetCoastalLowland(x, y, lowlandType) or mgr:SetCoastalLowland(plot, lowlandType) 1 boolean, always false no high Adds a coastal lowland (flood) type to a plot directly through the terrain manager's CoastalLowlandDataHandler. Return value is constant false even on success. Plot index computed as width*y+x without bounds check. No undo command.
SetContinentType mgr:SetContinentType(plot, continent) 1 boolean (result of SetContinent) yes (probably) medium Sets a plot's continent via WorldBuilder::Map::Manager::SetContinent. False when args missing/plot unparsable. Recorded via Do (probably terrain unchanged, continent set).
SetFeatureType mgr:SetFeatureType(x, y, feature [, params/bool]) or mgr:SetFeatureType(plot, feature ...) 1 boolean (result of SetFeature) yes (probably) medium Sets (or changes) the feature on a plot via WorldBuilder::Map::Manager::SetFeature. Feature and direction default to -1 when not given. -1 as feature probably clears it (guess). Validity checks are inside Manager::SetFeature (not read).
SetImprovementPillaged mgr:SetImprovementPillaged(x, y, bPillaged) or mgr:SetImprovementPillaged(plot, bPillaged) 1 boolean, always false no (probably) medium Sets the pillaged state of the improvement on a plot directly via the improvement builder. Always returns false even on success; no WorldBuilder command, so not undoable. Plot-vs-x,y form is guessed from arg count (exactly 2 args after self = plot,bool).
SetImprovementType mgr:SetImprovementType(x, y, improvement [, player]) or mgr:SetImprovementType(plot, improvement) 1 boolean (result of SetImprovement) yes high Sets the improvement on a plot (optionally with owner player) via WorldBuilder::Map::Manager::SetImprovement. Arg-count heuristic: exactly 2 args after self = plot,improvement; 3+ = x,y,improvement,player, so plot,improvement,player is read as x,y form.
SetPlotValue mgr:SetPlotValue(plotIndex, valueType, [name,] value) nothing unknown medium Stores a per-plot value entry (type, optional name, integer or string value) through WorldBuilder::Map::Manager::SetPlotValue. Silent no-op when plot arg unparsable. Number values truncated to int. Undo not visible in callee data.
SetResourceType mgr:SetResourceType(x, y, resource [, amount]) or mgr:SetResourceType(plot, resource) 1 boolean (result of SetResource) yes high Sets the resource (with amount) on a plot via WorldBuilder::Map::Manager::SetResource. Arg-count heuristic as other Set* methods. Placement validity not checked in wrapper; use CanPlaceResource first.
SetRevealed mgr:SetRevealed(x, y, bRevealed, player) 1 boolean yes (probably) medium Reveals or hides one plot for a player via WorldBuilder::Map::Manager::SetRevealed. Needs 3+ args after self; wrapper tells plot helper 2 args remain, so x,y form is probably required (inference).
SetRouteType mgr:SetRouteType(x, y, route [, flag]) or mgr:SetRouteType(plot, route) 1 boolean (result of SetRoute) yes high Sets the route on a plot via WorldBuilder::Map::Manager::SetRoute. Arg-count heuristic: plot,route,flag is read as x,y form.
SetTerrainType mgr:SetTerrainType(plot, terrain) 1 boolean (result of SetTerrain) yes (probably) medium Sets the terrain of a plot via WorldBuilder::Map::Manager::SetTerrain, and removes the plot's resource if it no longer fits the new terrain. Several commands are issued for one call. Only the plot-object form is parsed (helper told 1 arg).

Player manager

Initialize and remove players, set leader, era, gold, faith, civics, technologies and start positions. 25 methods.

Method Call Returns Undo Confidence What it does, and cautions
AddPlayer mgr:AddPlayer(flag) -> playerID (exactly one argument) 1 number: new player id, or -1 if the argument count is not exactly one unknown medium Adds a new player slot via WorldBuilder::Player::Manager::AddPlayer and returns its player id. Wrapper returns -1 without acting when called with no argument or with 2+ arguments. No self check (ScopedInstance::GetInstance not called).
ClearPlayerStartingPosition mgr:ClearPlayerStartingPosition(playerID) nothing yes high Clears the start position assigned to a given player. Silent no-op when called without the argument. Player id not range-checked in the wrapper.
ClearStartingPosition mgr:ClearStartingPosition(plot location) nothing yes high Clears whatever start position (player/leader/civ/random) is set on the given plot. Silent no-op if no args or the plot location cannot be parsed. No feedback whether a start position existed.
GetMaxPlayers mgr:GetMaxPlayers() 1 number: constant 64 (immediate 0x4050000000000000) no high Returns the constant maximum player count. Hard-coded constant, does not query game config.
GetPlayerConfig local cfg = mgr:GetPlayerConfig(playerID) 1 value: table with Name, SlotStatus, IsHuman, IsFullCiv, IsCityState, IsBarbarian, IsFreeCities, Civ, Leader, CivLevel, Era, Gold, Faith; or nil on bad argument no (probably) medium Returns a table describing a player slot's configuration (name, slot status, civ, leader, era, gold, faith). Returns nil unless exactly one numeric arg and id < 64. IsHuman is SlotStatus==3. Civ/Leader/CivLevel/Era may be nil. Gold/Faith are 0 if the player is not initialized (fixed-point >>8, whole units). Name falls back to localized text plus id+1 without a civ definition.
GetSlotStatus mgr:GetSlotStatus(playerID) 1 number: SlotStatus enum value; returns 2 when arg missing, not a number, or id >= 64 no high Returns the configured slot status number of a player slot. Fallback value 2 on bad input is indistinguishable from a real status 2. Enum meanings not decoded (GetPlayerConfig treats 3 as human).
GetStartPositionInfo local info = mgr:GetStartPositionInfo(plot location) 1 value: nil if none/out of map/bad args; else table {Type='Player',Player=id} / {Type='Leader',Leader=n} / {Type='Civilization',Civilization=n} / {Type='RandomMajor'} / {Type='RandomMinor'} no (probably) medium Describes the start position marker on a plot, if any. Leader/Civilization values are raw numbers (probably type indices, not decoded). Plot is bounds checked against map size.
GetStartPositionPlayer mgr:GetStartPositionPlayer(plot location) 1 number: player id, or -1 if no player start there, bad args or out of map no high Returns the player id whose start position is on the given plot. -1 is also returned if the plot holds a leader/civ/random start (only the Player kind is reported).
InitializePlayer mgr:InitializePlayer(playerID) -> true 1 boolean: false if no argument; otherwise always true (result of the C++ call is ignored) yes high Initializes (creates the in-game player for) a player slot. Return value true does not prove success. Player id not range-checked in the wrapper.
IsPlayerInitialized mgr:IsPlayerInitialized(playerID) 1 boolean (false if no argument) no high Tells whether a player slot has been initialized. No argument gives false, not an error.
PlayerHasCivic mgr:PlayerHasCivic(playerID, civicIndex) 1 boolean no high Checks whether an initialized player has a civic. Returns false for wrong arg count, non-number args (a civic name string yields false), id >= 64 or uninitialized player. Does not accept hashes unlike SetPlayerHasCivic.
PlayerHasTech mgr:PlayerHasTech(playerID, techIndex) 1 boolean no high Checks whether an initialized player has a tech. Returns false for wrong arg count, non-number args, id >= 64 or uninitialized player. Does not accept hashes unlike SetPlayerHasTech.
SetCivilizationStartingPosition mgr:SetCivilizationStartingPosition(civType, plot location) nothing yes high Places a civilization start marker on a plot. Silent no-op if too few args or plot cannot be parsed. Civ taken as plain number, not hash.
SetLeaderStartingPosition mgr:SetLeaderStartingPosition(leaderType, plot location) nothing yes high Places a leader start marker on a plot. Silent no-op if too few args or plot unparsable.
SetPlayerEra mgr:SetPlayerEra(playerID, era) nothing yes high Sets a player's era. Silent no-op if fewer than two args. Behavior for an uninitialized player or invalid era is inside Manager::SetEra (not decoded).
SetPlayerFaith mgr:SetPlayerFaith(playerID, amount) nothing yes high Sets a player's faith amount. Both arguments required else silent no-op. Fractions truncated to integer.
SetPlayerGold mgr:SetPlayerGold(playerID, amount) nothing yes high Sets a player's gold amount. Both arguments required else silent no-op; fractions truncated. Player validity checks are inside Manager::SetGold (not decoded).
SetPlayerHasCivic mgr:SetPlayerHasCivic(playerID, civic, progress) nothing yes (probably) medium Grants or removes a civic for a player, with a progress value. Wrapper requires all three args (count > 3 with self); with two it silently does nothing even though progress looks optional. Meaning of progress (probably 0 = remove) not decoded.
SetPlayerHasTech mgr:SetPlayerHasTech(playerID, tech, progress) nothing yes (probably) medium Grants or removes a tech for a player, with a progress value. Wrapper requires all three args; with two it silently does nothing. Meaning of progress (probably 0 = remove) not decoded.
SetPlayerLeader mgr:SetPlayerLeader(playerID, leader [, civ [, civLevel]]) nothing (wrapper pushes a boolean but returns 0 values) yes (probably) medium Sets a player's leader, and optionally civilization and civilization level. Silent no-op with fewer than 2 args. Omitted civ/level become -1; effect is inside Manager::SetPlayerLeader (not decoded).
SetPlayerSlotStatus local ok = mgr:SetPlayerSlotStatus(playerID, status) 1 boolean: true when two args were given (C++ result ignored), false otherwise no (probably) medium Sets the configured slot status of a player slot. true does not prove the status changed. Valid status values not decoded.
SetPlayerStartingPosition mgr:SetPlayerStartingPosition(playerID, plot location) nothing yes high Places a player's start marker on a plot. Silent no-op if too few args or plot unparsable. Player id not validated in the wrapper.
SetRandomMajorStartingPosition mgr:SetRandomMajorStartingPosition(plot location) nothing yes high Places a random-major-civ start marker on a plot. Silent no-op if no args or plot unparsable.
SetRandomMinorStartingPosition mgr:SetRandomMinorStartingPosition(plot location) nothing yes high Places a random-minor-civ (city-state) start marker on a plot. Silent no-op if no args or plot unparsable.
UninitializePlayer mgr:UninitializePlayer(playerID) nothing yes high Uninitializes a player, removing its units and cities first. Destructive: deletes all units and cities of the player. Silent no-op without argument.

Configuration manager

Map-level configuration values. 3 methods.

Method Call Returns Undo Confidence What it does, and cautions
GetMapValue WorldBuilder.ConfigurationManager():GetMapValue(type [, name]) 1 value (the ValueEntry's stored variant converted by the script system) no (probably) low Looks up a map configuration value entry in WorldBuilder::Configuration::Manager and pushes its stored value to Lua. Code reads the type from stack slot 1 (the object itself on a colon call) while SetMapValue reads slot 2; this looks inconsistent, so the type argument may be ignored or misread (probably a game bug; untested). Optional-name slot logic is odd (slot 2 tested, slot 4 read).
GetMapValues local t = WorldBuilder.ConfigurationManager():GetMapValues() 1 table no high Returns a table with the current map settings: Width, Height, IsWrapX, IsWrapY, plus MapScript and Ruleset when set. MapScript key present only if Configuration::Map::Instance::GetScript succeeds; Ruleset only if non-null. Read-only snapshot.
SetMapValue WorldBuilder.ConfigurationManager():SetMapValue(type, value) nothing unknown medium Stores a map configuration value (number as integer variant, otherwise string) under a value-type key via WorldBuilder::Configuration::Manager. Does nothing if the value argument is missing (needs at least 2 args after self). Numeric values are truncated to integers; no validation in the wrapper. Undo not visible in callee data (no Command seen), but handler is not readable.

Mod manager

The mod metadata strings of a World Builder map. 6 methods.

Method Call Returns Undo Confidence What it does, and cautions
GetKeyStringPairByIndex local key, text = mgr:GetKeyStringPairByIndex(index [, locale]) 2 values (key, text; nil for a null pointer) or nothing no (probably) medium Returns the Nth (key, string) pair of the mod's localization table for a locale. Returns nothing if index < 1, locale not found or index past the end.
GetLanguageByIndex local locale = mgr:GetLanguageByIndex(index) 1 string (nil if null) or nothing no (probably) medium Returns the locale name at the 1-based index in the mod manager's language list. Nothing returned for index < 1 or past the end.
GetString local text = mgr:GetString(key [, locale]) 1 string or nothing no high Returns the localized string stored for a key in a locale. Nothing if key missing/not found.
RemoveString mgr:RemoveString(key [, locale]) 1 boolean no (probably) medium Removes a key from a locale's localization pairs. Needs at least 1 arg. No Command seen in callee data (not undoable).
SetKeyStringPairByIndex mgr:SetKeyStringPairByIndex(index, key, text [, locale]) 1 boolean no (probably) medium Replaces the key and string of the Nth entry in a locale's localization table. False unless 3+ args and index >= 1. Not undoable per callee data.
SetString mgr:SetString(key, text [, locale]) 1 boolean (result of LocalizationStringTable::Add) no (probably) medium Adds a (key, text) pair to the mod's localization table for a locale. False unless 2+ args. Whether it overwrites an existing key is not visible. No undo command.

Provenance

Method names, registration state and addresses come from the Lua registration tables of the GameCore DLL. Argument forms, return values and undo behaviour come from reading each wrapper's decompilation and the direct and second-level callees in the call graph; where the code was not visible the entry says "probably" and carries a lower confidence. Test these in a scratch game before using them in a release, and report what you observe.