Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = { ... }
- local size = args[1]
- local function is_stone_below()
- local success, data = turtle.inspect()
- if not success then
- return false
- end
- if data.name == "minecraft:stone" then
- return true
- end
- return false
- end
- local function find_stone()
- for s = 1, 16 do
- turtle.select(s)
- if turtle.getItemDetail() and turtle.getItemDetail().name == "minecraft:stone" then
- return true
- end
- end
- return false
- end
- local function select_stone()
- while true do
- if find_stone() then
- return
- end
- os.pullEvent('turtle_inventory')
- end
- end
- local function do_replace()
- if is_stone_below() then
- return
- end
- -- Not stone
- turtle.digDown()
- turtle.placeDown()
- end
- local function check_fuel(amount)
- if not amount then
- amount = 1
- end
- if turtle.getFuelLevel() < amount then
- while true do
- if turtle.refuel() then
- return
- end
- os.pullEvent('turtle_inventory')
- end
- end
- end
- local orientation_fw = true
- local function init()
- for x = 0, size do
- for z = 0, size do
- check_fuel(1)
- do_replace()
- turtle.forward()
- end
- if orientation_fw then
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- orientation_fw = false
- else
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- orientation_fw = true
- end
- end
- end
- if not size then
- print("Missing args")
- else
- init()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement