LeeS
Imperator
I'm using this bit of code to replace the city's current (top of the qeue) production item with new item that ought to take the place of the current item.
So, any ideas on how I go about deleting the old item from the city's build qeue?
Or am I just missing the painfully obvious from within the API?
I did use whoward's API-as-XML to look through the available 'City' methods.
Code:
for pCity in pPlayer:Cities() do
if (pCity:GetProductionBuilding() ~= -1) and tReplacementBuildingCorrespondances[pCity:GetProductionBuilding()] then
local iCurrentProductionAmount, iBuildingToBeSet = pCity:GetProduction(), tReplacementBuildingCorrespondances[pCity:GetProductionBuilding()]
pCity:PushOrder(OrderTypes.ORDER_CONSTRUCT, iBuildingToBeSet, -1, false, false, false, 1)
pCity:SetBuildingProduction(iBuildingToBeSet, (iCurrentProductionAmount + 1))
end
end
- this occurs when the player advances to a new era and the current item at the top of the qeue is no longer valid
- in the lua-table tReplacementBuildingCorrespondances, all "keys" are the ID#s of buildings that will get replaced, and all "values" are the building ID#s for which building should be set as the city's production item in place of the old one
- I am using the ReplacementBuildingClass column from within table Buildings to handle most of this busy-work, but I encountered a couple of unfortunate 'special-case' conditions with the way the game handles ReplacementBuildingClass and which I am now trying to cure.
- the code works fine to add the new production item at the top of the city build qeue, and preserves the production the player had accumulated to constructing the outdated building.
- What happens is that the new production item is placed at the top of the city build-qeue, but the "old" item is still in the qeue one item below the new item. Everything eventually gets 'fixed' and corrected when a player presses NEXT TURN (ie, the old building gets removed by the game from the city build qeue), but I'm concerned about a condition where a player has the city's build-qeue "full-up" before the code executes.
- I tried using as this to get rid of the old building within the city's build qeue, but obviously "PushOrder" didn't work for me in this way:
Code:for pCity in pPlayer:Cities() do if (pCity:GetProductionBuilding() ~= -1) and tReplacementBuildingCorrespondances[pCity:GetProductionBuilding()] then local iCurrentProductionAmount, iBuildingToBeSet = pCity:GetProduction(), tReplacementBuildingCorrespondances[pCity:GetProductionBuilding()] pCity:PushOrder(OrderTypes.ORDER_CONSTRUCT, pCity:GetProductionBuilding(), -1, false, false, false, 0) pCity:PushOrder(OrderTypes.ORDER_CONSTRUCT, iBuildingToBeSet, -1, false, false, false, 1) pCity:SetBuildingProduction(iBuildingToBeSet, (iCurrentProductionAmount + 1)) end end
So, any ideas on how I go about deleting the old item from the city's build qeue?
Or am I just missing the painfully obvious from within the API?
