• Civilization 7 has been announced. For more info please check the forum here .

[GS] Changing a specific map's Map Script -OR- Randomizing resources

PumpkinCake

Chieftain
Joined
Jun 1, 2023
Messages
1
How do I change a custom WorldBuilder map's Map Script? I'm able to finagle it to allow me to change the field, but it won't actually save the setting.
Failing that, how can I randomize resources on a map I built in the WorldBuilder?

I made a map in the Map Editor named Six Hexes. The concept is simple. There are 6 large hexagons (13 tiles to a side) honeycombed together. Each is bounded by a 1 tile wide mountain range blocking all egress. The idea is each Civ would start completely isolated or sharing their hex with one or two other Civs (plus possibly City-States) and can only leave with flight or the mountain tunnel technology. 3 cold hexes, 3 hot hexes, with different features but some commonalities (hills, trees, a lake in the center, and 3 rivers, 2 of which have floodplains). The half hexes were filled with water so Civs (hopefully) wouldn't spawn in an area half as large as everyone else's.

Spoiler Example Screenshot :
20230531213958_1.jpg


I'm aware I can randomly place the resources ONCE and permanently, but I wanted some replayability, so I looked up a way to randomize the resources of a hand-placed map so they're different every game. The only result I could find was this thread:
https://forums.civfanatics.com/threads/how-to-make-a-map-with-randomized-resources.671006/

I made a .txt file with the code copied from that thread and renamed it to Six_Hexes.lua and placed it in the C:\Users\<Me>\Documents\My Games\Sid Meier's Civilization VI\Saves\WorldBuilder folder. I also placed it in the C:\Games\Steamlibrary2\steamapps\common\Sid Meier's Civilization VI\Base\Assets\Maps folder.
Spoiler Code Block :

Code:
include "MapUtilities"
include "ResourceGenerator"

-- ===========================================================================
function InitializeNewGame()


local resourcesConfig = MapConfiguration.GetValue("resources");
local startConfig = MapConfiguration.GetValue("start");-- Get the start config
local args = {
resources = resourcesConfig,
START_CONFIG = startConfig,
};
local resGen = ResourceGenerator.Create(args);

local gridWidth, gridHeight = Map.GetGridSize();
AddGoodies(gridWidth, gridHeight);
AddLeyLines();
end

LuaEvents.NewGameInitialized.Add(InitializeNewGame);

In the WorldBuilder inside Civ 6, I tried to edit the fields in the Map Editor to change the field "Map Script" from Continents.lua to Six_Hexes.lua. I was only able to do so by changing to the advanced editor, saving as a new map and then editing the field. If I then saved after editing the field and reloaded, the field would always revert to Continents.lua. I opened the Six_Hexes.Civ6Map file with the program DB Browser for SQLite (the same program I used to make the map dimensions 78x53) and forcibly edited that field to Six_Hexes.lua, but that change had no effect either. Opening the map in Civ 6 has it show Continents.lua as the Map Script still. If I then saved a copy, the DB Browser recognized the field as being Six_Hexes.lua still, but Civ 6 always claims its map script is Continents.lua
I also tried to add the script in ModBuddy, but I can't recount the exact steps I took, and I wanted to test if this script I found even worked before trying to put the finishing touches on my map mod.
Map Script in Civ terms seems to usually refer to scripts that generate a whole new map, so trying to Google this specific problem was impossible.

Spoiler Screenshot :
20230531213928_1.jpg


Sorry for the long post. I wanted to give as much information up front as I could. I have 3 different questions:
1) How do I apply a script to a custom map?
2) Is there a better way to randomize resources? I don't know if that code I found even works at all.
3) Is it possible to randomly generate a map where every Civilization is isolated by (initially) impassable mountains? (Is there already such a map?)

That last one would be the most useful, but I'm very new to modding, and I don't know lua or any other relevant programming languages. If anyone is willing and able to make it, feel free to steal the concept. I want to play it more than I want to make it.
 
Top Bottom