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")
- --# add a title
- t:add("Redstone Control Grid", nil, 2, 2, 20, 4, colors.black, colors.black)
- --# add two buttons
- t:add("Oil Pump", nil, 2, 6, 10, 12, colors.red, colors.lime)
- t:add("Refinery", nil, 12, 6, 20, 10, 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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement