K0ne28

Computercraft Turtle Stein Wand

Nov 17th, 2023
645
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.80 KB | Gaming | 0 0
  1. function checkIfStone()
  2.     local success, data = turtle.inspect()
  3.     if success then
  4.        if data.name == "minecraft:stone" then
  5.            return true
  6.        end
  7.     end
  8.     return false
  9. end
  10.  
  11. function checkInventory(curSlot)
  12.     if turtle.getItemDetail() == nil or turtle.getItemDetail().name ~= "minecraft:stone" then
  13.         repeat
  14.            curSlot = curSlot + 1
  15.            turtle.select(curSlot)        
  16.         until turtle.getItemDetail().name == "minecraft:stone"    
  17.     end
  18.     return curSlot
  19. end    
  20.  
  21. function checkFuel(curSlot)
  22.     if turtle.getFuelLevel() ~= "unlimited" and turtle.getFuelLevel() < 1 then
  23.         turtle.select(16)
  24.         while turtle.refuel(0) == false do
  25.             print("Bitte Treibstoff in Slot 16 Füllen!")
  26.             os.sleep(2)
  27.         end
  28.             turtle.refuel(1)
  29.             turtle.select(curSlot)
  30.     end
  31. end
  32.  
  33. turtle.select(1)
  34. print("Fuel: Slot 16")
  35. print("Stone: Slot 1-15")
  36. print("Höhe: ")
  37. local height = read()
  38. print("Breite (nach rechts):")
  39. local width = read()
  40.  
  41. curSlot = 1
  42.  
  43. for i=1, width do
  44.     for j=1, (height-1) do
  45.         checkFuel(curSlot)
  46.         if checkIfStone() == false then
  47.             turtle.dig()
  48.             curSlot = checkInventory(curSlot)
  49.             turtle.place()
  50.         end
  51.         if i%2 == 1 and j ~= height then
  52.             turtle.up()
  53.         end
  54.         if i%2 == 0 and j ~= height then
  55.             turtle.down()
  56.         end
  57.     end
  58.     if checkIfStone() == false then
  59.         turtle.dig()
  60.         curSlot = checkInventory(curSlot)
  61.         turtle.place()
  62.     end
  63.     if i < tonumber(width) then    
  64.         turtle.turnRight()
  65.         turtle.forward()
  66.         turtle.turnLeft()
  67.     end
  68. end
  69. if tonumber(width)%2 == 1 then
  70.     for i=0, (height-1) do
  71.         turtle.down()
  72.     end
  73. end
Tags: wall
Advertisement
Add Comment
Please, Sign In to add comment