Advertisement
kovakovi2000

_MASTERSPONGE

Feb 28th, 2021 (edited)
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.67 KB | None | 0 0
  1. term.clear()
  2. term.setCursorPos(1,1)
  3. if not fs.exists("rnc2") then
  4.     shell.run("pastebin","get","7UH6rt36","rnc2")
  5. end
  6. os.loadAPI("rnc2")
  7.  
  8. function GotSpongeAmount()
  9.     local sponge = 0
  10.     for i = 1, 16 do
  11.         local detail = turtle.getItemDetail(i)
  12.         if detail ~= nil and detail.name == "enderio:block_industrial_insulation" then
  13.             sponge = sponge + detail.count
  14.         end
  15.     end
  16.     if sponge == 128 then
  17.         return true
  18.     end
  19.     return false
  20. end
  21.  
  22. function GiveSponge()
  23.     for i = 1, 16 do
  24.         local detail = turtle.getItemDetail(i)
  25.         if detail ~= nil and detail.name == "enderio:block_industrial_insulation" then
  26.             turtle.select(i)
  27.         end
  28.     end
  29.     local detail = turtle.getItemDetail(turtle.getSelectedSlot())
  30.     if detail ~= nil and detail.name == "enderio:block_industrial_insulation" and turtle.dropDown(1) then
  31.         return true
  32.     end
  33.     return false
  34. end
  35.  
  36. if not GotSpongeAmount() then
  37.     error("Not enought sponge")
  38. end
  39.  
  40. local prg = shell.getRunningProgram()
  41. rnc2.setPort(prg, 600)
  42. rnc2.setIdenty(prg, 100)
  43. rnc2.setTimeOut(prg, 2)
  44.  
  45. if turtle.detectUp() then
  46.     turtle.digUp()
  47. end
  48.  
  49. turtle.select(1)
  50. turtle.placeUp()
  51. local tmin = 10000
  52. local tmax = 0
  53. local sucked = 1
  54. local ERRORS = 2
  55.  
  56. while sucked ~= 129 do
  57.     turtle.select(1)
  58.     if turtle.suckUp() then
  59.         while not turtle.placeDown() do end
  60.         GiveSponge()
  61.         peripheral.call("bottom", "turnOn")
  62.         sleep(0.3)
  63.         temp = peripheral.wrap("bottom")
  64.         local message = "t_" .. temp.getID() .. " fg liningupsponge " .. sucked
  65.         local expect = "t_" .. temp.getID() .. "> Command resived!"
  66.         local res = nil
  67.         local continue = false
  68.         local send = true
  69.         repeat
  70.             res = nil
  71.             continue = false
  72.  
  73.             --print(message)
  74.             if send then
  75.                 rnc2.setIdenty(prg,100)
  76.                 rnc2.send(prg, message)
  77.                 send = false
  78.             end
  79.            
  80.             rnc2.setIdenty(prg,101)
  81.             local res = rnc2.resive(prg)
  82.             if res == expect then
  83.                 continue = true
  84.                 --print(res)
  85.             else
  86.                 if res == nil then
  87.                     res = "nil"
  88.                     send = true
  89.                 end
  90.                 term.setCursorPos(1,ERRORS)
  91.                 print("ERROR on " .. temp.getID() .. ":\"" .. res .. "\"")
  92.                 ERRORS = ERRORS + 1
  93.             end
  94.         until continue
  95.         term.setCursorPos(1,1)
  96.         print("success started " .. sucked)
  97.         sucked = sucked + 1
  98.         if temp.getID() > tmax then
  99.             tmax = temp.getID()
  100.         elseif temp.getID() < tmin then
  101.             tmin = temp.getID()
  102.         end
  103.     end
  104. end
  105.  
  106. turtle.select(1)
  107. turtle.digUp()
  108. local forward = 13
  109. while forward ~= 0 do
  110.     if turtle.forward() then
  111.         forward = forward - 1
  112.     end
  113. end
  114. turtle.select(2)
  115. turtle.place()
  116. local backword = 13
  117. while backword ~= 0 do
  118.     if turtle.back() then
  119.         backword = backword - 1
  120.         turtle.place()
  121.     end
  122. end
  123. turtle.turnLeft()
  124. turtle.turnLeft()
  125. turtle.select(3)
  126. turtle.place()
  127. turtle.select(4)
  128. term.setCursorPos(1,1)
  129. print("                        ")
  130. sucked = 1
  131. while sucked ~= 129 do
  132.     if turtle.detectUp() and turtle.digUp() and turtle.drop() then
  133.         sucked = sucked + 1
  134.         term.setCursorPos(1,1)
  135.         print("success collected " .. sucked)
  136.     end
  137. end
  138.  
  139. turtle.turnLeft()
  140. turtle.turnLeft()
  141. turtle.select(1)
  142. turtle.dig()
  143. forward = 13
  144. while forward ~= 0 do
  145.     if turtle.forward() then
  146.         forward = forward - 1
  147.         turtle.dig()
  148.     end
  149. end
  150. backword = 13
  151. while backword ~= 0 do
  152.     if turtle.back() then
  153.         backword = backword - 1
  154.     end
  155. end
  156. turtle.turnLeft()
  157. turtle.turnLeft()
  158. turtle.dig()
  159. turtle.turnLeft()
  160. turtle.turnLeft()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement