Advertisement
Guest User

geoPit

a guest
Aug 24th, 2015
690
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.11 KB | None | 0 0
  1. local component = require("component")
  2. local robot = require("robot")
  3. local moving = require("smartMoving")
  4. local geo = component.geolyzer
  5. local ic = component.inventory_controller
  6.  
  7. print("Положите сундук в первый слот инвентаря.\n\nВведите число от 1 до 32,\nэто будет радиус шахты.\nТо есть по столько в каждую сторону.")
  8. local size = io.read()
  9. local invSize = robot.inventorySize()
  10. local iter = 0
  11. local tab = {}
  12. local tab2 = {}
  13. local center = (size * 2 + 1) * size + size + 1
  14.  
  15. local function scan(tab3, u)
  16.   for z = -size, size do
  17.     for x = -size, size do
  18.       local scanTable = (geo.scan(x, z))
  19.       local isNeed = false
  20.       local height = 0
  21.       iter = iter + 1
  22.       if u == 1 then
  23.         for i = 28, 38 do
  24.           if scanTable[i] > 2.5 and scanTable[i] < 3.5 then
  25.             isNeed = true
  26.             height = 10-(i-28)
  27.             break
  28.           end
  29.         end
  30.       end
  31.       if u == 2 then
  32.         for i = 38, 28, -1 do
  33.           if scanTable[i] > 2.5 and scanTable[i] < 3.5 then
  34.             isNeed = true
  35.             height = 10-(i-28)
  36.             break
  37.           end
  38.         end
  39.       end
  40.       if isNeed then
  41.         tab3[iter] = height
  42.       else
  43.         tab3[iter] = -1
  44.       end
  45.     io.write(" ", tostring(tab3[iter]))
  46.     end
  47.     print("\nСканируется ".. math.floor(iter * 100 /(size*2+1)^2) .. "%...")
  48.   end
  49.   iter = 0
  50. end
  51.  
  52. local function drop()
  53.   if ic.getInventorySize(0) ~= nil then
  54.     for i = invSize, 1, -1 do
  55.       robot.select(i)
  56.       robot.dropDown()
  57.     end
  58.   else
  59.     for i = invSize, 1, -1 do
  60.       local t = ic.getStackInInternalSlot(i)
  61.       if t ~= nil and (t.name == "minecraft:cobblestone" or t.name == "minecraft:dirt" or t.name == "minecraft:gravel") then
  62.         robot.select(i)
  63.         robot.drop()
  64.       end
  65.     end
  66.   end
  67.   robot.select(1)
  68. end
  69.  
  70. local function maining()
  71. iter = 0
  72. goY(5)                                               -- переделать!!!!!
  73.   for z = -size, size do
  74.     for x = -size, size do
  75.       iter = iter + 1
  76.       if tab[iter] ~= -1 then
  77.         if not (goZ(z) and goX(x)) then
  78.           goDown()
  79.           goZ(z)
  80.           goX(x)
  81.         end
  82.         goY(5 - tab[iter])
  83.         goY(5)
  84.       end
  85.       if tab2[iter] ~= -1 then
  86.         if not (goZ(z) and goX(x)) then
  87.           goUp()
  88.           goZ(z)
  89.           goX(x)
  90.         end
  91.         goY(16 - tab2[iter])
  92.         goY(5)
  93.       end
  94.       if ic.getStackInInternalSlot(invSize) then
  95.         if not (goZ(0) and goX(0)) then
  96.           goDown()
  97.           goZ(0)
  98.           goX(0)
  99.         end
  100.         drop()
  101.         goY(0)
  102.         drop()
  103.         goY(5)
  104.       end      
  105.     end
  106.   end
  107.   if not (goX(0) and goZ(0)) then
  108.     goDown()
  109.     goX(0)
  110.     goZ(0)
  111.   end
  112.   drop()
  113.   goY(0)
  114.   drop()
  115. end
  116.  
  117. scan(tab, 1)
  118. tab[center] = -1
  119. robot.swingDown()
  120. robot.placeDown()
  121. if not goY(11) then
  122.   goEast()
  123.   goY(11)
  124.   goX(0)
  125.   goZ(0)
  126.   turnNorth()
  127.   print("Хозяин, ты куда меня послал? Дурень!")
  128. end
  129. scan(tab2, 2)
  130. maining()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement