City:IsOriginalCapital() can be used for both Gamplay and UI Script (). (ChimpanG has updated the Modding companion sheet)Is there a way to do the equivalent of City:IsOriginalCapital() in the Gameplay context?
function NephilimEras(iOldEra, iNewEra)
for iPlayer = 0, 63 do
if PlayerConfigurations[iPlayer]:GetCivilizationTypeName() == 'CIVILIZATION_HOLOEN_NEPHILIM' then
for i,city in Players[iPlayer]:GetCities():Members() do
if Game.GetEras():HasDarkAge(Players[iPlayer].Index) then
PlaceBuildingInCityCenter(i, GameInfo.Buildings["BUILDING_TWOAMEN"].Index)
elseif not Game.GetEras():HasGoldenAge(iPlayer) then
PlaceBuildingInCityCenter(i, GameInfo.Buildings["BUILDING_ONEAMEN"].Index)
end
end
end
end
end
function PlaceBuildingInCityCenter(pCity, iBuilding)
local iCityPlotIndex = Map.GetPlot(pCity:GetX(), pCity:GetY()):GetIndex()
if not pCity:GetBuildings():HasBuilding(iBuilding) then
pCity:GetBuildQueue():CreateIncompleteBuilding(iBuilding, iCityPlotIndex, 100);
end
end
Events.GameEraChanged.Add(NephilimEras)
Players[iPlayer].Index
PlayerObject.Index
Game.GetEras():HasDarkAge(playerID)
So it should work as an added Gameplay Script?the function should not be nil if the file is loaded in gameplay/script context AFAIK.
function expected instead of nil
see this post for an example of passing a function from the UI context to the gameplay context:I see, so adding amenities depending on the Age is impossible in the current state of the game using LUA...
Thanks for your help anyway.
DealManager.ClearWorkingDeal(DealDirection.OUTGOING, iPlayer1, iPlayer2);
local pDeal = DealManager.GetWorkingDeal(DealDirection.OUTGOING, iPlayer1, iPlayer2);
if pDeal then
pDealItem = pDeal:AddItemOfType(DealItemTypes.AGREEMENTS, iPlayer1);
if pDealItem then
pDealItem:SetSubType(DealAgreementTypes.OPEN_BORDERS);
pDealItem:SetValueType(-1);
pDealItem:SetFromPlayerID(iPlayer1);
pDealItem:SetToPlayerID(iPlayer2);
pDealItem:SetDuration(10);
pDealItem:SetLocked(true);
end
pDeal:Validate();
DealManager.EnactWorkingDeal(iPlayer1, iPlayer2);
end
DealManager.ClearWorkingDeal(DealDirection.OUTGOING, iPlayer1, iPlayer2);
local pDeal = DealManager.GetWorkingDeal(DealDirection.OUTGOING, iPlayer1, iPlayer2);
if pDeal then
pDealItem = pDeal:AddItemOfType(DealItemTypes.AGREEMENTS, iPlayer1);
if pDealItem then
pDealItem:SetSubType(DealAgreementTypes.OPEN_BORDERS);
pDealItem:SetValueType(-1);
pDealItem:SetFromPlayerID(iPlayer1);
pDealItem:SetToPlayerID(iPlayer2);
pDealItem:SetDuration(0);
pDealItem:SetLocked(true);
end
pDeal:Validate();
DealManager.EnactWorkingDeal(iPlayer1, iPlayer2);
end
DealManager.ClearWorkingDeal(DealDirection.OUTGOING, iPlayer1, iPlayer2);
local pDeal = DealManager.GetWorkingDeal(DealDirection.OUTGOING, iPlayer1, iPlayer2);
if pDeal then
pDealItem = pDeal:AddItemOfType(DealItemTypes.AGREEMENTS, iPlayer1);
if pDealItem then
pDealItem:SetSubType(DealAgreementTypes.ALLIANCE);
pDealItem:SetValueType(DB.MakeHash("ALLIANCE_MILITARY"));
pDealItem:SetLocked(true);
end
pDeal:Validate();
DealManager.EnactWorkingDeal(iPlayer1, iPlayer2);
end
DealManager.ClearWorkingDeal(DealDirection.OUTGOING, iPlayer1, iPlayer2);
local pDeal = DealManager.GetWorkingDeal(DealDirection.OUTGOING, iPlayer1, iPlayer2);
if pDeal then
pDealItem = pDeal:AddItemOfType(DealItemTypes.AGREEMENTS, iPlayer1);
if pDealItem then
pDealItem:SetSubType(DealAgreementTypes.ALLIANCE);
pDealItem:SetValueType(DB.MakeHash("ALLIANCE_MILITARY"));
pDealItem:SetDuration(0);
pDealItem:SetLocked(true);
end
pDeal:Validate();
DealManager.EnactWorkingDeal(iPlayer1, iPlayer2);
end
yeah, me too. One can even make shared visibility if you tie it (via alliance database modifiers) to an AllianceType or to a dummy Alliance (would need a DiploDealScreen UI rework if you want to hide it tho, but you're already overhauling everything in your Mod, so no big deal for you I guess). Except defensive Pacts I think.(I'm still wondering how many things I've thought impossible were in fact possible since a long time... and why they never released at least a minimal API)