Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = {...}
- local function isEmpty(val)
- return val == nil or val == ""
- end
- local function log(val)
- write(val .. "\n")
- end
- local function validate(x, z, y)
- if x > 100 or z > 100 or y > 100 then
- log("Vc vai fazer merda mano. Não vou deixar mais do que 100.")
- return false
- end
- return true
- end
- local function refuel()
- for i=1,16 do
- turtle.select(i)
- if turtle.refuel() then
- log("Recarreguei, que delícia cara.")
- return true;
- end
- end
- return false;
- end
- local function checkFuel()
- if turtle.getFuelLevel() < 200 then
- log("Quase sem gasosa, tentando recarregar.")
- return refuel()
- end
- return true;
- end
- local function start()
- local x = tonumber(args[1])
- local z = tonumber(args[2])
- local y = tonumber(args[3])
- if not validate(x, z, y) then
- return
- end
- log("Parâmetros válidos.")
- local turnRight = true
- for curY = 1, y do
- for curX = 1, x do
- for curZ = 1, z do
- log("Posição x:" .. x .. " z:" .. z .. " y:" .. y)
- if not checkFuel() then
- term.setTextColor(colors.red);
- log("To sem gás viado.");
- term.setTextColor(colors.white);
- return;
- end
- turtle.dig()
- turtle.forward()
- end
- if curX ~= x then
- if turnRight then
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- else
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- end
- turnRight = not turnRight;
- end
- end
- if curY ~= y then
- turtle.digDown()
- turtle.down()
- turtle.turnRight()
- turtle.turnRight()
- end
- end
- end
- start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement