Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local prefix = "[Carlos 0.1a] "
- -- Funcao printf
- local function printf(...) print(string.format(...)) end
- -- Funcao combustivel
- local function combustivel()
- local restante = turtle.getFuelLevel() -- Combustivel restante
- local suficiente = false
- while true do
- if restante == 0 then
- suficiente = false
- printf("%s Sem combustivel restante, tentando reabastecer.", prefix)
- for i = 1, 16 do
- turtle.select(i)
- if turtle.refuel(0) then
- local halfStack = math.ceil(turtle.getItemCount(i)/2)
- turtle.refuel(halfStack)
- break
- end
- end
- else
- printf("%s Combustivel restante: %s", prefix, restante)
- suficiente = true
- break
- end
- return suficiente
- end
- local function minerar()
- local possivel = combustivel()
- if possivel then
- turtle.dig()
- turtle.forward()
- else
- printf("%s Sem combustivel.", prefix)
- end
- end
- minerar()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement