Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- modem = peripheral.wrap("back")
- modem.open(12)
- --# load the touchpoint API
- os.loadAPI("touchpoint")
- --# intialize a new button set on the top monitor
- local t = touchpoint.new("top")
- --# add two buttons
- t:add("for", nil, 2, 2, 6, 6, colors.red, colors.lime)
- t:add("back", nil, 8, 2, 12, 6, 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:flash(p1)
- --# and toggle the redstone output on that side.
- modem.transmit(12,12,p1)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement