View difference between Paste ID: UnnB7sVZ and Lyjwa2Tz
SHOW: | | - or go back to the newest paste.
1
os.loadAPI("button")
2
m = peripheral.wrap("top")
3
m.clear()
4
local btn = "TOGGLE BRIDGE"
5
6
function fillTable()
7
  button.setTable(btn, bridge, "", 1, 18, 1, 5)
8
  button.screen()
9
end
10
11
function getClick()
12
  event,side,x,y = os.pullEvent("monitor_touch")
13
  button.checkxy(x,y)
14
end
15
16
function setOutput(arg)
17
  if arg then
18
    print("Opening bridge...")
19
  else
20
    print("Closing bridge...")
21
  end
22
  redstone.setOutput("left", arg)
23
end
24
25
function bridge(arg)
26
  button.toggleButton(btn)  
27
  setOutput(button.button[btn]["active"])
28
end
29
30
redstone.getSides()
31
fillTable()
32
while true do
33
  getClick()
34
end