ame824

FieldPrepare

Oct 2nd, 2022 (edited)
393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.38 KB | Gaming | 0 0
  1. args = {...}
  2. arg1 = tonumber(args[1])
  3.  
  4. local function isempty(s)
  5.   return s == nil or s == ''
  6. end
  7.  
  8. if isempty(arg1) then
  9.     print("")
  10.     print("Benutzung: prepareField [1-6]")
  11.     print("1 = Farmland - Slot 1")
  12.     print("2 = 8 Inferium Layer - Slot 2")
  13.     print("3 = 8 Prudentium Layer - Slot 3")
  14.     print("4 = 8 Tertium Layer - Slot 4")
  15.     print("5 = 8 Imperium Layer - Slot 5")
  16.     print("6 = 8 Supremium Layer - Slot 6")
  17.     print("Bitte die notwendigen Blöcke in die slots legen!")
  18. else
  19.     if (arg1 >= 1 and arg1 <= 6) then
  20.         steps = arg1
  21.     else
  22.         print("Step-Angabe ausserhalb der Border!")
  23.     end
  24. end
  25.  
  26. function digLayer(dLayer, dBlocks)
  27.     if dLayer == steps then
  28.         turtle.dig()
  29.         turtle.forward()
  30.     else
  31.         for i=dBlocks, 1, -1 do
  32.             turtle.digDown()
  33.             if not (dLayer == 1 and i==1) then
  34.                 turtle.down()
  35.             end
  36.         end
  37.     end
  38. end
  39.  
  40. function digHole (digStep)
  41.     for i=digStep, 1, -1 do
  42.         digLayer(i, 8)
  43.     end
  44. end
  45.  
  46. function placeLayer(pLayer, pBlocks)   
  47.     turtle.select(pLayer)
  48.     if pLayer == 1 then
  49.         turtle.back()
  50.         turtle.place()
  51.     else
  52.         for i=pBlocks, 1, -1 do
  53.             turtle.placeDown()
  54.             if not (pLayer == 2 and i==1) then
  55.                 turtle.up()
  56.             end
  57.         end
  58.     end
  59. end
  60.  
  61. function placeBlocks(placeStep)
  62.     for i=placeStep, 1, -1 do
  63.         placeLayer(i, 8)
  64.     end
  65. end
  66.  
  67. function main()
  68.     digHole(steps)
  69.     placeBlocks(steps)
  70.     print("Finished!")
  71. end
  72.  
  73. if not isempty(steps) then
  74.     main()
  75. end
Add Comment
Please, Sign In to add comment