I'm trying to find out if it is possible to change the type of cargo type when cargo is unloaded into receiving industry.
I have a producer of eg. "fish_b" and here I have made a custom indicator that fits only in this producer area. When the fish is loaded on to a boat it will make a mess on the load indicator, so that's why I have found and uses the "customCargoModels" in the vehicle compartment as vehicles can have other indicator models
Now I come to the problem. When delivering at an industry I get the original cargo and here I have the unwanted indicator in the visible stock layout.
My idea to get the same indicator as I have on the boat, it could be to just find the cargo components in the entities and change the cargoType number. It would be possible to let the "producer industry" create "fish_b" to be transported to an industry that may receive either "fish" or "fish_b" to produces food. I have found that the cargo type for fish has got the value of 16 and "fish_b" is 17 in my test environment.
But how do I find each component at the industry stock? and when found how to change the value? I have read the WIKI and got some updated info from UG about SimEntityAtStock
SimEntityAtStock
Additional data for entities waiting at industries.
Fields:
- stock Entity The industry the entity is waiting at
- arrivalTime int the timestamp when the item arrived at the industry
- I have written a script so I'm searching for constructions with it's name equal to my industry and can find all id:s but I'm stuck to continue to find the cargo type at the industry stock.
local Cargo = function(cargoName)
local cargoTypeFish = api.res.cargoTypeRep.find('FISH')
local cargoTypeFishB = api.res.cargoTypeRep.find('FISH_B')
local Entities = game.interface.getEntities({ pos = {0,0}, radius = 900000 }, { type="CONSTRUCTION" })
local entity = {}
if #Entities ~= nil then
for i = 1, #Entities do
entity = game.interface.getEntity(Entities[i])
if entity.fileName == 'fish_processing_plantA' or entity.fileName == 'fish_processing_plantC' then
-- local cargoTypes = api.res.cargoTypeRep()
local info = api.engine.getComponent(entity, 31) -- ComponentType: SIM_ENTITY_AT_STOCK = 31
-- print ("game script: cargotype /info= ",cargoTypeFish)
end
end
end
return
end
function data()
return {
update = function()
local cargoName = "FISH" --"FISH_B"
Cargo(cargoName)
end,
}
end
Alles anzeigen