Advertisement
Skip_21

Base Control Screen

Nov 18th, 2018
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.43 KB | None | 0 0
  1. --TODO : Add monitor handling Process
  2. -- API : https://pastebin.com/HRbMF1Eg
  3.  
  4. os.loadAPI("button")
  5.  
  6. function fillTable()
  7.     button.setTable("Wither Skeletons", witherskeletons, 3, 23, 3, 7)
  8.     button.setTable("Exit Program", exitProg, 25, 45, 21, 25)
  9.     button.screen()
  10. end
  11.  
  12. function getClick()
  13.     event, siude, x, y = os.pullEvent("monitor_touch")
  14.     button.checkxy(x, y)
  15. end
  16.  
  17. function witherskeletons()
  18.     button.toggleButton("Wither Skeletons")
  19.     rednet.broadcast("wither", "ControlComp")
  20. end
  21.  
  22. function exitProg()
  23.     error("Program Terminated")
  24. end
  25.  
  26. sides = peripheral.getNames()
  27.  
  28. modemhere = false
  29. monitorhere = false
  30. monitoramount = 0
  31. monitors = {}
  32.  
  33.  
  34. for i = 1,#sides do
  35.     thistype = peripheral.getType(sides[i])
  36.  
  37.     if thistype == "modem" then
  38.        
  39.         print("Modem Found ! Connecting !")
  40.         rednet.open(sides[i])
  41.         modemhere = true
  42.    
  43.     end
  44.  
  45.     if thistype == "monitor" then
  46.  
  47.         print("Monitor found ! Connecting !")
  48.         m = peripheral.wrap(sides[i])
  49.         monitorhere = true
  50.  
  51.         if monitoramount == 0 then
  52.             monitoramount = 1
  53.             m = peripheral.wrap(sides[i])
  54.         else
  55.             print("Already one monitor attached ! Ignoring !")
  56.         end
  57.  
  58.     end
  59.  
  60. end
  61.  
  62. if not modemhere then error("No Modem found ! Please connect one !") end
  63. if not monitorhere then error("No Monitor found ! Please connect one !") end
  64.  
  65. rednet.host("ControlComp","ControlComp")
  66.  
  67. m.clear()
  68. fillTable()
  69. button.heading("Base Control Panel")
  70.  
  71. while true do
  72.     getClick()
  73. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement