Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. local lzhs = {1, 5, 8, 12, 17, 19, 24, 31, 36, 38, 43, 47, 50, 54}
  2.  
  3. local component = require("component")
  4. local event = require("event")
  5. local m = component.modem -- get primary modem component
  6. m.open(1488)
  7. print(m.isOpen(1488)) -- true
  8. -- Send some message.
  9. m.broadcast(1488, "Started.")
  10.  
  11. local robot = component.robot
  12. local sides = require("sides")
  13. robot.select(2)
  14.  
  15. local ic = component.inventory_controller
  16.  
  17. -- checking for lapis
  18. function CheckLapis()
  19. local slot = 2
  20. robot.select(2)
  21. local lapisPassed = false
  22.  
  23. while lapisPassed == false do
  24. local item = ic.getStackInInternalSlot(slot)
  25. if item then
  26. if item.size < 64 then
  27. ic.suckFromSlot(sides.up, 1, 64 - item.size)
  28. end
  29. else
  30. ic.suckFromSlot(sides.up, 1)
  31. end
  32. item = ic.getStackInInternalSlot(slot)
  33. lapisPassed = item.size == 64
  34. if lapisPassed == false then
  35. print("Too low amount of lapis!")
  36. os.sleep(2)
  37. end
  38. end
  39. end
  40.  
  41. function wPrint(mes)
  42. m.broadcast(1488, mes)
  43. end
  44.  
  45. function has_value (tab, val)
  46. for index, value in ipairs(tab) do
  47. if value == val then
  48. return true
  49. end
  50. end
  51.  
  52. return false
  53. end
  54.  
  55. function CheckLZH(slot)
  56. local lzhitem = ic.getStackInSlot(sides.forward, slot)
  57. if lzhitem then
  58. if lzhitem.damage > 40000 then
  59. wPrint("LZH at slot ".. tostring(slot).. " is damaged.")
  60. turnOff()
  61. RepairLZH(slot)
  62. turnOn()
  63. end
  64. end
  65. end
  66.  
  67. function RepairLZH(slot)
  68. CheckLapis()
  69. robot.select(1)
  70. ic.suckFromSlot(sides.forward, slot)
  71. component.crafting.craft(1)
  72. PutLZH(slot)
  73. end
  74.  
  75. function PutLZH(slot)
  76. ic.dropIntoSlot(sides.forward, slot)
  77. end
  78.  
  79. function GlobalCheckLZHs()
  80. for i=1, #lzhs do
  81. CheckLZH(lzhs[i])
  82. end
  83. end
  84. --RepairLZH(1)
  85. --CheckLZH(1)
  86. --GlobalCheckLZHs()
  87.  
  88. function turnOn()
  89. component.redstone.setOutput(sides.forward, 15)
  90. component.redstone.setOutput(sides.back, 15)
  91. end
  92.  
  93. function turnOff()
  94. component.redstone.setOutput(sides.forward, 0)
  95. component.redstone.setOutput(sides.back, 0)
  96. end
  97.  
  98. function CheckFuel(slot)
  99. local fitem = ic.getStackInSlot(sides.forward, slot)
  100. if fitem then
  101. if fitem.label == "Quad Fuel Rod (Depleted MOX)" then
  102. wPrint("Fuel at slot"..tostring(slot).." is depleted.")
  103. turnOff()
  104. r.select(1)
  105. ic.suckFromSlot(sides.forward, slot)
  106. r.drop(sides.down)
  107. local item = ic.getStackInSlot(sides.up, slot)
  108. if item then
  109. ic.suckFromSlot(sides.up, 1, 1)
  110. ic.dropIntoSlot(sides.forward, slot)
  111. end
  112. end
  113. end
  114. end
  115.  
  116. function GlobalCheckFuel()
  117. for i = 1, 54 do
  118. CheckFuel(i)
  119. end
  120. end
  121.  
  122. while true do
  123. -- GlobalCheckFuel()
  124. turnOn()
  125. GlobalCheckLZHs()
  126. GlobalCheckFuel()
  127. -- ThingCycle()
  128. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement