I'm trying to write my own mining program, and I want the turtle to return to the surface if the fuel level falls below a certain level. How would I have it check the fuel level in a loop, and then affect an if/then statement?
6 replies to this topic
#1
Posted 12 November 2012 - 11:36 AM
#2
Posted 12 November 2012 - 11:42 AM
local minFuelAmount = 200 while true do if turtle.getFuelLevel() < minFuelAmount then break end --do stuff when fuel is not below 200 end --do stuff when fuel is below 200
#3
Posted 12 November 2012 - 12:25 PM
Anonomit, on 12 November 2012 - 11:42 AM, said:
local minFuelAmount = 200 while true do if turtle.getFuelLevel() < minFuelAmount then break end --do stuff when fuel is not below 200 end --do stuff when fuel is below 200
local minimumFuel = 200
while true do
while turtle.getFuelLevel() < minimumFuel do
turtle.refuel()
end
-- your digging code
end
#4
Posted 29 March 2013 - 08:34 PM
In theory, would this work?
The goal is to get it to go around in a square, refuelling when it needs it.
local mf=5 for i = 1, 800 do turtle.forward() turtle.turnRight() if turtle.getFuelLevel() < mf then turtle.refuel(1) end end
The goal is to get it to go around in a square, refuelling when it needs it.
#5
Posted 09 April 2013 - 02:04 AM
Cheesety210, on 29 March 2013 - 08:34 PM, said:
In theory, would this work?
The goal is to get it to go around in a square, refuelling when it needs it.
local mf=5 for i = 1, 800 do turtle.forward() turtle.turnRight() if turtle.getFuelLevel() < mf then turtle.refuel(1) end end
The goal is to get it to go around in a square, refuelling when it needs it.
Funny program - but should work
#6
Posted 09 April 2013 - 02:12 AM
latemail, on 09 April 2013 - 02:04 AM, said:
Cheesety210, on 29 March 2013 - 08:34 PM, said:
In theory, would this work?
The goal is to get it to go around in a square, refuelling when it needs it.
local mf=5 for i = 1, 800 do turtle.forward() turtle.turnRight() if turtle.getFuelLevel() < mf then turtle.refuel(1) end end
The goal is to get it to go around in a square, refuelling when it needs it.
Funny program - but should work
#7
Posted 09 April 2013 - 04:04 AM
Whilst mining, a turtle will no doubt encounter coal.
What I usually do is put coal into a specific slot of the turtle, and then when the fuel gets below a threshold "Min Fuel Reserve Level", it scans the turtle's inventory for coal and refuels (1 unit at a time) until we hit a "Full Tank Level".
If it finds no fuel in the inventory, it'll go home.
What I usually do is put coal into a specific slot of the turtle, and then when the fuel gets below a threshold "Min Fuel Reserve Level", it scans the turtle's inventory for coal and refuels (1 unit at a time) until we hit a "Full Tank Level".
If it finds no fuel in the inventory, it'll go home.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











