Skip to content

Instantly share code, notes, and snippets.

@NULLx76
Created March 12, 2019 17:57
Show Gist options
  • Save NULLx76/e16169436651a62a196da308ca8a15e8 to your computer and use it in GitHub Desktop.
Save NULLx76/e16169436651a62a196da308ca8a15e8 to your computer and use it in GitHub Desktop.
-- Imports
local component = require("component")
local sides = require("sides")
local gpu = component.gpu
local w, h = gpu.getResolution()
-- Vars
local card = component.proxy(component.list("redstone")())
local cardUUID = card.address
local outputSide = sides.east
local checkSide = sides.east
-- Helper functions
-- Makes screen green if true, red if false
function colorScreen(bool)
gpu.fill(1, 1, w, h, " ") -- Clear screen
if bool then
gpu.setBackground(0x00FF00)
else
gpu.setBackground(0xFF0000)
end
gpu.fill(1, 1, w, h, " ") -- Clear screen
end
-- List of redstone interfaces excluding card
local rs = {}
for address, name in component.list("redstone", true) do
if address ~= component.get(cardUUID) then
table.insert( rs, component.proxy(address))
end
end
-- Main loop
while true do
local hasItems = 0
for key,value in ipairs(rs) do
hasItems = hasItems + value.getComparatorInput(checkSide)
end
if(hasItems > 0) then
card.setOutput(sides.east, 255) -- 255 is max signal
colorScreen(false)
else
card.setOutput(sides.east, 0)
colorScreen(true)
end
os.sleep(1)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment