Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x = 0
- y = 0
- xmax = 0
- size = 0
- oakTotal = 0
- birchTotal = 0
- depositChest = 0
- currentChestFullness = 0
- function writeFile()
- file = fs.open("ArchiveInfo", "w")
- file.writeLine(xmax)
- file.writeLine(size)
- file.writeLine(oakTotal)
- file.writeLine(birchTotal)
- file.writeLine(depositChest)
- file.writeLine(currentChestFullness)
- file.close()
- end
- function readFile()
- file = fs.open("ArchiveInfo","r")
- fileData = {}
- local i = 0
- while i < 6 do
- line = file.readLine()
- table.insert(fileData, line)
- i = i + 1
- end
- file.close()
- xmax = tonumber(fileData[1])
- size = tonumber(fileData[2])
- oakTotal = tonumber(fileData[3])
- birchTotal = tonumber(fileData[4])
- depositChest = tonumber(fileData[5])
- currentChestFullness = tonumber(fileData[6])
- end
- function printData()
- print("x = ", x)
- print("y = ", y)
- print("xmax = ", xmax)
- print("size = ", size)
- print("oakTotal = ", oakTotal)
- print("birchTotal = ", birchTotal)
- print("depositChest = ", depositChest)
- print("currentChestFullness = ", currentChestFullness)
- end
- function countWood()
- for i = 2,16,1 do
- local data = turtle.getItemDetail(i)
- if data ~= nil then
- if data.damage == 0 then
- oakTotal = oakTotal + data.count
- end
- if data.damage == 2 then
- birchTotal = birchTotal + data.count
- end
- end
- end
- writeFile()
- end
- function makeChests()
- turtle.select(2)
- local data = turtle.getItemDetail()
- if data.damage == 0 then
- oakTotal = oakTotal - 32
- end
- if data.damage == 2 then
- birchTotal = birchTotal - 32
- end
- turtle.dropDown(16)
- sleep(3)
- turtle.dropDown(16)
- sleep(5)
- turtle.select(1)
- end
- function hardDig()
- while turtle.detect() do
- turtle.dig()
- end
- end
- function digFour()
- turtle.up()
- turtle.up()
- turtle.up()
- turtle.up()
- hardDig()
- turtle.down()
- hardDig()
- turtle.down()
- hardDig()
- turtle.down()
- hardDig()
- turtle.down()
- hardDig()
- end
- function chestColumn()
- turtle.up()
- turtle.up()
- turtle.up()
- turtle.up()
- hardDig()
- turtle.select(1)
- turtle.down()
- hardDig()
- turtle.place()
- turtle.down()
- hardDig()
- turtle.place()
- turtle.down()
- hardDig()
- turtle.place()
- turtle.down()
- hardDig()
- turtle.place()
- end
- function fullChest()
- digFour()
- if turtle.forward() then
- x = x + 1
- end
- digFour()
- turtle.turnLeft()
- chestColumn()
- turtle.turnRight()
- turtle.turnRight()
- chestColumn()
- turtle.turnLeft()
- if turtle.forward() then
- x = x + 1
- end
- turtle.turnLeft()
- chestColumn()
- turtle.turnRight()
- turtle.turnRight()
- chestColumn()
- turtle.turnLeft()
- if turtle.back() then
- x = x - 1
- end
- if turtle.back() then
- x = x - 1
- end
- xmax = xmax + 3
- size = size + 27648
- writeFile()
- end
- function deposit()
- for i = 2,16,1 do
- currentChestFullness = currentChestFullness + turtle.getItemCount(i)
- turtle.select(i)
- turtle.drop()
- end
- if currentChestFullness >= 3456 then
- currentChestFullness = 0
- if depositChest ~= 7 then
- depositChest = depositChest + 1
- else
- depositChest = 0
- end
- end
- writeFile()
- end
- function determineChest()
- if depositChest <= 3 then
- turtle.turnLeft()
- if depositChest == 0 then
- deposit()
- end
- if depositChest == 1 then
- turtle.up()
- deposit()
- turtle.down()
- end
- if depositChest == 2 then
- turtle.up()
- turtle.up()
- deposit()
- turtle.down()
- turtle.down()
- end
- if depositChest == 3 then
- turtle.up()
- turtle.up()
- turtle.up()
- deposit()
- turtle.down()
- turtle.down()
- turtle.down()
- end
- turtle.turnRight()
- end
- if depositChest >= 4 then
- turtle.turnRight()
- if depositChest == 4 then
- deposit()
- end
- if depositChest == 5 then
- turtle.up()
- deposit()
- turtle.down()
- end
- if depositChest == 6 then
- turtle.up()
- turtle.up()
- deposit()
- turtle.down()
- turtle.down()
- end
- if depositChest == 7 then
- turtle.up()
- turtle.up()
- turtle.up()
- deposit()
- turtle.down()
- turtle.down()
- turtle.down()
- end
- turtle.turnLeft()
- end
- end
- function returnHome()
- while y > 0 do
- if turtle.down() then
- y = y - 1
- else
- turtle.digDown()
- end
- end
- while x > 0 do
- if turtle.back() then
- x = x - 1
- end
- end
- end
- while true do
- local event, p1 = os.pullEvent("turtle_inventory")
- sleep(5)
- readFile()
- countWood()
- printData()
- if oakTotal + birchTotal > size then
- makeChests()
- while x < xmax do
- if turtle.forward() then
- x = x + 1
- else
- digFour()
- end
- end
- fullChest()
- end
- returnHome()
- printData()
- sleep(1)
- while x < xmax - 2 do
- if turtle.forward() then
- x = x + 1
- else
- digFour()
- end
- end
- determineChest()
- returnHome()
- printData()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement