--- /dev/null
+-- stockpile-switch.lua
+
+-- forandre disse verdiene etter ønske!
+local move_to_high = 500
+local move_to_low = 10000
+local update_frequency_seconds = 10
+---------------------------------------
+
+
+
+local inventory_address
+for _,p in pairs(peripherals.getNames()) do
+ inventory_address = string.match(p, "^.*barrel.*$")
+end
+
+local get_amount = function(item)
+ local amount = 0
+ for _,v in pairs(inventory.list()) do
+ if v and v.name == item then
+ amount = amount + v.count
+ end
+ end
+ return amount
+end
+
+local set_redstone = function(b)
+ for _,side in pairs({"top", "bottom", "left", "right", "front", "back"}) do
+ rs.setOutput(side, b)
+ end
+ return b
+end
+
+local redstone_state = false
+while true do
+ os.sleep(10)
+ local cobble_amount = get_amount("minecraft:cobblestone")
+ if cobble_amount >= move_to_high and not redstone_state then
+ redstone_state = set_redstone(true)
+ elseif cobble_amount <= move_to_low and redstone_state then
+ redstone_state = set_redstone(false)
+ end
+end