Advertisement
Bjornir90

LapisFinder

Jun 23rd, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.26 KB | None | 0 0
  1. --Un programme de detection de lapis
  2. local heigth = 14 --distance to level 14
  3. local length = 64*16/3-1 --length of the tunnel
  4. local position = 0
  5. local detected = false
  6. local orePos = {x=0, y=0}
  7.  
  8. print("Enter the heigth to level 14 :")
  9. heigth = read()
  10.  
  11. function dw(step)
  12.  for i=1, step do
  13.   turtle.digDown()
  14.   turtle.down()
  15.  end
  16. end
  17.  
  18. function fw(step)
  19.  for i=1, step do
  20.  print("Inspecting front block\n")
  21.   local isBlock, data = turtle.inspect()
  22.   if isBlock then
  23.    if data.name == "minecraft:lapisore" then
  24.     detected = true
  25.     orePos.x = position+1
  26.     orePos.y = 14
  27.     return detected
  28.    end
  29.    else
  30.     turtle.dig()
  31.    end
  32.   end
  33.   print("Inspecting down block\n")
  34.   isBlock, data = turtle.inspectDown()
  35.   if isBlock then
  36.    if data.name == "minecraft:lapisore" then
  37.     detected = true
  38.     orePos.x = position
  39.     orePos.y = 13
  40.     return detected
  41.    end
  42.    else
  43.     turtle.digDown()
  44.    end
  45.   end
  46.   print("Inspecting up block\n")
  47.   isBlock, data = turtle.inspectUp()
  48.   if isBlock then
  49.    if data.name == "minecraft:lapisore" then
  50.     detected = true
  51.     orePos.x = position
  52.     orePos.y = 15
  53.     return detected
  54.    end
  55.   end
  56.   turtle.turnLeft()
  57.   print("Inspecting left block\n")
  58.   isBlock, data = turtle.inspect()
  59.   turtle.turnRight()
  60.   if isBlock then
  61.    if data.name == "minecraft:lapisore" then
  62.     detected = true
  63.     orePos.x = position
  64.     orePos.y = 14
  65.     return detected
  66.    end
  67.   end
  68.   turtle.turnRight()
  69.   print("Inspecting right block\n")
  70.   isBlock, data = turtle.inspect()
  71.   turtle.turnLeft()
  72.   if isBlock then
  73.    if data.name == "minecraft:lapisore" then
  74.     detected = true
  75.     orePos.x = position
  76.     orePos.y = 14
  77.     return detected
  78.    end
  79.   end
  80.   turtle.forward()
  81.   position = position + 1
  82.   if position%12 == 0 then
  83.    print("Placing a torch\n")
  84.    turtle.select(1)
  85.    turtle.turnLeft()
  86.    turtle.place()
  87.    turtle.turnRight()
  88.   end
  89.  end
  90. end
  91.  
  92. dw(heigth)
  93. fw(length)
  94. if detected then
  95.  f = fs.open("ore", "w")
  96.  f.write("Ore position :"..orePos.x.." Ore heigth :"..orePos.y)
  97.  f.close()
  98.  term.clear()
  99.  print("Ore position :"..orePos.x.." Ore heigth :"..orePos.y)
  100. end
  101. turtle.turnLeft()
  102. turtle.turnLeft()
  103. for i=1, position do
  104.  turtle.forward()
  105. end
  106. for u=1, heigth do
  107.  turtle.up()
  108. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement