Advertisement
Guest User

startup.lua

a guest
Aug 17th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.89 KB | None | 0 0
  1. modem = peripheral.wrap("bottom")
  2. monitor = peripheral.wrap("top")
  3.  
  4. isSpawning = false
  5.  
  6. function writeCenter(text)
  7.     x, y = monitor.getSize()
  8.     x2, y2 = monitor.getCursorPos()
  9.    
  10.     monitor.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), math.ceil(y / 2))
  11.     monitor.write(text)
  12. end
  13.  
  14. function switchOn()
  15.     modem.transmit(81, 81, "on")
  16.    
  17.     monitor.setBackgroundColor(colors.green)
  18.     monitor.clear()
  19.     writeCenter("Slaughtering hard")
  20. end
  21.  
  22. function switchOff()
  23.     modem.transmit(81, 81, "off")
  24.  
  25.     monitor.setBackgroundColor(colors.red)
  26.     monitor.clear()
  27.     writeCenter("Click to start slaughtering")    
  28. end
  29.  
  30. switchOff()
  31.  
  32. while true do
  33.     event, side, xPos, yPos = os.pullEvent("monitor_touch")
  34.  
  35.     if isSpawning == true then
  36.         isSpawning = false
  37.         switchOff()
  38.     else
  39.         isSpawning = true
  40.         switchOn()
  41.     end
  42. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement