71 posts
Location
Nerdfightaria Island
Posted 23 January 2013 - 09:18 AM
So I was wondering, is there a way to find out the number of movements that a turtle took, and then have the turtle refuel appropriately?
To maybe clarify a bit, Is it possible for it to check the number of movements it made (not turns and checks the the like) and if the total number of movements were under a set amount, it would refuel. Now that I think about this more, I guess you would have to have some way to have the number of movements left not, movements made. So, is this at all possible?
88 posts
Location
UK
Posted 23 January 2013 - 09:22 AM
Why do you care about the number of movements made? Can't you just compare the fuel level before and after?
48 posts
Location
Colorado, USA
Posted 23 January 2013 - 09:24 AM
Yea it's possible. if you know how many moves it's going to make (Or write in a function to do the math for you) and how many moves each piece of fuel will give you, then you could just tell it to select it's fuel slot and refuel x times.
An alternative is doing something like this.
function refuel()
if turtle.getFuelLevel() < x then
turtle.select(1)
turtle.refuel(1)
end
end
just change the "x" to the fuel level you want it to refuel at and tell it which slot to select/how many time to refuel. Put that function into your movement loop and it won't use more fuel than it needs.
71 posts
Location
Nerdfightaria Island
Posted 23 January 2013 - 09:26 AM
Why do you care about the number of movements made? Can't you just compare the fuel level before and after?
Well, that just shows how much of a n00b at ComputerCraft I am. I really did not know you could do that.
Yea it's possible. if you know how many moves it's going to make (Or write in a function to do the math for you) and how many moves each piece of fuel will give you, then you could just tell it to select it's fuel slot and refuel x times.
An alternative is doing something like this.
function refuel()
if turtle.getFuelLevel() < x then
turtle.select(1)
turtle.refuel(1)
end
end
just change the "x" to the fuel level you want it to refuel at and tell it which slot to select/how many time to refuel. Put that function into your movement loop and it won't use more fuel than it needs.
I have been doing that, I just wanted a way to do it without having to figure that out every time
88 posts
Location
UK
Posted 23 January 2013 - 09:36 AM
http://computercraft...le.getFuelLevel, to which I am
incidentally awarding the prize for "least consistent function page".
2005 posts
Posted 23 January 2013 - 05:05 PM
Huh? What's so inconsistent about it? I mean, the essential output of the function itself changes depending on whether fuel is enabled or not, so there's that, but that's the function itself, not the page.