Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = {...}
- if #tArgs ~= 1 then
- print("Usage: andGate <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 sides = tonumber(tArgs[1])
- if sides < 1 then
- sides = 1
- elseif sides > 4 then
- sides = 4
- end
- local function testTwo(side1, side2)
- if (((redstone.getInput(side1) == true) or (redstone.getBundledInput(side1) > 0)) and
- ((redstone.getInput(side2) == true) or (redstone.getBundledInput(side2) > 0))) then
- redstone.setOutput("back",true)
- redstone.setBundledOutput("back",255)
- else
- redstone.setOutput("back",false)
- redstone.setBundledOutput("back",0)
- end
- end
- while true do
- if (sides == 1) then
- testTwo("left","front")
- end
- if (sides == 2) then
- testTwo("right","front")
- end
- if (sides == 3) then
- testTwo("right","left")
- end
- if (sides == 4) then
- if (((redstone.getInput("left") == true) or (redstone.getBundledInput("left") > 0)) and
- ((redstone.getInput("front") == true) or (redstone.getBundledInput("front") > 0)) and
- ((redstone.getInput("right") == true) or (redstone.getBundledInput("right") > 0))) then
- redstone.setOutput("back",true)
- redstone.setBundledOutput("back",255)
- else
- redstone.setOutput("back",false)
- redstone.setBundledOutput("back",0)
- end
- end
- os.pullEvent("redstone")
- end
Advertisement
Add Comment
Please, Sign In to add comment