Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --# load the touchpoint API
- os.loadAPI("touchpoint")
- --# intialize a new button set on the top monitor
- local t = touchpoint.new("back")
- --# add two buttons
- t:add("left", nil, 2, 2, 14, 11, colors.red, colors.lime)
- t:add("right", nil, 16, 2, 28, 11, colors.red, colors.lime)
- --# draw the buttons
- t:draw()
- while true do
- --# handleEvents will convert monitor_touch events to button_click if it was on a button
- local event, p1 = t:handleEvents(os.pullEvent())
- if event == "button_click" then
- --# p1 will be "left" or "right", since those are the button labels
- --# toggle the button that was clicked.
- t:toggleButton(p1)
- --# and toggle the redstone output on that side.
- rs.setOutput(p1, not rs.getOutput(p1))
- end
- end
Add Comment
Please, Sign In to add comment