Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = {...}
- if #tArgs ~= 1 then
- print("Usage: xorGate <sides>")
- print(" -- the left of the screen is A, the screen is B")
- print(" -- the right of the screen is C, the back is output")
- print(" -- if sides is 1, the system will check A and B")
- print(" -- if sides is 2, the system will check B and C")
- print(" -- if sides is 3, the system will check A and C")
- print(" -- if sides is 4, the system will check A, B, and C")
- print(" -- all inputs must be true(active) for the output to be true")
- return
- end
- local function testSide(side)
- return ( (redstone.getInput(side)) or (redstone.getBundledInput(side) >0) )
- end
- local sides = tonumber(tArgs[1])
- if sides < 1 then
- sides = 1
- elseif sides > 4 then
- sides = 4
- end
- while true do
- if ( sides == 1 ) then
- if ( (testSide("left") and not testSide("front")) or (not testSide("left") and testSide("front")) ) then
- redstone.setOutput("back",true)
- redstone.setBundledOutput("back",255)
- end
- elseif ( sides == 2 ) then
- if ( (testSide("right") and not testSide("front")) or (not testSide("right") and testSide("front")) ) then
- redstone.setOutput("back",true)
- redstone.setBundledOutput("back",255)
- end
- elseif ( sides == 3 ) then
- if ( (testSide("right") and not testSide("left")) or (not testSide("right") and testSide("left")) ) then
- redstone.setOutput("back",true)
- redstone.setBundledOutput("back",255)
- end
- elseif ( sides == 4 ) then
- if ( (testSide("right") and not testSide("front") and not testSide("left")) or
- (not testSide("right") and testSide("front") and not testSide("left")) or
- (not testSide("right") and not testSide("front") and testSide("left")) then
- redstone.setOutput("back",true)
- redstone.setBundledOutput("back",255)
- end
- else
- redstone.setOutput("back",false)
- redstone.setBundledOutput("back",0)
- end
- os.pullEvent("redstone")
- end
Advertisement
Add Comment
Please, Sign In to add comment