Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function updateOutputs()
- redstone.setOutput("back", out[1])
- redstone.setOutput("left", out[2])
- redstone.setOutput("right", out[3])
- redstone.setOutput("front", out[4])
- end
- function boolToStr(b)
- if b == true then
- return "true"
- else
- return "false"
- end
- end
- gui = peripheral.wrap("top")
- gui.registerAsEventListener()
- out = {false, false, false, false}
- button = {0,0,0,0}
- updateOutputs()
- gui.createGui()
- while true do
- a = os.pullEvent()
- if a == "PDA_Use" then
- gui.displayGui()
- gui.addCenText("Redstone Output Control", math.floor(gui.getWidth() / 2), 10, -1)
- button[1] = gui.addButton(1, math.floor(gui.getWidth() / 4), 30, math.floor(gui.getWidth() / 2), 20, "")
- button[2] = gui.addButton(2, math.floor(gui.getWidth() / 4), 60, math.floor(gui.getWidth() / 2), 20, "")
- button[3] = gui.addButton(3, math.floor(gui.getWidth() / 4), 90, math.floor(gui.getWidth() / 2), 20, "")
- button[4] = gui.addButton(4, math.floor(gui.getWidth() / 4), 120, math.floor(gui.getWidth() / 2), 20, "")
- gui.setButtonText(button[1], "Back: "..boolToStr(out[1]))
- gui.setButtonText(button[2], "Left: "..boolToStr(out[2]))
- gui.setButtonText(button[3], "Right: "..boolToStr(out[3]))
- gui.setButtonText(button[4], "Front: "..boolToStr(out[4]))
- while gui.isGuiVisible() do
- a, b = os.pullEvent()
- if a == "GUI_ButtonClick" then
- out[b] = not out[b]
- updateOutputs()
- gui.setButtonText(button[1], "Back: "..boolToStr(out[1]))
- gui.setButtonText(button[2], "Left: "..boolToStr(out[2]))
- gui.setButtonText(button[3], "Right: "..boolToStr(out[3]))
- gui.setButtonText(button[4], "Front: "..boolToStr(out[4]))
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement