Advertisement
thatparadox

WitherButtonCom

Oct 28th, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.32 KB | None | 0 0
  1. mon = peripheral.find("monitor")
  2. for k,v in pairs(rs.getSides()) do
  3.   if peripheral.getType(v) == "modem" then
  4.    rednet.open(v)
  5.   end
  6. end
  7.  
  8. function touchReady()
  9. mon.setBackgroundColor(colors.black)
  10. mon.clear()
  11. mon.setCursorPos(2,2)
  12. mon.write("Build")
  13. mon.setCursorPos(1,4)
  14. mon.write("Wither")
  15. end
  16.  
  17. function building()
  18. mon.setBackgroundColor(colors.red)
  19. mon.clear()
  20. mon.setCursorPos(1,1)
  21. mon.write("Building")
  22. mon.setCursorPos(1,3)
  23. mon.write("Press to")
  24. mon.setCursorPos(1,5)
  25. mon.write("ABORT")
  26. end
  27.  
  28. function abort()
  29. mon.setBackgroundColor(colors.green)
  30. mon.clear()
  31. mon.setCursorPos(1,2)
  32. mon.write("Aborted")
  33. end
  34.  
  35. function buildComplete()
  36. mon.setBackgroundColor(colors.green)
  37. mon.clear()
  38. mon.setCursorPos(2,2)
  39. mon.write("Wither")
  40. mon.setCursorPos(2,4)
  41. mon.write("Built")
  42. end
  43.  
  44. while true do
  45.   touchReady()
  46.   event, param1, param2, param3 = os.pullEvent()
  47.   if event == "monitor_touch" then
  48.     rednet.broadcast("BuildWither", 33)
  49.     building()
  50.     while true do
  51.       ev, p1, p2, p3 = os.pullEvent()
  52.       if ev == "monitor_touch" then
  53.         rednet.broadcast("abort", 33)
  54.         abort()
  55.         sleep(10)
  56.         break
  57.       elseif ev == "rednet_message" and p2 == "WitherBuilt" and tonumber(p3) == 33 then
  58.         buildComplete()
  59.         sleep(60)
  60.         break
  61.       end
  62.     end
  63.   end
  64. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement