Hi all,
I'm trying to transfer a Great Work as part of a mod I'm making. Finding the right place seems to work fine as far as I can tell, but Network.SendMoveGreatWorks doesn't seem to do anything. Any help is very appreciated.
I'm trying to transfer a Great Work as part of a mod I'm making. Finding the right place seems to work fine as far as I can tell, but Network.SendMoveGreatWorks doesn't seem to do anything. Any help is very appreciated.
Code:
function GetNextFreeSlot (iBuilding, pCity)
local pBuilding = GameInfo.Buildings[iBuilding]
local iAvailableSlots = pBuilding.GreatWorkCount
for iSlot = 0, iAvailableSlots-1, 1 do
local iWork = pCity:GetBuildingGreatWork(GameInfoTypes[pBuilding.BuildingClass], iSlot)
if (iWork == -1) then
return iSlot
end
end
end
function AddArti (playerID, sBuildingArtType)
local greatWorkArtID = GameInfoTypes["GREAT_WORK_SLOT_ART_ARTIFACT"]
local pPlayer = Players[playerID]
if (pPlayer:HasAvailableGreatWorkSlot(greatWorkArtID)) then
local capital = pPlayer:GetCapitalCity()
local capx = capital:GetX()
local capy = capital:GetY()
local dummybuildingID = GameInfoTypes[sBuildingArtType]
capital:SetNumRealBuilding(dummybuildingID, 1)
local iBuilding = pPlayer:GetBuildingOfClosestGreatWorkSlot(capx, capy, greatWorkArtID);
print ("targetbuilding: ".. iBuilding)
local pCity = pPlayer:GetCityOfClosestGreatWorkSlot(capx, capy, greatWorkArtID);
local cityID = pCity:GetID()
local cityname = pPlayer:GetCityByID(cityID):GetName()
print ("targetcity " ..cityname)
local slotID = GetNextFreeSlot (iBuilding, pCity)
print ("targetslot" ..slotID)
Network.SendMoveGreatWorks(playerID, capital:GetID(), dummybuildingID, 0, cityID, iBuilding, slotID)
print ("transfered")
--capital:SetNumRealBuilding(dummybuildingID, 0)
end
end