I'm trying to remove inventory from an assembling-machine I have when a " radar scan" is completed.
So, when I build the assembling-machine, I store it as follow:
Code: Select all
if entity.valid and entity.name == "bi-Arboretum" then
local arboretum = entity
local radar_name = "bi-Arboretum-Radar"
local position_c = {position.x - 4, position.y + 3.95}
local create_radar = surface.create_entity({name = radar_name, position = position_c, force = force})
create_radar.minable = false
create_radar.destructible = false
global.Arboretum_Table[entity.unit_number] = {inventory=entity, radar=create_radar }
end
Code: Select all
script.on_event(defines.events.on_sector_scanned, function(event)
---- Each time a Arboretum-Radar scans a sector, do ----
if event.radar.name == "bi-Arboretum-Radar" then
local num = (event.radar.unit_number-1)
Get_Arboretum_Recipe(global.Arboretum_Table[num], event)
end
end)
I can read the recipe, by using:
local recipe = ArboretumTable.inventory.get_recipe()
But I'm having a hard time being able to read the inventory content of the assembling-machine.
Currently I have 5 recipes it can have. Three of them have two ingredients and two had three ingredients. One of the ingredients is always water.
So I can identify the recipe, now I want to check and make sure the ingredients are there and if there, remove 1. (100 in the case of water)
Can someone please help me out with this.
I tried stuff like:
ArboretumTable.inventory.get_inventory(1).get_contents()
but that gives a nil.
or
for k = 1,3 do
ArboretumTable.inventory.get_inventory(k).get_contents()
Thanks.