Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local coalChest = "minecraft:chest"
- local dir = 1
- local coalDir = 1
- local chestDirs = {["minecraft:iron_block"]=4, ["minecraft:redstone"]=2, ["minecraft:ender_pearl"]=3}
- function findCoalChest()
- for i = 1,4 do
- local block, data = turtle.inspect()
- if block then
- if data.name == coalChest then
- dir = 1
- return
- end
- end
- turtle.turnRight()
- end
- end
- function right()
- turtle.turnRight()
- dir = dir+1
- if dir > 4 then
- dir = 1
- end
- end
- function left()
- turtle.turnLeft()
- dir = dir-1
- if dir < 1 then
- dir = 4
- end
- end
- function setDir(d)
- if dir == 1 and d == 4 then
- left()
- elseif dir == 4 and d == 1 then
- right()
- end
- while d > dir do
- right()
- end
- while d < dir do
- left()
- end
- end
- function fillInv()
- while turtle.detectUp() == false do
- turtle.up()
- end
- if turtle.getFuelLevel() < 1000 then
- setDir(1)
- turtle.select(16)
- turtle.suck(10)
- turtle.refuel(64)
- end
- local invDef = {[1]="minecraft:iron_block", [2]="minecraft:redstone", [3]="minecraft:ender_pearl"}
- local invLayout = {1, 1, 2, 2,
- 3, 3, 3, 3,
- 3, 3, 3, 3}
- for i = 1, 12 do
- local item = invDef[invLayout[i]]
- local count = 64
- if item == "minecraft:ender_pearl" then
- count = 16
- end
- if turtle.getItemCount(i) < count then
- setDir(chestDirs[item])
- turtle.select(i)
- turtle.suck(count - turtle.getItemCount())
- end
- end
- end
- function pick(item)
- for i = 1,12 do
- turtle.select(i)
- local data = turtle.getItemDetail()
- if data then
- if data.name == item then
- return
- end
- end
- end
- --If no items were found then go fill up
- fillInv()
- pick(item)
- turtle.down()
- turtle.down()
- end
- function makeWall()
- while turtle.detectUp() == false do
- turtle.up()
- end
- turtle.down()
- turtle.down()
- pick("minecraft:iron_block")
- turtle.placeDown()
- turtle.up()
- pick("minecraft:redstone")
- turtle.placeDown()
- turtle.up()
- pick("minecraft:ender_pearl")
- turtle.dropDown(1)
- end
- findCoalChest()
- while true do
- makeWall()
- sleep(12)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement