Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- size_z = 16
- size_x = 32
- size_y = 1
- path = {}
- function createPath()
- i = 1
- for y = 1, size_y, 1 do
- for z = 1, size_z, 1 do
- for z = 1, size_x, 1 do
- path[i] = "mov"
- i = i + 1
- end
- path[i] = "tl"
- i = i + 1
- path[i] = "mov"
- i = i + 1
- path[i] = "tl"
- i = i + 1
- for z = 1, size_x, 1 do
- path[i] = "mov"
- i = i +1
- end
- path[i] = "tr"
- i = i + 1
- path[i] = "mov"
- i = i + 1
- path[i] = "tr"
- i = i + 1
- end
- path[i] = "y"
- i = i + 1
- path[i] = "y"
- i = i + 1
- path[i] = "y"
- i = i + 1
- path[i] = "tl"
- i = i + 1
- end
- end
- function putChest()
- while turtle.detectDown() do
- turtle.digDown()
- end
- turtle.select(1)
- turtle.placeDown()
- for i = 2, 16 do
- turtle.select(i)
- turtle.dropDown()
- end
- turtle.select(1)
- -- Ender chest
- turtle.digDown()
- end
- function move()
- while turtle.detectUp() do
- turtle.digUp()
- end
- while turtle.detect() do
- turtle.dig()
- end
- while turtle.detectDown() do
- turtle.digDown()
- end
- os.sleep(0.2)
- turtle.forward()
- end
- function serialize(data, name)
- if not fs.exists('/data') then
- fs.makeDir('/data')
- end
- local f = fs.open('/data/'..name, 'w')
- f.write(textutils.serialize(data))
- f.close()
- end
- function unserialize(name)
- if fs.exists('/data/'..name) then
- local f = fs.open('/data/'..name, 'r')
- data = textutils.unserialize(f.readAll())
- f.close()
- else
- data = cp
- end
- return data
- end
- counter = 0
- -- Loads path, if dont exit create
- if not fs.exists('/data/'..name) then
- createPath()
- path["startPoint"] = 1
- serialize(path, 'tpath')
- else
- path = unserialize('tpath')
- end
- -- Find path size
- for i, value in pairs(path) do
- counter = counter + 1
- end
- for i = path["startPoint"], counter do
- print(path[i])
- if path[i] == "mov" then
- move()
- end
- if path[i] == "tr" then
- turtle.turnRight()
- end
- if path[i] == "tl" then
- turtle.turnLeft()
- end
- if path[i] == "y" then
- turtle.digDown()
- turtle.moveDown()
- end
- if turtle.getItemCount(16) > 0 then
- putChest()
- end
- path["startPoint"] = path["startPoint"] + 1
- serialize(path, 'tpath')
- end
Add Comment
Please, Sign In to add comment