Inherit current map (remove/add resources)

Salmo

Chieftain
Joined
Oct 24, 2016
Messages
64
Working on a mod, I want to delete/change resources on tiles on an already generated map. Trying to figure out how to inherit the current map ? class so I can access the resources. I see there is a WorldBuilderMapIcons.lua file in the game ..\Steam\steamapps\common\Sid Meier's Civilization VI\Base\Assets\UI folder which has functions to "UnloadResourceIconAt" and "SetResourceIcon", so how to expose those functions & the map to my mod LUA code ?
 
Have you considered overriding the map generator itself? Lua files for the map generator are at <install path>/Base/Assets/Maps/Utility. The MapUtilities.AddGoodies() method is usually the last step in map generation, so if you want access to a completely finished map (including goody-huts), that would be one way to do it.

Other places where you could add your code to modify resources:
  • AssignStartingPlots.Create() - access to civ starting positions and all resources
  • ResourceGenerator.Create() - access to resources that are not devoted to civ-starts; AssignStartingPlots might override these
 
Working on a mod, I want to delete/change resources on tiles on an already generated map. Trying to figure out how to inherit the current map ? class so I can access the resources. I see there is a WorldBuilderMapIcons.lua file in the game ..\Steam\steamapps\common\Sid Meier's Civilization VI\Base\Assets\UI folder which has functions to "UnloadResourceIconAt" and "SetResourceIcon", so how to expose those functions & the map to my mod LUA code ?
ResourceBuilder.SetResourceType(pPlot, ResourceID, num)

for a standard civ6 game, num always = 1, but a plot can yield more than 1 unit of a resource.
 
and a ResourceID of -1 means no resource, so you can remove resources using the same function:

ResourceBuilder.SetResourceType(pPlot, -1);


Basically, all the functions used to generate the map in the first place are still available to your code during gameplay. I recommend looking at mapscripts for working examples of code, as well as at map utility scripts like ResourceGenerator.lua.
 
Thankyou all. I can now remove & add resources onto an already generated map using:
Code:
ResourceBuilder.SetResourceType(pPlot, -1)                   -- remove the resource on pPlot from map
ResourceBuilder.SetResourceType(pPlot, iResourceType, 1)     -- add resource with index iResourceType onto the map at pPlot
 
Back
Top Bottom