Advertisement
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("top")
- local buttonName = {
- " ",
- " A button ",
- " label ",
- " ",
- label = "a button"
- }
- t:add(buttonName, nil, 2, 2, 11, 5, colors.red, colors.lime)
- 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement