Karnel

platform_CC

May 5th, 2022 (edited)
975
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.52 KB | None | 0 0
  1. print(">>platform v1.1<<")
  2. local length = 32
  3. local width = 32
  4.  
  5. if arg[1] then
  6.     length = arg[1]
  7. end
  8. if arg[2] then
  9.     width = arg[2]
  10. end
  11.  
  12. local function select_block()
  13.     while true do
  14.         for slot=1,16 do
  15.             if turtle.getItemCount(slot) ~= 0 then
  16.                 turtle.select(slot)
  17.                 return true
  18.             end
  19.         end
  20.     write ("place blocks and push Enter...")
  21.     _ = read()
  22.     end
  23.     return false
  24. end
  25.  
  26.  
  27. local function build_step()
  28.     if select_block() then
  29.         turtle.placeUp()
  30.         return true
  31.     end
  32.     return false
  33. end
  34.  
  35. local function build_line()
  36.     for i=1, length-1 do
  37.         build_step()
  38.         turtle.forward()
  39.     end
  40.     build_step()
  41. end
  42.  
  43. local function build_flat()
  44.     for i=1, width -1 do
  45.         build_line()
  46.         if math.fmod(i, 2) == 1 then
  47.             turtle.turnRight()
  48.             turtle.forward()
  49.             turtle.turnRight()
  50.         else
  51.             turtle.turnLeft()
  52.             turtle.forward()
  53.             turtle.turnLeft()
  54.         end
  55.     end
  56.     build_line()
  57. end
  58.  
  59. need_fuel = width*length+length+width+10
  60. print("Fuel: "..turtle.getFuelLevel())
  61. print("Need: "..need_fuel)
  62. if turtle.getFuelLevel() > need_fuel then
  63.     turtle.forward()
  64.     turtle.down()
  65.     turtle.down()
  66.     build_flat()
  67.     if math.fmod(width, 2) == 1 then
  68.         turtle.turnLeft()
  69.         for i=1, width - 1 do
  70.             turtle.forward()
  71.         end
  72.         turtle.turnRight()
  73.         turtle.forward()
  74.     else
  75.         turtle.turnRight()
  76.         for i=1,width -1 do
  77.             turtle.forward()
  78.         end
  79.         turtle.turnRight()
  80.         for i=1,length do
  81.             turtle.forward()
  82.         end
  83.     end
  84.     turtle.up()
  85.     turtle.up()
  86.     turtle.back()
  87. else
  88.     print("not enough fuel!!!")
  89. end
  90. print("Fuel: "..turtle.getFuelLevel())
Add Comment
Please, Sign In to add comment