Advertisement
Guest User

zh.lua

a guest
Mar 24th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.05 KB | None | 0 0
  1. -- placeItem(TOARCH_SLOT): place() TOARCH_SLOT's item
  2. -- placeItem(CHEST_SLOT, turtle.placeUp): use placeUp()
  3. function placeItem(slot, place_func)
  4.   print("placeItem")
  5.   local place_func = place_func or turtle.place
  6.   turtle.select(slot)
  7.   local status, error_msg = place_func()
  8.   turtle.select(1)
  9.   return status, error_msg
  10. end
  11. TOARCH_SLOT = 1
  12. function placeToarch(i)
  13.   print("placeTorch")
  14.   if i%5==0  and turtle.getItemCount(TOARCH_SLOT)>0 and turtle.down() then
  15.     turtle.turnRight(); turtle.turnRight()
  16.     print('place a toarch: ', placeItem(TOARCH_SLOT))
  17.     turtle.turnRight(); turtle.turnRight()
  18.     turtle.up()
  19.    end
  20. end
  21. args={...}
  22. distance=args[1] - 1
  23.  
  24. --??????????20??????????????
  25. fuel=distance * 5 + 20
  26.  
  27. if turtle.getFuelLevel() <= fuel then
  28.   print("")
  29.   print("Fuel level is low.")
  30.   print("Set fuel in slot 1.")
  31.   turtle.select(1)
  32.   while turtle.getFuelLevel() <= fuel do
  33.     turtle.refuel()
  34.     sleep(1)
  35.   end
  36.   print("")
  37.   print("Fuel is enough!")
  38. end
  39. turtle.select(1)
  40. print("Mining start.")
  41. for i = 0,distance do
  42.   placeToarch(i)
  43.   turtle.dig()
  44.   turtle.forward()
  45.   turtle.digDown()
  46.   turtle.digUp()
  47.   turtle.turnLeft()
  48.   turtle.dig()
  49.   turtle.forward()
  50.   turtle.digDown()
  51.   turtle.digUp()
  52.   turtle.turnRight()
  53.   turtle.turnRight()
  54.   turtle.forward()
  55.   turtle.dig()
  56.   turtle.forward()
  57.   turtle.digDown()
  58.   turtle.digUp()
  59.   turtle.turnLeft()
  60.   turtle.turnLeft()
  61.   turtle.forward()
  62.   turtle.turnRight()
  63.   remain = distance - i
  64.   print("Remaining: ",remain," m")
  65.   if turtle.getSelectedSlot() == 16 then
  66.     turtle.turnRight()
  67.     turtle.turnRight()
  68.     for i=0,distance do
  69.       turtle.forward()
  70.     end
  71.     for i=2,16 do
  72.       turtle.select(i)
  73.       turtle.dropDown()
  74.     end
  75.     turtle.turnLeft()
  76.     turtle.turnLeft()
  77.     for i=0,distance do
  78.       turtle.forward()
  79.     end
  80.   end
  81. end
  82. turtle.turnRight()
  83. turtle.turnRight()
  84. for i=0,distance do
  85.   turtle.forward()
  86. end
  87. for i=2,16 do
  88.   turtle.select(i)
  89.   turtle.dropDown()
  90. end
  91. turtle.turnLeft()
  92. turtle.turnLeft()
  93. print("Mining has ended!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement