Advertisement
Skip_21

Base Control Client

Nov 18th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.21 KB | None | 0 0
  1. fails = 0
  2. wither = 0
  3.  
  4. sides = peripheral.getNames()
  5.  
  6. modemhere = false
  7.  
  8. function eventListener()
  9.  
  10.     local event, p1, p2, p3 = os.pullEvent()
  11.  
  12.     if event == "rednet_message" and p3 == "ControlComp" then
  13.  
  14.         if p2[1] == "wither" then wither() end
  15.    
  16.     end
  17.  
  18. end
  19.  
  20. function wither()
  21.     if wither == 0 then
  22.         wither = 1
  23.         redstone.setOutput("bottom", true)
  24.         redstone.setOutput("back", true)
  25.     elseif wither == 1 then
  26.         wither = 0
  27.         redstone.setOutput("bottom", false)
  28.         redstone.setOutput("back", false)
  29.     end
  30. end
  31.  
  32. for i = 1, #sides do
  33.  
  34.     thistype = peripheral.getType(sides[i])
  35.  
  36.     if thistype == "modem" then
  37.    
  38.         print("Modem found on " .. sides[i] .. ", connecting...")
  39.         rednet.open(sides[i])
  40.         modemhere = true
  41.  
  42.     end
  43.  
  44. end
  45.  
  46. if not modemhere then error("No Modem found ! Please connect one !") end
  47.  
  48. ControlComp = rednet.lookup("ControlComp","ControlComp")
  49.  
  50. while ControlComp == nil do
  51.    
  52.     fails = fails+1
  53.     print("Can't find Control Computer. Waiting ! ("..fails.." tries)")
  54.     os.sleep(10)
  55.     ControlComp = rednet.lookup("ControlComp","ControlComp")
  56.  
  57. end
  58.  
  59. print("Found Control Computer ! Running...")
  60.  
  61. while true do
  62.     eventListener()
  63. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement