Advertisement
Inksaver

CobbleGenerator

Mar 19th, 2022
844
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.18 KB | None | 0 0
  1. local T
  2.  
  3. local function checkFuelNeeded(quantity)
  4.     local fuelNeeded = quantity - turtle.getFuelLevel() -- eg 600
  5.     if fuelNeeded > 0 then
  6.         T:checkInventoryForItem({"minecraft:lava_bucket", "coal", "planks"}, {1, math.ceil(fuelNeeded / 60), math.ceil(fuelNeeded / 15)}) -- 0 if not present  
  7.         T:refuel(quantity, true)
  8.     end
  9. end
  10.  
  11. local function getSupplies()
  12.     T:clear()
  13.     T:checkInventoryForItem({"minecraft:chest"}, {4}, true)
  14.     T:checkInventoryForItem({"stairs"}, {16}, true)
  15.     T:checkInventoryForItem({"minecraft:lava_bucket"}, {1}, true)
  16.     T:checkInventoryForItem({"minecraft:water_bucket"}, {1}, true)
  17. end
  18.  
  19. local function createGenerator()
  20.     local function placeStairs(path, direction)
  21.         T:go(path)
  22.         T:place("minecraft:cobblestone_stairs", 0, direction)
  23.     end
  24.    
  25.     checkFuelNeeded(250)
  26.     getSupplies()
  27.     T:up(2)
  28.     T:place("minecraft:chest", 0, "forward")
  29.    
  30.     placeStairs("U1", "forward")        -- first stairs, facing inwards, to hold water
  31.     placeStairs("U1B1","down")          -- stairs on opposite side, centre of back edge
  32.     placeStairs("R1F1L1","down")        -- stairs on back left corner
  33.     placeStairs("F1L1","down")          -- centre left
  34.     placeStairs("R1F1L1","down")        -- front left corner
  35.    
  36.     placeStairs("F2L2","down")          -- front centre
  37.     placeStairs("R1F1L1","down")        -- front right corner
  38.     placeStairs("R1F1L1","down")        -- right side centre
  39.    
  40.     placeStairs("B1","forward")         -- right back corner, top layer
  41.     for i = 1, 3 do                     -- back, left and front top layer
  42.         placeStairs("R1F1L1F2L1","forward")
  43.         placeStairs("R1F1L1","forward")
  44.     end
  45.     placeStairs("R1F1L1F2L1","forward") -- right centre top layer
  46.     T:go("U1F2L1F1R2x2")                -- move above water source step and dig out covering stair
  47.     T:place("minecraft:water_bucket", 0, "down")
  48.     placeStairs("D1B1","forward")       -- replace stairs removed to allow water access
  49.     T:go("U1F2L2D2")                    -- move to 1 above final position
  50.     T:place("minecraft:lava_bucket", 0, "up")
  51.     T:down(1)                           -- move to final position
  52.     for i = 1, 3 do                     -- place remaining 3 chests
  53.         T:turnRight(1)
  54.         T:place("minecraft:chest", 0, "forward")
  55.     end
  56. end
  57.  
  58. function main()
  59.     T = require("lib.clsTurtle"):new(true) -- true enables logfile to log.txt
  60.     createGenerator()
  61. end
  62.  
  63. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement