Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- m = peripheral.wrap("right")
- m.clear()
- spawner = peripheral.wrap("bottom")
- onX = 2
- onY = 3
- offX = 2
- offY = 5
- function draw_buttons(type)
- if type == 1 then
- draw_text(onX,onY,"On", colors.white, colors.black)
- draw_text(offX,offY,"Off", colors.white, colors.black)
- else if type == 2 then
- draw_text(onX,onY,"On", colors.white, colors.green)
- draw_text(offX,offY,"Off", colors.white, colors.black)
- else if type == 3 then
- draw_text(onX,onY,"On", colors.white, colors.black)
- draw_text(offX,offY,"Off", colors.white, colors.red)
- end
- end
- end
- end
- function draw_text(x, y, text, text_color, bg_color)
- m.setBackgroundColor(bg_color)
- m.setTextColor(text_color)
- m.setCursorPos(x,y)
- m.write(text)
- end
- function spawnOff()
- rs.setOutput("back", true)
- end
- function spawnOff()
- rs.setOutput("back", false)
- end
- draw_buttons(1)
- draw_text(2,1,"Spawner Control", colors.white, colors.black)
- while true do
- event, side, x, y = os.pullEvent("monitor_touch")
- if y == onY and x >= onX and x <= onX + 2 then
- draw_buttons(2)
- spawnOn()
- else if y == offY and x >= offX and x <= offX + 3 then
- draw_buttons(3)
- spawnOff()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement