Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArg = {...}
- local height = tonumber(tArg[1] or "") or 45
- local length = tonumber(tArg[2] or "") or 30
- turtle.refuel(64)
- turtle.select(1)
- local saveFile = "lastpos.dat"
- local saveState = function(x, y)
- local file = fs.open(saveFile, "w")
- file:writeLine(x)
- file:writeLine(y)
- file.close()
- end
- local loadState = function()
- local file = fs.open(saveFile, "r")
- local x = tonumber(file:readLine())
- local y = tonumber(file:readLine())
- file.close()
- return x, y
- end
- local function place()
- if turtle.getItemCount() == 0 then
- for i = 1, 16 do
- if turtle.getItemCount(i) > 0 then
- turtle.select(i)
- turtle.placeDown()
- return true
- end
- end
- else
- turtle.placeDown()
- return true
- end
- return false
- end
- local function goUp()
- repeat until turtle.up()
- end
- local function goForward()
- repeat until turtle.forward()
- end
- local function goBack()
- repeat until turtle.forward()
- end
- local startX, startY
- if fs.exists(saveFile) then
- print("Save file found.")
- startX, startY = loadState()
- else
- goUp()
- end
- for y = startY or 1, height - 1 do
- for x = startX or 1, length do
- saveState()
- if not place() then
- print("Ran out of shit. Fuck you")
- print("Please insert more shit")
- repeat
- sleep(0.5)
- until place()
- print("Cheers")
- end
- if x ~= length then
- if y % 2 == 1 then
- turtle.forward()
- else
- turtle.back()
- end
- end
- end
- if y ~= height - 1 then
- goUp()
- end
- startX = 1
- end
- print("All done.")
- fs.delete(saveFile)
Add Comment
Please, Sign In to add comment