Hi Claude, I am currently figuring out how the entity system is working. I also replied to the other post about getting information about input/output of industries. However, it's different because that was about editing the construction via loadConstruction where you have information about the construction file. The entities work different and have other variables.
So, I get all entities of a specific type with
local constructions = game.interface.getEntities( {radius = 999999}, {type = "CONSTRUCTION", includeData=true} )
It includes many entries, all constructions of the current game: town buildings, industries, assets.
Example:
[3357] = {
baseEdges = {},
baseNodes = {},
dateBuilt = {
day = 1,
month = 1,
year = 2000
},
depots = {},
fileName = "industry/farm.con",
id = 3357,
name = "Germaringen Bauernhof",
params = {
productionLevel = 0,
seed = -7946
},
particleSystems = {},
position = { -608, -1233.3120117188, 18.139999389648 },
simBuildings = { 16513 },
stations = {},
townBuildings = {},
transf = { -0.94868332147598, 0.31622776389122, 0, 0, -0.31622776389122, -0.94868332147598, 0, 0, 0, 0, 1, 0, -608, -1236, 18.099998474121, 1 },
type = "CONSTRUCTION"
},
Alles anzeigen
Now what you could do, is filtering the entities via
entity.fileName == "industry/*"
But that entry does not contain information about the industry itself, I think it contents just information about the model. So I became aware of simBuildings = { 16513 }:
{
id = 16513,
itemsConsumed = {
_lastMonth = {
_sum = 0
},
_lastYear = {
_sum = 0
},
_sum = 0
},
itemsConsumedVehicleUsed = {
_lastMonth = {
_sum = 0
},
_lastYear = {
_sum = 0
},
_sum = 0
},
itemsProduced = {
GRAIN = 1123,
_lastMonth = {
GRAIN = 17,
_sum = 17
},
_lastYear = {
GRAIN = 200,
_sum = 200
},
_sum = 1123
},
itemsShipped = {
_lastMonth = {
_sum = 0
},
_lastYear = {
_sum = 0
},
_sum = 0
},
level = 0,
name = "Germaringen Bauernhof",
position = { -608, -1233.3120117188, 18.099998474121 },
stockList = 3357,
type = "SIM_BUILDING",
upgradeProgress = 0
}
Alles anzeigen
This might be more interesting for you because it contains information about the production. type = "SIM_BUILDING" seems to be the industries, although I wouldn't have guessed that by the name.
There is still an issue, I had industries on my test map that didn't produce anything and didn't have any entries of Cargotype in their simbuilding table.
I don't know a better solution yet. Maybe there are possibilities with game.interface.getIndustryProduction but my tries with that resulted in a crash.