Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function refuel(requireFuel)
- currentFuel = turtle.getFuelLevel()
- diffFuel = requireFuel - currentFuel
- requireCoal = math.ceil(diffFuel / 80)
- cnt = turtle.getItemCount(16)
- if cnt < requireCoal then
- print("require coal: " .. requireCoal)
- return false
- end
- turtle.select(16)
- turtle.refuel(requireCoal)
- return true
- end
- function shiftRight()
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- end
- function backLeft(width)
- turtle.turnLeft()
- for i = 1, width do
- turtle.forward()
- end
- turtle.turnRight()
- end
- function backDown(height)
- for i = 1, height do
- turtle.down()
- end
- end
- function getBlock()
- if turtle.detect() then
- for i = 1, 16 do
- if turtle.getItemCount(i) == 0 then
- turtle.dig()
- return i
- end
- turtle.select(i)
- if turtle.compare() then
- turtle.dig()
- return i
- end
- end
- else
- return 0
- end
- end
- write("Enter Filename\n")
- path = read()
- if path == "" then
- return
- end
- write("Enter Width\n")
- width = read()
- write("Enter Height\n")
- height = read()
- write("Enter Depth\n")
- depth = read()
- if refuel(((((width * 2) + 2) * height) + 1) * depth) ~= true then
- return
- end
- f = fs.open(path, "wb")
- f.write(tonumber(width))
- f.write(tonumber(height))
- f.write(tonumber(depth))
- for z = 1, depth do
- for y = 1, height do
- for x = 1, width do
- f.write(getBlock())
- shiftRight()
- end
- backLeft(width)
- turtle.up()
- end
- backDown(height)
- turtle.forward()
- end
- f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement