Quick Modding Questions Thread

I need to figure out a way to give the player 2 of a certain resource after a unit dies. Specifically for GS, I want a unit that costs 2 of a unique resource to make, and refunds those 2 when it dies. Hopefully this can be done easily, maybe with functions from before GS, even. Does anyone know a relevant effect in a mod or gameplay that exists already, or maybe a relevant lua function?
 
Hi, "No Missionaries" fails because of foreign key constraints. I fixed that in its SQL file, i.e. modified D:\SteamLibrary\steamapps\workshop\content\289070\1195010193\CNO_NoMissionaries.sql , but it looks like the game doesn't use my modified version. Is there some trick to make it reload that SQL?
 
The game auto-updates anything you've subscribed to from Steam. If an update is made to the mod on the Steam Workshop, the game will auto-download this new version and any changes you have made within such a mod will go *poof*.

Every time you start the game (or return to the main menu from within an active game-session), the game reloads all code from mods when you start a new game or reload a saved game. When you reload a saved game there are some restrictions on what mods will be loaded regardless of whether they are enabled or not.
  • For example, if you subscribed to a new mod on Steam, it will show as being enabled in the Additional Content menu but as a general rule will not be implemented when you reload a saved game -- the new mod you subscribed to as a general rule will only be implemented when you start a brand new game.
  • Even starting a new game, and then going back to a saved game that did not have the new mod active will not make that new mod actually implement for the save that was made without the mod as part of it.

I would look for syntax error reports in Database.log.
 
Would it be possible to make units interact with tile yields? I want to make a mod where units take 10 damage a turn, while healing 5 per turn per food on the tile. Is that even possible with the breadth of modding?
IDK if there are modifiers allowing that, but it can be done in a Lua Gameplay script.
 
Is there a way to make an improvement be required to be placed next to another improvement? Or is it possible to add a resource to an improvement when you place it?
 
Two short questions:
1) Am I correct in assuming that the yield from a citizen slot in a district is simply a plot yield? (i.e. the citizens work the district plot tile like they would work any other tile)
2) Is it possible to set or change plot yields through LUA? (without attaching a modifier that is, since afaik that's permanent, as we can't remove modifiers (yet?)).
 
Last edited:
#1 Citizens work the slots provided by the buildings within the district. "District_CitizenYieldChanges" determines the effect each such citizen-specialist within the district has. So it's sort of kind of like a plot yield, but not so far as effects of modifiers are concerned.
#2 Nope. All you can do is attach a modifier that alters the yields of a plot. Whether you directly add a modifier to a player/city or add/remove a building that contains the modifier, you are still adding or removing a modifier rather than directly changing a plot-yield via lua.
 
This should be rather obvious, but I keep getting side tracked everytime I try to figure this out. I want to increase free amenities either by era or by government type. How would I go about this?

This is to help make AI more aggressive, inspired by recent tests showing that AI expansion is greatly influenced by amenity levels. I've already slightly increased the base free amenities, but want something that scales with time.
 
Question. I made changes in my mod file that I'm using for one save, but the changes don't apply when I reload that save. It is just a value change, no line added. Only line I added was the AffectsSavedGames line in .modinfo but that didn't do anything.
Any way I can make it reload the save?
 
Question. I made changes in my mod file that I'm using for one save, but the changes don't apply when I reload that save. It is just a value change, no line added. Only line I added was the AffectsSavedGames line in .modinfo but that didn't do anything.
Any way I can make it reload the save?
If you set AffectsSavedGames to '0' this will allow the mod to be added or removed from the list of enabled mods when a save is reloaded. However, doing so to a mod that was set as affecting saved games (the default value for AffectsSavedGames) will only work properly on new games, and may or may not work properly for a saved game since part of the save game process is to 'tag' the save-file with the list of mods that are needed in order for the save to work properly, and this 'tagging' system works based on the original setting of AffectsSavedGames for every mod enabled when the new game is first saved. Succeeding saves preserve the original list of 'tagged mods' so far as I am aware, since this list is loaded again when the saved game is loaded.

Mods are generated by ModBuddy with AffectsSavedGames set to '1' by default. No setting for AffectsSavedGames defaults to '1'. Adding AffectsSavedGames with a value of '0' after starting a game with that mod enabled under an AffectsSavedGames value of '1' is almost certainly your problem, and should never be done.

Editing a modinfo file should also never be done as a general rule if one intends to reload a save that was using that mod. At the very least this will cause the order mods are loaded to be re-arranged (especially when the makers of multiple mods do not provide LoadOrder values within their mods' various Actions).

For the general user of mods, and the less-experienced mod-maker, the rule is also never to alter anything within a mod without starting an entirely new game.

-------

Note that I said "almost certainly". The rest of the probable "certainties" is a syntax error or other sort of mistake made in the edits made elsewhere in the mod. If you make a syntax or other fatal code-error in an XML or SQL file, the game will cease reading anything within that file at that point, and this often leads people to think "this mod isn't working". In fact the mod will be working in the sense of the game is running the mod, just not the code within the mod.

Look to Database.log at C:\Users\[Your User Name Here]\Documents\My Games\Sid Meier's Civilization VI\Logs for error messages that might be reported there re the mod that seems not to be working.
 
Last edited:
Hi all. What are the events (if there are at all) for the following actions:
- a rock band performed a concert,
- a military engineer built a railroad (1 piece).
The Rock Band I'm not sure of yet. For the military engineer thing there's nothing directly for when specifically an engineer makes a railroad chunk.
Code:
Events.UnitChargesChanged(iPlayer, iUnitID, iNumberChargesRemaining, iPreviousNumberCharges)

Events.RouteChanged(iX, iY)

Events.RouteRemovedFromMap(?)
 
I'm trying to make my first mod (allow Stepwells to be built on floodplains), and it's just straight up not loading into the game.

I followed the tutorials to get ModBuddy, build a project, and build the mod. It shows up in the Additional Content screen, and I'm able to enable it. However, when I create a game it doesn't show up in the list of enabled mods on the "Esc" screen. What might I be doing wrong?


Code:
<?xml version="1.0" encoding="utf-8"?>
<Mod id="71d8540c-4f7e-44a4-ba79-3d9688511be7" version="1.1">
  <Properties>
    <Name>Stepwells on Floodplains</Name>
    <Description>This mod allows India to build the Stepwell improvement on Floodplains.</Description>
    <CustomProperties xmlns="http://schemas.microsoft.com/developer/msbuild/2003">2.0</CustomProperties>
    <Teaser>Build Stepwells on floodplains</Teaser>
    <Authors>hbarsquared</Authors>
    <AffectsSavedGames>0</AffectsSavedGames>
    <CompatibleVersions>2.0</CompatibleVersions>
  </Properties>
  <Files>
    <File>Improvements.xml</File>
  </Files>
</Mod>

Code:
<?xml version="1.0" encoding="utf-8"?>
<!-- GameData1 -->
<!-- Author: hbarsquared -->
<!-- DateCreated: 3/17/2019 10:09:57 AM -->
<GameData>
    <GameInfo>
        <Improvement_ValidFeatures>
            <Row ImprovementType="IMPROVEMENT_STEPWELL" FeatureType="FEATURE_FLOODPLAINS"/>
        </Improvement_ValidFeatures>
    </GameInfo>
</GameData>

upload_2019-3-17_12-28-49.png


I tried looking through some log files but I have no idea what I might be looking for. I've also disabled all other community mods so that nothing's interfering.
 
  1. Mods that have AffectsSavedGames set to "0" will not always show in the list. But you should have your setting as "1" because it makes a fundamental change to where an improvement can be placed. With the setting at "1" you will be required to start a completely new game in order for the mod to actually take effect.
  2. You have no action defined for what the game should do with file Improvements.xml. You will not get an error report in any log for this type of mistake
    Code:
      <InGameActions>
        <UpdateDatabase id="BuilderScaling">
          <Properties>
            <LoadOrder>150</LoadOrder>
          </Properties>
          <File>NoBuilderScaling.xml</File>
        </UpdateDatabase>
      </InGameActions>
      <Files>
        <File>NoBuilderScaling.xml</File>
      </Files>
    The LoadOrder settting under the action's "Properties" is not strictly required but it makes things more seamless as this means your mod's code will load into the game after all the DLC including the expansions.
  3. You have fatal syntax errors in the Improvements.xml file.
    Code:
    <GameData>
        <GameInfo>
    • You must use one or the other of <GameData> or <GameInfo> but not both within the same file.
    • If you start with <GameData> in your file you must end with </GameData>. You cannot for example start with <GameData> and end with </GameInfo>
 
Sweet, thanks! That got it partially working, though I don't fully understand the actions thing.

I can now build Stepwells on Desert floodplains, but not the new GS-style floodplains on grassland and plains. For farm civopedia entry, it lists all the floodplains discretely, but I'm not seeing any corresponding entries in the XML.
upload_2019-3-17_13-15-46.png

(The Stepwell pedia entry just lists desert floodplains.)

I'm certain grass/plains floodplains are treated differently that desert floodplains, but I'm not sure how.
 
Hey, long time lurker here.

How do I replace a file in : "\Sid Meier's Civilization VI\DLC\Expansion2\Maps\Utility"? Specifically I want to replace the "CoastalLowlands.lua" file.

I have seen that YNAMP, by the great @Gedemon, has replaced the "AssignStartingPlots.lua" file and tried to nose around in the .modinfo and do the same thing, but I cant get it to work. When I start up a new game it's effects is not active and the mod is not shown in the Esc menu, but it is enabled in the Additional Content in the main menu. I have tested the actual code by directly modifying the file in my game install folder so I know that part works.

I can't upload the .modinfo file, so I'll paste it here:
<?xml version="1.0" encoding="utf-8"?>
<Mod id="f9eac68a-1631-49d7-8153-c54828d2db60" version="1">
<Properties>
<Name>Nerevatar's Real Climate Change</Name>
<Description>Adds inland flooding, and some adjustment to Climate Change</Description>
<LoadOrder>99999</LoadOrder>
<Teaser>Adds inland flooding, and some adjustment to Climate Change</Teaser>
<Authors>Nerevatar</Authors>
<AffectsSavedGames>0</AffectsSavedGames>
<CompatibleVersions>2.0</CompatibleVersions>
</Properties>
<InGameActions>
<ImportFiles id="Nere_Flooding">
<Properties>
<LoadOrder>99999</LoadOrder>
</Properties>
<File>Override/CoastalLowlands.lua</File>
</ImportFiles>
<!-- <UpdateDatabase id="Nere_Climate">
<Properties>
<LoadOrder>99999</LoadOrder>
</Properties>
<File>Climate_Change_and_Disasters.xml</File>
</UpdateDatabase> -->
</InGameActions>
<Files>
<File>Climate_Change_and_Disasters.xml</File>
<File>Override/CoastalLowlands.lua</File>
</Files>
</Mod>
 
Last edited:
Nevermind, I think I found it. I was only looking in the base file, I found the DLC and they just added two more floodplains types.
 
Hi!
Question: Am i able to include base-game files (ui) in my mod and just extend/overwrite functions to prevent replacing the entire base-game-file?
Ive seen the EXP1 and EXP2 lua files doing this, tried it but it doesnt seem to work for mods.

As an example i wanto include the DiplomacyTradeView.lua and just replace (overwrite) a single function instead of the entire file.
If this is not possible, is there any other best-practices of "extending" or "overwriting" parts of existing base-lua-files?

Thanks!
 
@Fampat Ofc you can do that with mods. Btw, DLCs are ”mods” too.
You must use ReplaceUIScript, same way as firaxis does in Expansion1 and Expansion2 folders. Many of my mods work that way.
This however is not as easy as just replacing entire file by using ImportFiles. Which is probably the reason why many mods just copy the file, even if they change just few lines in it.
Edit. This replace command is a new thing in Civ6 and firaxis is using it to modifiy all existing files in UI in all DLCs. I would say that this is the „official” way. If this „best-practice” - it depends on the amount of changes. If you want to change small parts of the file, you should use Replace, but if you are going to heavily modify the file and eventually end-up replacing almost functions, then ImportFiles is much better way.
 
Last edited:
  • Like
Reactions: cvb
@Infixo Thanks alot for the hint!
I think ive overseen the ReplaceUIScript-Part!
Ill try that out!

And yes, ill often just need to adjust a few lines but break complete compatibility with other mod which i can prevent this way!
 
Back
Top Bottom