rockingrocky
Chieftain
- Joined
- Jun 28, 2015
- Messages
- 2
I am currently making a civilization that gives 1 culture to every merchant specialists.
I made a dummy building that give 1 culture yield and a lua script that should give 1 dummy building per merchant specialist.
I adapted this script from the summa mod on steam workshop.
However, nothing happens when i choose the specialist merchant slot, no culture increase.
Heres the script:
local tSpecialists = {}
for tSpecialist in GameInfo.Specialists() do
if tSpecialist.ID == GameInfoTypes.SPECIALIST_MERCHANT then
table.insert(tSpecialists, tSpecialist.ID)
end
end
local bZiggurat = GameInfoTypes.BUILDING_AKKADIAN_MOD_ZIGGURAT
local bHongKong = GameInfoTypes.BUILDING_HONGKONG2_DUMMY
function ResetSpecialists(pCity)
pCity:SetNumRealBuilding(bHongKong, 0)
if (pPlayer:GetCivilizationType() ~= GameInfoTypes.CIVILIZATION_HONGKONG2) then
local cSpecialists = 0
for iKey, iSpecialist in ipairs(tSpecialists) do
print(GameInfo.Specialists[iKey].Description, pCity:GetSpecialistCount(iSpecialist))
cSpecialists = cSpecialists + pCity:GetSpecialistCount(iSpecialist)
end
pCity:SetNumRealBuilding(bHongKong, cSpecialists);
end
end
function PlayerDoTurn_ResetSpecialists(iPlayer)
local pPlayer = Players[iPlayer]
if (pPlayer:GetCivilizationType() ~= GameInfoTypes.CIVILIZATION_HONGKONG2) then return end
for pCity in pPlayer:Cities() do
ResetSpecialists(pCity)
end
end
if isBNW then GameEvents.PlayerDoTurn.Add(PlayerDoTurn_ResetSpecialists) end
local iSpecialistUpdateType = CityUpdateTypes.CITY_UPDATE_TYPE_SPECIALISTS
function SpecificCityInfoDirty_ResetSpecialists(iPlayer, iCity, iUpdateType)
if iUpdateType ~= iSpecialistUpdateType then return end
local iPlayer = Game.GetActivePlayer()
local pPlayer = Players[iPlayer]
if not(pPlayer:IsTurnActive()) then return end
if (pPlayer:GetCivilizationType() ~= GameInfoTypes.CIVILIZATION_HONGKONG2) then return end
local pCity = pPlayer:GetCityByID(iCity)
ResetSpecialists(pCity)
end
if isBNW then Events.SpecificCityInfoDirty.Add(SpecificCityInfoDirty_ResetSpecialists) end
Here is the xml for dummy building:
<GameData>
<Buildings>
<Row>
<Type>BUILDING_HONGKONG2_DUMMY</Type>
<BuildingClass>BUILDINGCLASS_HONGKONG2_DUMMY</BuildingClass>
<!-- Invisible Buildings -->
<Cost>-1</Cost>
<FaithCost>-1</FaithCost>
<PrereqTech>NULL</PrereqTech>
<GreatWorkCount>-1</GreatWorkCount>
<!-- Invisible Buildings -->
<Description>TXT_KEY_BUILDING_HONGKONG2_DUMMY_DESC</Description>
<Civilopedia>TXT_KEY_CIVLOPEDIA_HONGKONG2_DUMMY_TEXT</Civilopedia>
<Strategy>TXT_KEY_BUILDING_HONGKONG2_DUMMY_STRATEGY</Strategy>
<ArtDefineTag>MARKET</ArtDefineTag>
<MinAreaSize>-1</MinAreaSize>
<HurryCostModifier>25</HurryCostModifier>
<IconAtlas>NEB_BW_ATLAS</IconAtlas>
<PortraitIndex>0</PortraitIndex>
<NeverCapture>true</NeverCapture>
<NukeImmune>true</NukeImmune>
</Row>
</Buildings>
<Building_YieldChanges>
<Row>
<BuildingType>BUILDING_HONGKONG2_DUMMY</BuildingType>
<YieldType>YIELD_CULTURE</YieldType>
<Yield>1</Yield>
</Row>
</Building_YieldChanges>
<BuildingClasses>
<Row>
<Type>BUILDINGCLASS_HONGKONG2_DUMMY</Type>
<DefaultBuilding>BUILDING_HONGKONG2_DUMMY</DefaultBuilding>
<Description>TXT_KEY_BUILDING_HONGKONG2_DUMMY_DESC</Description>
</Row>
</BuildingClasses>
<Language_en_US>
<Row Tag="TXT_KEY_BUILDING_HONGKONG2_DUMMY_DESC">
<Text>Merchant Culture Dummy</Text>
</Row>
<Row Tag="TXT_KEY_CIVLOPEDIA_HONGKONG2_DUMMY_TEXT">
<Text>Just a dummy.</Text>
</Row>
<Row Tag="TXT_KEY_BUILDING_HONGKONG2_DUMMY_STRATEGY">
<Text>Just a dummy.</Text>
</Row>
<Row Tag="TXT_KEY_BUILDING_HONGKONG2_DUMMY_DESC">
<Text>Merchant Culture Dummy</Text>
</Row>
</Language_en_US>
</GameData>
I made a dummy building that give 1 culture yield and a lua script that should give 1 dummy building per merchant specialist.
I adapted this script from the summa mod on steam workshop.
However, nothing happens when i choose the specialist merchant slot, no culture increase.
Heres the script:
local tSpecialists = {}
for tSpecialist in GameInfo.Specialists() do
if tSpecialist.ID == GameInfoTypes.SPECIALIST_MERCHANT then
table.insert(tSpecialists, tSpecialist.ID)
end
end
local bZiggurat = GameInfoTypes.BUILDING_AKKADIAN_MOD_ZIGGURAT
local bHongKong = GameInfoTypes.BUILDING_HONGKONG2_DUMMY
function ResetSpecialists(pCity)
pCity:SetNumRealBuilding(bHongKong, 0)
if (pPlayer:GetCivilizationType() ~= GameInfoTypes.CIVILIZATION_HONGKONG2) then
local cSpecialists = 0
for iKey, iSpecialist in ipairs(tSpecialists) do
print(GameInfo.Specialists[iKey].Description, pCity:GetSpecialistCount(iSpecialist))
cSpecialists = cSpecialists + pCity:GetSpecialistCount(iSpecialist)
end
pCity:SetNumRealBuilding(bHongKong, cSpecialists);
end
end
function PlayerDoTurn_ResetSpecialists(iPlayer)
local pPlayer = Players[iPlayer]
if (pPlayer:GetCivilizationType() ~= GameInfoTypes.CIVILIZATION_HONGKONG2) then return end
for pCity in pPlayer:Cities() do
ResetSpecialists(pCity)
end
end
if isBNW then GameEvents.PlayerDoTurn.Add(PlayerDoTurn_ResetSpecialists) end
local iSpecialistUpdateType = CityUpdateTypes.CITY_UPDATE_TYPE_SPECIALISTS
function SpecificCityInfoDirty_ResetSpecialists(iPlayer, iCity, iUpdateType)
if iUpdateType ~= iSpecialistUpdateType then return end
local iPlayer = Game.GetActivePlayer()
local pPlayer = Players[iPlayer]
if not(pPlayer:IsTurnActive()) then return end
if (pPlayer:GetCivilizationType() ~= GameInfoTypes.CIVILIZATION_HONGKONG2) then return end
local pCity = pPlayer:GetCityByID(iCity)
ResetSpecialists(pCity)
end
if isBNW then Events.SpecificCityInfoDirty.Add(SpecificCityInfoDirty_ResetSpecialists) end
Here is the xml for dummy building:
<GameData>
<Buildings>
<Row>
<Type>BUILDING_HONGKONG2_DUMMY</Type>
<BuildingClass>BUILDINGCLASS_HONGKONG2_DUMMY</BuildingClass>
<!-- Invisible Buildings -->
<Cost>-1</Cost>
<FaithCost>-1</FaithCost>
<PrereqTech>NULL</PrereqTech>
<GreatWorkCount>-1</GreatWorkCount>
<!-- Invisible Buildings -->
<Description>TXT_KEY_BUILDING_HONGKONG2_DUMMY_DESC</Description>
<Civilopedia>TXT_KEY_CIVLOPEDIA_HONGKONG2_DUMMY_TEXT</Civilopedia>
<Strategy>TXT_KEY_BUILDING_HONGKONG2_DUMMY_STRATEGY</Strategy>
<ArtDefineTag>MARKET</ArtDefineTag>
<MinAreaSize>-1</MinAreaSize>
<HurryCostModifier>25</HurryCostModifier>
<IconAtlas>NEB_BW_ATLAS</IconAtlas>
<PortraitIndex>0</PortraitIndex>
<NeverCapture>true</NeverCapture>
<NukeImmune>true</NukeImmune>
</Row>
</Buildings>
<Building_YieldChanges>
<Row>
<BuildingType>BUILDING_HONGKONG2_DUMMY</BuildingType>
<YieldType>YIELD_CULTURE</YieldType>
<Yield>1</Yield>
</Row>
</Building_YieldChanges>
<BuildingClasses>
<Row>
<Type>BUILDINGCLASS_HONGKONG2_DUMMY</Type>
<DefaultBuilding>BUILDING_HONGKONG2_DUMMY</DefaultBuilding>
<Description>TXT_KEY_BUILDING_HONGKONG2_DUMMY_DESC</Description>
</Row>
</BuildingClasses>
<Language_en_US>
<Row Tag="TXT_KEY_BUILDING_HONGKONG2_DUMMY_DESC">
<Text>Merchant Culture Dummy</Text>
</Row>
<Row Tag="TXT_KEY_CIVLOPEDIA_HONGKONG2_DUMMY_TEXT">
<Text>Just a dummy.</Text>
</Row>
<Row Tag="TXT_KEY_BUILDING_HONGKONG2_DUMMY_STRATEGY">
<Text>Just a dummy.</Text>
</Row>
<Row Tag="TXT_KEY_BUILDING_HONGKONG2_DUMMY_DESC">
<Text>Merchant Culture Dummy</Text>
</Row>
</Language_en_US>
</GameData>