Advertisement
MrQuentinet

Untitled

Jul 30th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. isError=0
  2. --NbReactors=2
  3.  
  4. function detectDevice(DeviceName)
  5. DeviceSide="none"
  6. for k,v in pairs(redstone.getSides()) do
  7. if peripheral.getType(v)==DeviceName then
  8. DeviceSide = v
  9. break
  10. end
  11. end
  12. return(DeviceSide)
  13. end
  14.  
  15.  
  16. cell="none"
  17. monitor="none"
  18. reactor="none" --{}
  19.  
  20. --for x = 0, NbReactors-1 do
  21. -- table.insert(reactors, "none")
  22. --end
  23.  
  24. local peripheralList = peripheral.getNames()
  25.  
  26. CellSide=detectDevice("cofh_thermalexpansion_energycell")
  27.  
  28. if CellSide~="none" then
  29. cell=peripheral.wrap(CellSide)
  30. print ("TE Energy cell on the " .. CellSide .. " connected.")
  31. else
  32. CellSide=detectDevice("tile_blockcapacitorbank_name")
  33. if CellSide~="none" then
  34. cell=peripheral.wrap(CellSide)
  35. print ("EnderIO capacitorbank on the " .. CellSide .. " connected.")
  36. else
  37. for Index = 1, #peripheralList do
  38. if string.find(peripheralList[Index], "cofh_thermalexpansion_energycell") then
  39. cell=peripheral.wrap(peripheralList[Index])
  40. print ("TE Energy cell on wired modem: "..peripheralList[Index].." connected")
  41. elseif string.find(peripheralList[Index], "tile_blockcapacitorbank_name") then
  42. cell=peripheral.wrap(peripheralList[Index])
  43. print ("EnderIO capacitorbank on wired modem: "..peripheralList[Index].." connected")
  44. end
  45. end --for
  46. if cell == "none" then
  47. print("No Energy storage found. Halting script!")
  48. return
  49. end
  50.  
  51. end
  52. end
  53.  
  54.  
  55. MonitorSide=detectDevice("monitor")
  56.  
  57. if MonitorSide~="none" then
  58. monitor=peripheral.wrap(MonitorSide)
  59. print ("Monitor on the " .. MonitorSide .. " connected")
  60. else
  61. for Index = 1, #peripheralList do
  62. if string.find(peripheralList[Index], "monitor") then
  63. monitor=peripheral.wrap(peripheralList[Index])
  64. print ("Monitor on wired modem: "..peripheralList[Index].." connected")
  65. end
  66. end --for
  67. if monitor == "none" then
  68. print ("Warning - No Monitor attached, continuing without.")
  69. end
  70. end
  71.  
  72. MonLength, MonHigh = monitor.getSize()
  73.  
  74. ReactorSide=detectDevice("fissionreactor")
  75.  
  76. if ReactorSide~="none" then
  77. reactor=peripheral.wrap(ReactorSide)
  78. print("Reactor on the " ..ReactorSide .. " connected")
  79. else
  80. for Index = 1, #peripheralList do
  81. if string.find(peripheralList[Index], "fissionreactor") then
  82. reactor=peripheral.wrap(peripheralList[Index])
  83. print("Reactor on wired modem: "..peripheralList[Index].." connected")
  84. end
  85. end
  86. if reactor == "none" then
  87. print("Warning No Reactor Attatched !")
  88. end
  89. end
  90.  
  91. if monitor ~= "none" then
  92. monitor.clear()
  93. monitor.setBackgroundColour((colours.grey))
  94. monitor.setCursorPos(math.ceil(MonLength/2)-2,4)
  95. monitor.write(" ON ")
  96. monitor.setBackgroundColour((colours.green))
  97. monitor.setCursorPos(math.ceil(MonLength/2)+2,4)
  98. monitor.write(" OFF ")
  99. monitor.setBackgroundColour((colours.black))
  100. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement