Advertisement
Guest User

startup.lua

a guest
Jun 25th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.03 KB | None | 0 0
  1. rednet.open("left")
  2.  
  3.  
  4. function bucher(arbres)
  5. local ok = 0
  6. local leaves = 0
  7.  
  8.  turtle.turnLeft()
  9.  forwarding()
  10.  
  11.  for j=1, arbres do
  12.  
  13.   for i=1,5 do
  14.  
  15.    while not turtle.forward() and not turtle.inspect() do
  16.     os.sleep(0.5)
  17.    end
  18.   end
  19.   turtle.turnLeft()
  20.  
  21.   while ok==0 do --boucle pour bucher l'arbre
  22.    s, data = turtle.inspect()
  23.  
  24.    if data.name ~= "minecraft:log"
  25.    then ok = 1
  26.    else turtle.select(5)
  27.     turtle.dig()
  28.     rednet.send(27,"1", "bois")
  29.     ls, ldata = turtle.inspectUp()
  30.     turtle.digUp()
  31.    
  32.     while not turtle.up() and not ls do
  33.     os.sleep(0.5)
  34.     end
  35.    end
  36.   end
  37.  
  38.   ok = 0
  39.  
  40.   while ok==0 do --boucle de descente
  41.    gs, gdata = turtle.inspectDown()
  42.    if gdata.name == "chisel:stonebrick" then ok = 1
  43.    else turtle.down() end
  44.   end
  45.   turtle.select(2)
  46.   turtle.place()
  47.   turtle.turnRight()
  48.  end
  49.  
  50.  forwarding()
  51.  --s, data = turtle.inspect()
  52.  --while not turtle.forward() and not s do
  53.  --os.sleep(0.5)
  54.  --end
  55.  
  56. end
  57.  
  58. function chemin(moves)
  59.  for i=1, moves do
  60.  forwarding()
  61.   --s, data = turtle.inspect()
  62.   --while not turtle.forward() and not s do
  63.    --os.sleep(0.5)
  64.   --end
  65.  end
  66. end
  67.  
  68. function chest()
  69.  for i=5, 16 do
  70.   turtle.select(i)
  71.   data = turtle.getItemDetail()
  72.   if data then
  73.    if data.name == "minecraft:log"
  74.    then turtle.dropUp()
  75.    else i=17 end
  76.   end
  77.  end
  78.  turtle.select(2)
  79.  turtle.suckUp()
  80.  turtle.select(1)
  81.  if turtle.getItemCount() < 34 then turtle.suck(34-turtle.getItemCount(1)) end
  82.  
  83.  turtle.turnRight()
  84.  forwarding()
  85.  --ps = turtle.inspect()
  86.  --while not turtle.forward() and not ps do
  87.   --os.sleep(0.5)
  88.  --end
  89.  turtle.turnLeft()
  90.  
  91.  chemin(5)
  92. end
  93.  
  94. function forwarding()
  95.  s = turtle.detect()
  96.  while not turtle.forward() and not s do
  97.   os.sleep(0.5)
  98.  end
  99. end
  100.  
  101. while true do
  102. local s, data = turtle.inspect()
  103. local bs, bdata = turtle.inspectDown()
  104. local fuel_lvl = turtle.getFuelLevel()
  105.  
  106.  if fuel_lvl <= 40
  107.  then turtle.select(1)
  108.  turtle.refuel(1) end
  109.  
  110.  rednet.send(27,fuel_lvl,"fuel")
  111.  
  112.  if data.name == "minecraft:glowstone" and bdata.name == "chisel:stonebrick"
  113.  then bucher(4)
  114.  end
  115.  
  116.  if data.name == "chisel:laboratory" and bdata.name == "chisel:stonebrick"
  117.  then turtle.turnRight()
  118.  forwarding()
  119.  turtle.turnLeft()
  120.  chemin(6)
  121.  end
  122.  
  123.  if data.name == "minecraft:glowstone" and bdata.name == "chisel:laboratory"
  124.  then bucher(2)
  125.  end
  126.  
  127.  if data.name == "chisel:laboratory" and bdata.name == "minecraft:glowstone"
  128.  then bucher(3)
  129.  end
  130.  
  131.  if data.name == "minecraft:glowstone" and bdata.name == "chisel:glowstone"
  132.  then bucher(1)
  133.  end
  134.  
  135.  if data.name == "chisel:glowstone" and bdata.name == "chisel:glowstone"
  136.  then turtle.turnLeft()
  137.   chemin(9)
  138.  end
  139.  
  140.  if data.name == "chisel:glowstone" and bdata.name == "chisel:laboratory"
  141.  then turtle.turnLeft()
  142.   chemin(14)
  143.  end
  144.  
  145.  if data.name == "chisel:glowstone" and bdata.name == "minecraft:glowstone"
  146.  then turtle.turnLeft()
  147.   chemin(2)
  148.  end
  149.  
  150.  if data.name == "minecraft:chest" and bdata.name == "chisel:stonebrick"
  151.  then chest()
  152.  end
  153. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement