Quick Modding Questions Thread

Can anyone please help me confirm that every user has Documents\my games\Sid Meier's Civilization VI\Cache folder regardless of their settings right? I have been modding and my PC is a dev PC so I am not sure if it's consistent for every end-user. Do they have to turn on Firetuner once for that file to exist (as for me the file is updated even with that option off). Is the path consistent (assume I can get correct path to Documents), or can it be changed somehow?
 
Yes, each user has their own My Documents ~stuff~ that isn't affected by other users. The cache files are automatically created by the game when it starts if they don't already exist. No firetuner required.
 
Is there a way to make a civilization that has the unique ability to have +x amount of gold in each city per turn?
 
Is there a way to make a civilization that has the unique ability to have +x amount of gold in each city per turn?
I see 2 options: you can create a simple lua code which will calculate and add additional gold on turn start but there may be problems with calculating next turn income you may need to check this thing or you can create new city modifier and bound it to new civilization ability (I don't know how exectly it should be done maybe someone who is more experienced in modifiers could help).

Lua code for changing gold:
Code:
local pPlayer = Players[ playerID ];
pPlayer:GetTreasury():ChangeGoldBalance( iGoldGained );
 
I insert the iGoldGained calculation:
Code:
   local pPlayer = Players[ eplayerID ];
   for n, pCity in pPlayer:GetCities():Members() do
      n = n + 1;
   local iGoldGained = n * X_AMOUNT_OF_GOLD_PER CITY;
   pPlayer:GetTreasury():ChangeGoldBalance( iGoldGained );
Note: ChangeGoldBalance is available only in gameplay script context

I suppose, this is easier to do in XML, SQL. But I have little experience with either, and in doubt: Lua works all the time - somehow. :)

edit: Does Players:GetCities():GetCount return the number of cities directly? :D
 
Last edited:
I insert the iGoldGained calculation:
Code:
   local pPlayer = Players[ eplayerID ];
   for n, pCity in pPlayer:GetCities():Members() do
      n = n + 1;
   local iGoldGained = n * X_AMOUNT_OF_GOLD_PER CITY;
   pPlayer:GetTreasury():ChangeGoldBalance( iGoldGained );
Note: ChangeGoldBalance is available only in gameplay script context

I suppose, this is easier to do in XML, SQL. But I have little experience with either, and in doubt: Lua works all the time - somehow. :)

edit: Does Players:GetCities():GetCount return the number of cities directly? :D

Yes, you can use GetCities():GetCount() but if I created such modifier I would also check if city has at least 1 gold income to be able generate additional income something like:

GoldPerTurn = Round( pCity:GetYield( YieldTypes.GOLD ), 1);

you can check the CitySupport.lua to see if you need it.
 
  • Like
Reactions: cvb
Is there a way to make a civilization that has the unique ability to have +x amount of gold in each city per turn?
<ModifierType>MODIFIER_SINGLE_CITY_ADJUST_YIELD_CHANGE</ModifierType>

You would have to use a MODIFIER_PLAYER_CITIES_ATTACH_MODIFIER modifier tied to the Leader or Civ trait which then attaches a modifier that has the ModifierType of MODIFIER_SINGLE_CITY_ADJUST_YIELD_CHANGE. Modifier arguments then specifies YieldType of YIELD_GOLD and Amount of 'X'

Should really be no need for lua in this case.
 
Last edited:
  • Like
Reactions: cvb
Is the level cap for Spies configurable? Is it in SQL database or hard-coded? How about Rock Bands?
 
Found it, it's in GlobalParameters, called ESPIONAGE_MAX_LEVEL and "ROCK_BAND_MAX_LEVEL"/"ROCK_BAND_MAX_PROMOTIONS" (I wonder what's the difference and which one is being used).
 
There's a hard-coded limit to how high that can be, or at least there was some time ago (I raised it to 6 but could only get a max of 3 (4?) promotions).

I was able to promote spy so it had all available promotion perks (i don't remember but i think it get 18 lvls) using my mod Cheat Menu for Units. So I think there is no hardcoded lvl limit or it is implemented in some unnatural way.
 
I was able to promote spy so it had all available promotion perks (i don't remember but i think it get 18 lvls) using my mod Cheat Menu for Units. So I think there is no hardcoded lvl limit or it is implemented in some unnatural way.

I sit corrected. Thanks!
 
Is there a comparable event to "TERRITORIAL_EXPANSION_WAR_INITIATED" for Holy and Colonial Wars, or has firaxis only included the ones used for the current leaders? If not how would I trigger a modifier to occur upon the use of a specific casus belli?
 
I was able to promote spy so it had all available promotion perks (i don't remember but i think it get 18 lvls) using my mod Cheat Menu for Units. So I think there is no hardcoded lvl limit or it is implemented in some unnatural way.

Yes this is correct, I have just tested for my mod. However, you need to remember the value is "Level" and not "Promotion". So for example my mod give 6 promotions for Spies, then I need to cap the Spy level at 7 (starting level = 1).
 
Is there an easy way to get a breakdown of the total great person points per turn for a given civ and great person type?

I'm currently trying to track down the reason why a civ has x scientist points per turn when they should have y but I can't see anything in the logs directory with sufficient detail.
 
I want to run some of my code in UI context so I put a ReplaceUIScript with InGame context. However, my other mod (Cheat Panel) which also uses that Context stopped working. Why is that? Only one allowed? Is there anyway I can create an UI context? My script just need access to some methods, but do not provide any real UI.

Code:
    <ReplaceUIScript id="SpyPromotionTreeUI">
      <Properties>
        <LoadOrder>150</LoadOrder>
        <LuaContext>InGame</LuaContext>
        <LuaReplace>spypromotiontreeUI.lua</LuaReplace>
      </Properties>
    </ReplaceUIScript>

How do I properly inject spypromotiontreeUI.lua to any UI context without breaking other mod?

EDIT: seem not problem with the Context, I tried using another context (UnitPanel), Cheat Panel still stops working. Now I wonder what I break. Here is the script:

Code:
print("Loaded Spy UI");

spyPromotingUnits = {};

...

Events.UnitAddedToMap.Add(SPT_UnitCreated);
Events.UnitPromoted.Add(SPT_CheckSpyPromotion);

You have replaced a lot of game code which is located in file InGame.lua with few of your functions. This is bad approach in general and I'd suggest you to find a better way to integrate your mod but if you want to stick with this approach you should copy the content of InGame.lua into your script file and append your code after the original code.
 
Wow... I never knew it was that bad... I only thought ReplaceUIScript simply runs something to override them. Pretty sure last time I used ReplaceUIScript, it only changes what I need to change.

What is the proper way to do that then? I need to get unit's level, which only available in ContextUI, then I plan to use LuaEvents to communicate with Script context.
 
Top Bottom