Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --signet
- --version 1.0a
- local function version()
- return "1.0a"
- end
- local sigAvailable = tonumber("8000",16)
- local sigAcknowledge = tonumber("4000",16)
- local sigFilter = tonumber("2FFF",16)
- local sides = {"top", "bottom", "left", "right", "front", "back"}
- -- returns true if there is a valid signal coming in on side
- local function available(side)
- return colors.test(redstone.getBundledInput(side), sigAvailable)
- end
- -- returns true if a tx'd sig has been acknowldged
- local function acknowledged(side)
- return colors.test(redstone.getBundledInput(side), sigAcknowledge)
- end
- -- returns the first side with a valid signal
- local function scan()
- for side in sides do
- if available(side) then
- return side
- end
- end
- return nil
- end
- -- removes overhead bits from the signal coming in on side
- local function getSig(side)
- if not available(side) then
- return nil
- end
- return bit.band(redstone.getBundledInput(side), sigFilter)
- end
- function rx(side)
- if not available(side) then
- return nil
- end
- sig = getSig(side)
- redstone.setBundledOutput(side, sigAcknowledge)
- while available(side) do
- os.sleep(0.05)
- end
- redstone.setBundledOutput(side, 0)
- return sig
- end
- function tx(side, sig)
- redstone.setBundledOutput(side, sig + sigAvailable)
- while not colors.test(redstone.getBundled
- redstone.setBundledOutput(side, 0)
- signal.waitWhile(side, signal.commandReceived)
- end
Advertisement
Add Comment
Please, Sign In to add comment