Page 2 of 2

Re: Help with removing Inventory from assembling-machine

Posted: Tue Mar 27, 2018 2:06 am
by TheSAguy
Thanks for your patience with me!
Seems to be working.

Thanks again!

EDIT: Code is anyone else needs it:

Code: Select all

	local recipe = ArboretumTable.inventory.get_recipe()
		
		if recipe ~= nil and ArboretumTable.inventory.fluidbox[1] ~= nil then
 

			local Water_Name = ArboretumTable.inventory.fluidbox[1].name
			local Water_Level = ArboretumTable.inventory.fluidbox[1].amount
			local my_inv = ArboretumTable.inventory.get_inventory(defines.inventory.assembling_machine_input).get_contents()
			local pass_qc = true
			for i = 1, #Inventory do
				if not Inventory[i].valid_for_read then
					pass_qc = false
					break
				end
			end		

Code: Select all

							
							--- Remove 100 Water
							Water_Level = Water_Level - 100
							ArboretumTable.inventory.fluidbox[1] = {name='water',amount=Water_Level}
					
							local Inventory = ArboretumTable.inventory.get_inventory(defines.inventory.assembling_machine_input)

							--- remove 1 inventory item
							for i = 1, #Inventory do
								local stack = Inventory[i]
								if stack.count > 0 then
								  stack.count  = stack.count - 1
								end
							end

Re: [Done] Help with removing Inventory from assembling-machine

Posted: Wed May 09, 2018 8:43 pm
by TheSAguy
Me again,

So I use the below to check and remove inventory from an assemble machine.

Code: Select all

							local Inventory = bi_drill_table.inventory.get_inventory(defines.inventory.assembling_machine_input)
							for i = 1, #Inventory do
								local stack = Inventory[i]
								if stack.count > 0 then
								  stack.count  = stack.count - 1
								end
							end
How would I check the results bucket to get that count also?
So from below, I have the green, need to get the info on the red:
Image

Thanks.

Re: [Done] Help with removing Inventory from assembling-machine

Posted: Wed May 09, 2018 8:51 pm
by TheSAguy
Actually I got it figured out.
Need to use "defines.inventory.assembling_machine_output"

Code: Select all

							local Inventory_out = bi_drill_table.inventory.get_inventory(defines.inventory.assembling_machine_output)
							for i = 1, #Inventory_out do
								local stack = Inventory_out[i]
								if stack.count > 0 then
								  box.insert({name = stack.name, count = stack.count})
								end
							end