Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --# load the touchpoint API
- os.loadAPI("touchpoint")
- local mes
- --# opens rednet
- rednet.open("bottom")
- --# intialize a new button set on the top monitor
- local t = touchpoint.new("top")
- local monitor = peripheral.find("monitor")
- monitor.setTextScale(0.5)
- function setMessage(nr)
- mes = nr
- print(mes)
- end
- --# add two buttons
- t:add("EG", nil, 1, 1, 36, 4, colors.red, colors.lime)
- t:add("U1", nil, 1, 5, 36, 8, colors.red, colors.lime)
- t:add("U2", nil, 1, 9, 36, 12, colors.red, colors.lime)
- t:add("U3", nil, 1, 13, 36, 16, colors.red, colors.lime)
- t:add("U4", nil, 1, 17, 36, 20, colors.red, colors.lime)
- t:add("U5", nil, 1, 21, 36, 24, 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)
- if p1 == "EG" then setMessage(6)
- elseif p1 == "U1" then setMessage(5)
- elseif p1 == "U2" then setMessage(4)
- elseif p1 == "U3" then setMessage(3)
- elseif p1 == "U4" then setMessage(2)
- elseif p1 == "U5" then setMessage(1)
- end
- rednet.send(17, mes)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement