Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- settings.load()
- local me_bridge = peripheral.wrap(settings.get("color.me_bridge"))
- local redstone_side = settings.get("color.redstone_side")
- local max_storage_amount = settings.get("color.max_storage_amount")
- local min_storage_amount = settings.get("color.min_storage_amount")
- local dye_colors = settings.get("color.colors")
- local function stop_all()
- local redstone_colors = 0
- for i, color in pairs(dye_colors) do
- local color_value = colors.fromBlit(color.value)
- if color.inverted then
- redstone_colors = colors.subtract(redstone_colors, color_value)
- else
- redstone_colors = colors.combine(redstone_colors, color_value)
- end
- end
- redstone.setBundledOutput(redstone_side, redstone_colors)
- end
- local function stop_color(color_blit_value, inverted)
- local output = redstone.getBundledOutput(redstone_side)
- local color_value = colors.fromBlit(color_blit_value)
- if inverted then
- output = colors.subtract(output, color_value)
- else
- output = colors.combine(output, color_value)
- end
- redstone.setBundledOutput(redstone_side, output)
- end
- local function start_color(color_blit_value, inverted)
- local output = redstone.getBundledOutput(redstone_side)
- local color_value = colors.fromBlit(color_blit_value)
- if inverted then
- output = colors.combine(output, color_value)
- else
- output = colors.subtract(output, color_value)
- end
- redstone.setBundledOutput(redstone_side, output)
- end
- local function check_storage()
- for i, color in pairs(dye_colors) do
- print("Checking storage for "..color.name.." ...")
- local item = me_bridge.getItem({name = color.item})
- if item == nil or item.amount == nil then
- print(" NOTHING FOUND - producting")
- start_color(color.value, color.inverted)
- elseif item.amount < max_storage_amount then
- print(" found "..item.amount.." - producting")
- start_color(color.value, color.inverted)
- else
- print(" found "..item.amount.." - OK")
- stop_color(color.value, color.inverted)
- end
- sleep(1)
- end
- end
- print(" -- Farbproduktion -- ")
- stop_all()
- while true do
- check_storage()
- sleep(30)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement