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 function toggleBundledColor(side, color)
- rs.setBundledOutput(side, (colors.test(rs.getBundledOutput(side), color) and colors.subtract(rs.getBundledOutput(side), color) or colors.combine(rs.getBundledOutput(side), color)))
- end
- local function test()
- toggleBundledColor("back", colors.white)
- end
- t:add("Test", test, 2, 2, 9, 4, colors.red, colors.cyan)
- --# 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)
- t.buttonList[p1].func()
- --# 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