[LUA] Script not working for WLTKD in cities.

Nyjene

Chieftain
Joined
Feb 13, 2018
Messages
9
Greetings,

Can someone read my script quickly ?

Code:
GameEvents.PlayerDoTurn.Add(function(ePlayer)
    local pPlayer = Players[ePlayer]
    if pPlayer:GetCivilizationType() == GameInfoTypes.CIVILIZATION_MYCIV then
        for pCity in pPlayer:Cities() do
            if pCity:GetWeLoveTheKingDayCounter() > 0 then
                pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_WLTKD_TRAIT, 1)
            else
                pCity:SetNumRealBuilding(GameInfoTypes.BUILDING_WLTKD_TRAIT, 0)
            end
        end
    end
end

The idea is to put a dummy building that grants +25% production, gold and science when the city is holding a WLTKD. It is linked to a UA. Except it doesn't work.

Here is the dummy building :
Code:
<!-- Called by LUA for WLTKD -->

    <Buildings>
        <Row>
            <Type>BUILDING_WLTKD_TRAIT</Type>
            <BuildingClass>BUILDINGCLASS_WLTKD_TRAIT</BuildingClass>
            <Cost>-1</Cost>
            <GoldMaintenance>0</GoldMaintenance>
            <Help>TXT_KEY_BUILDING_WLTKD_TRAIT_HELP</Help>
            <Description>TXT_KEY_BUILDING_WLTKD_TRAIT</Description>
            <ArtDefineTag>NONE</ArtDefineTag>
            <MinAreaSize>-1</MinAreaSize>
            <NeverCapture>true</NeverCapture>
            <HurryCostModifier>-1</HurryCostModifier>
            <IconAtlas>ICON_ATLAS_MYCIV</IconAtlas>
            <PortraitIndex>1</PortraitIndex>
        </Row>
    </Buildings>
    <Building_YieldModifiers>
        <Row>
            <BuildingType>BUILDING_WLTKD_TRAIT</BuildingType>
            <YieldType>YIELD_PRODUCTION</YieldType>
            <Yield>25</Yield>
        </Row>
        <Row>
            <BuildingType>BUILDING_WLTKD_TRAIT</BuildingType>
            <YieldType>YIELD_GOLD</YieldType>
            <Yield>25</Yield>
        </Row>
        <Row>
            <BuildingType>BUILDING_WLTKD_TRAIT</BuildingType>
            <YieldType>YIELD_SCIENCE</YieldType>
            <Yield>25</Yield>
        </Row>
    </Building_YieldModifiers>
    <BuildingClasses>
        <Row>
            <Type>BUILDINGCLASS_WLTKD_TRAIT</Type>
            <DefaultBuilding>BUILDING_WLTKD_TRAIT</DefaultBuilding>
            <Description>TXT_KEY_BUILDINGCLASS_WLTKD_TRAIT</Description>
        </Row>
    </BuildingClasses>
Both the XML and the LUA files are loaded into the solution.

It's an old civilization that I have made years ago and still work. I'm just reworking the UA. So it shouldn't be a problem involving the whole mod. I have a slow upload connection, but if you really need the whole attachment, tell me and I'll do it.

By the way, what does the (ePlayer) mean ? If I do understand well, it should be a custom name to the function right ?
 
Last edited:
Oh yeah indeed, I do understand now. I struggle a bit on how to use properly () with LUA. For example, when there is a xxx() is it a placeholder for readability or it has to be there even if not used ?
 
Top Bottom