Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local whereWall = nil
- local curWall = nil
- local blockToWall = {
- ["minecraft:stripped_oak_log"]=0,
- ["minecraft:oak_log"]=1,
- ["minecraft:bricks"]=2,
- }
- while whereWall == nil or curWall == nil do
- local s,b = turtle.inspect()
- if b.name == "minecraft:stripped_oak_log" or b.name == "minecraft:oak_log" or b.name == "minecraft:bricks" then
- whereWall = 0
- curWall = blockToWall[b.name]
- break
- else
- turtle.turnLeft()
- end
- end
- print("Found wall: ", curWall)
- function turnLeft()
- turtle.turnLeft()
- whereWall = (whereWall - 1) % 4
- end
- function turnRight()
- turtle.turnRight()
- whereWall = (whereWall + 1) % 4
- end
- function forward()
- if whereWall % 2 == 0 then
- return false, "may not escape 2d working area or run into wall"
- end
- local s,r = turtle.forward()
- if not s then
- return false, r
- end
- if whereWall == 1 then
- curWall = (curWall + 1) % 3
- return true
- elseif whereWall == 3 then
- curWall = (curWall - 1) % 3
- return true
- end
- end
- function goWall(wall)
- if curWall ~= wall then
- dist = wall - curWall
- if dist > 0 and whereWall ~= 1 then
- while whereWall ~= 1 do
- if whereWall > 1 then
- turnLeft()
- else
- turnRight()
- end
- end
- elseif dist < 0 and whereWall ~= 3 then
- while whereWall ~= 3 do
- if whereWall < 1 then
- turnLeft()
- else
- turnRight()
- end
- end
- end
- dist = math.abs(dist)
- for i=1,dist do
- forward()
- end
- end
- end
- function cabinet()
- goWall(2)
- end
- cabinet()
- while true do
- local success, block = turtle.inspectDown()
- addItemDown("farmersdelight:tomato_sauce",64)
- end
Advertisement
Add Comment
Please, Sign In to add comment