Hallo allerseits,
ich versuche grade einen Weg zu finden, um bei allen Wohnhäusern, Einkaufsläden und Industriegebäuden die PersonCapacity nachträglich zu ändern. Da ich die KI beim Städtebau ausgeschaltet habe, kann ich auch nicht einfach warten, bis Mods wie z.B. Population Factor (https://steamcommunity.com/sha…iledetails/?id=2036235984) das erledigen.
Leider habe ich bisher nichts gefunden was das kann; weder schon fertig als mod oder selbstgeschrieben. Am nächsten an das was ich will kommt dieser Versuch:
Lua
local done = false
local updatefunction = function()
if done then
return
end
done = true
print("Running town building capacity adjuster...")
local entities = game.interface.getEntities({ radius = 999999 }, { type = "CONSTRUCTION", includeData = false })
print("Total entities found: " .. tostring(#entities))
for _, constrId in pairs(entities) do
local constr = api.engine.getComponent(constrId, api.type.ComponentType.CONSTRUCTION)
if constr == null then
goto continue
end
local index,_= string.find(constr.fileName, "building")
if index ~= 1 then
print("Constr " .. constr.fileName .. " is no Town building")
goto continue
end
print("in replace " .. constr.fileName)
local p = game.interface.getEntity(constrId).params
p.seed = null
game.interface.upgradeConstruction(constrId, constr.fileName, p)
--[[ alternative, die das gleiche ergebins hat
local newConstr = api.type.SimpleProposal.ConstructionEntity.new()
newConstr.fileName = constr.fileName
newConstr.params = game.interface.getEntity(constrId).params
for i = 1, 16 do
newConstr.transf[i] = constr.transf[i]
end
if constr.name then
newConstr.name = constr.name
else
newConstr.name = ""
end
newConstr.playerEntity = api.engine.util.getPlayer()
--newConstr.headquarters = false
local proposal = api.type.SimpleProposal.new()
proposal.old2new = { [constrId] = 0 } -- 0! Not -1! What a surprise! :-)
proposal.constructionsToRemove = { constrId }
proposal.constructionsToAdd[1] = newConstr
api.cmd.sendCommand(api.cmd.make.buildProposal(proposal, nil, true), function(res, success)
--- insert individual error handler
end)]]
::continue::
end
end
function data()
return {
update = updatefunction,
}
end
Alles anzeigen
Problem hierbei: Die Gebäude erden zwar 1:1 ausgetauscht, verlieren aber ihre Bewohner/Arbeitsplätze und werden, so wie ich das sehe, Assets.
Jemand eine Idee was ich hier übersehe oder noch probieren kann?