• Our friends from AlphaCentauri2.info are in need of technical assistance. If you have experience with the LAMP stack and some hours to spare, please help them out and post here.

Quick Modding Questions Thread

In LUA, how can I tell if a city was conquered, loyalty-flipped, or traded? (I think that covers all ways city ownership can change) I want to update my Key Loyalties mod for Dramatic Ages which appears to make loyalty-flipping much more common. For cities where the current owner is not the original owner, I want the ongoing max loyalty penalty to be different depending on how the city was acquired.
 
Maybe a stupid question, but I looked all around and couldn't find the answer to this:
How do I actually include a sound file in a mod?
Everyone says to not include the .wem in modbuddy, but where does it go then? Do I, after building the mod, manually stuff it in the /Platforms/[OS]/Audio?

Also, should I even use modbuddy? Most resources here seem to work without it... Sorry, I am really new to civ 6 modding, and this whole thing isn't exactly easy for me to wrap my slow brain around .-.

Edit:

Whoops didn't see LeeS' modding guide, since I only scoured through the "modding tutorial" part of the forum, and not the top-level pinned posts.

Well, turns out there is at least some documentation on what to do after all. Time to read through 400 pages I guess.
 
Last edited:
In LUA, how can I tell if a city was conquered, loyalty-flipped, or traded? (I think that covers all ways city ownership can change) I want to update my Key Loyalties mod for Dramatic Ages which appears to make loyalty-flipping much more common. For cities where the current owner is not the original owner, I want the ongoing max loyalty penalty to be different depending on how the city was acquired.
Code:
local eLastTransferType = City:GetLastTransferType();
if (eLastTransferType == CityTransferTypes.BY_GIFT) then
	--do something here
end
You have to have to have the city object first, and it is not known whether the GetLastTransferType method is only valid in User Interface scripts.

Firaxis only uses "CityTransferTypes.BY_GIFT" in their lua files so it is not clear what the designations for the other transfer types will be. But "CityTransferTypes.BY_GIFT" should actually just be a variable holding an integer value, so it should be possible to write a script that looks at transfers of cities and records into the lua log the GetLastTransferType data whenever a city changes ownership. From there you should be able to work out what the actual integer values are for a gift, loyalty-flip, conquest, etc.

Your real problem will be in transferring this information from a User Interface script to a Gameplay Script if the GetLastTransferType method is only valid in User Interface. This can be cured by using the ExposedMembers system. A search through the forum for "ExposedMembers" ought to lead you to the info you will need if GetLastTransferType is only valid in User Interface.

Alternatively, there are hook events for:
Code:
 GameEvents.CityConquered(newPlayerID, oldPlayerID, newCityID, iCityX, iCityY)
Events.CityTransfered(playerID, cityID)
Events.CulturalIdentityCityConverted(playerID, cityID, iFromPlayer)
Events.CulturalIdentityConversionOutcomeChanged(playerID, 	cityID, eOutcome)
You can make your script run whenever one of these events triggers in the game and record the necessary information for later use.
 
Maybe a stupid question, but I looked all around and couldn't find the answer to this:
How do I actually include a sound file in a mod?
Everyone says to not include the .wem in modbuddy, but where does it go then? Do I, after building the mod, manually stuff it in the /Platforms/[OS]/Audio?

Also, should I even use modbuddy? Most resources here seem to work without it... Sorry, I am really new to civ 6 modding, and this whole thing isn't exactly easy for me to wrap my slow brain around .-.

Edit:

Whoops didn't see LeeS' modding guide, since I only scoured through the "modding tutorial" part of the forum, and not the top-level pinned posts.

Well, turns out there is at least some documentation on what to do after all. Time to read through 400 pages I guess.

If you only want to edit music you dont need modbuddy. But using it, you simply create platforms/<OS>/audio folders in your modbuddy project, add your files, and you are good to go.
 
If you only want to edit music you dont need modbuddy. But using it, you simply create platforms/<OS>/audio folders in your modbuddy project, add your files, and you are good to go.
Oh wow, .-. I tried to look at sukritact's mods to find out how it worked, and I just couldn't figure it out.

Thank you very much for the answer, finally works now.
 
Firaxis only uses "CityTransferTypes.BY_GIFT" in their lua files so it is not clear what the designations for the other transfer types will be.
you can try
Code:
for k, v in pairs(CityTransferTypes) do print (k, v) end
 
This code
Code:
for k,v in pairs(CityTransferTypes) do
	print("CityTransferTypes : k = " .. k .. ", v = " .. v)
end
Gives this result in the lua log
Code:
CityTransferTypes : k = BY_GIFT, v = -1821839791
CityTransferTypes : k = BY_LIBERATION, v = 361156668
CityTransferTypes : k = BY_CULTURAL_IDENTITY, v = -738490196
CityTransferTypes : k = BY_COMBAT, v = -1173539618
So the four available city transfer types are as:
Code:
CityTransferTypes.BY_GIFT
CityTransferTypes.BY_LIBERATION
CityTransferTypes.BY_CULTURAL_IDENTITY
CityTransferTypes.BY_COMBAT
My unfounded assumption would be that "CityTransferTypes.BY_GIFT" would encompass any sort of diplomatic deal wherein a city ownership is transfered.
 
HI.
Is it possible in the LUA script to add culture to the city? I want to accelerate the city growth by adding culture. I can add plots with "WorldBuilder.CityManager():SetPlotOwner" BUT it will not increase the plot culture cost (at least, it was the result of my test). I'm creating city mover mod that actually copies the information from source city to destination city. Currently, culture seems to be difficult to change by lua script. Coundn't find city.GetCulture().ChangeCulture or something like that.

related methods:
City:GetCulture():GetNextPlotCultureCost()
City:GetCulture():GetCurrentCulture()
 
A few quick questions, mostly just feeling out feasibility of a few things while I start to learn how to mod:

1. I want to make a trade route generate power
2. My mod had a problem while creating a new game. Which logs should I be looking at?
3. I want to implement a civ 5 esque system where I have a new custom resource, and that limits how many of a certain class of unit that can be built. Is the best way to just some kind of upkeep cost?
4. Expand city radius to > 3 hexes? Or less than 3?
5. Make units with a limited lifespan (aka number of turns before death).

Are these things doable? Require a lot of scripting? Easy? Please and thank you for any help.
 
2 -> Modding, Database and Lua logs. cross-check the timestamp in database and modding when there is an error reported to identify the file.
4 -> impossible with the current tools AFAIK
5 -> can be done with a bit of Lua scripting
 
Any thoughts on what I may be doing wrong here when trying to use updates on the Moments table (via an UpdateDatabase action):

Code:
<GameData>
    <Moments>

        <Update>
            <Where MomentType="MOMENT_BARBARIAN_CAMP_DESTROYED" />
            <Set Name="LOC_MOMENT_BARBARIAN_CAMP_DESTROYED_JP" Description="LOC_MOMENT_BARBARIAN_CAMP_DESTROYED_DESCRIPTION_JP" InstanceDescription="MOMENT_BARBARIAN_CAMP_DESTROYED_INSTANCE_DESCRIPTION_JP"/>
        </Update>

        <Update>
            <Where MomentType="MOMENT_BARBARIAN_CAMP_DESTROYED_NEAR_YOUR_CITY" />
            <Set Name="LOC_MOMENT_BARBARIAN_CAMP_DESTROYED_NEAR_YOUR_CITY_JP" Description="LOC_MOMENT_BARBARIAN_CAMP_DESTROYED_NEAR_YOUR_CITY_DESCRIPTION_JP" InstanceDescription="LOC_MOMENT_BARBARIAN_CAMP_DESTROYED_NEAR_YOUR_CITY_INSTANCE_DESCRIPTION_JP" />
        </Update>

    </Moments>
</GameData>

...and then adding the associated LocalizedText (via an UpdateText action):

Code:
<GameData>
    <LocalizedText>

        <Row Tag="LOC_MOMENT_BARBARIAN_CAMP_DESTROYED_JP" Language="en_US">
            <Text>Test 1</Text>
        </Row>

        <Row Tag="LOC_MOMENT_BARBARIAN_CAMP_DESTROYED_DESCRIPTION_JP" Language="en_US">
            <Text>Test 2</Text>
        </Row>

        <Row Tag="LOC_MOMENT_BARBARIAN_CAMP_DESTROYED_INSTANCE_DESCRIPTION_JP" Language="en_US">
            <Text>Test 3</Text>
        </Row>

        <Row Tag="LOC_MOMENT_BARBARIAN_CAMP_DESTROYED_NEAR_YOUR_CITY_JP" Language="en_US">
            <Text>Test 4</Text>
        </Row>

        <Row Tag="LOC_MOMENT_BARBARIAN_CAMP_DESTROYED_NEAR_YOUR_CITY_DESCRIPTION_JP" Language="en_US">
            <Text>Test 5</Text>
        </Row>

        <Row Tag="LOC_MOMENT_BARBARIAN_CAMP_DESTROYED_NEAR_YOUR_CITY_INSTANCE_DESCRIPTION_JP" Language="en_US">
            <Text>Test 6</Text>
        </Row>

    </LocalizedText>
</GameData>
 
1st:

Code:
InstanceDescription="MOMENT_BARBARIAN_CAMP_DESTROYED_INSTANCE_DESCRIPTION_JP"
vs
Code:
<Row Tag="LOC_MOMENT_BARBARIAN_CAMP_DESTROYED_INSTANCE_DESCRIPTION_JP"

2nd:

What is your LoadOrder setting for the UpdateDatabase Action ?
 
Perfect, Lee. I don't know how I missed the first one, and this was the first time I've used LoadOrder, but I looked up a few of your posts about it, set it, and now everything is good. Thanks!
 
Ok, after trying to figure out how to make a leader use voice clips by looking at Sukritact's mods to see what hierarchy I would have to make in wwise, but I just can't do it.
Is there any written source on how to do this?
 
Has anyone been able to discover more information on the Secret Societies invitations? Specifically, how each member reduces the invitation rate? I have located the Discovery chances in the SecretSocieties table, but setting those to 100 did not have an impact. Will attempt setting them to higher than 100

Update: Setting them to 999 seems to have the intended effect, no one has since had issues claiming them in multiplayer
 
Last edited:
Hi guys. I'm playing a mod that was built on the original Civ6 called Relive World Wars (RWW). I posted a question on the mod thread a couple weeks back but it doesn't look like that thread is active anymore. It's a great mod but it appears to have a flaw in the max turns setting (set at 291) and something is also strange with the years setting and the relationship to the turns. It starts out at 4000 BC and then in turn 2 becomes 1850. Looks like from there it advances one year per turn but later it slows down and in the last 50 turns was taking 10 turns per year. I've tried to find where this is managed in the mod but no luck so far. Can anyone help?

Thanks!
 
Last edited:
Back
Top Bottom