Jump to content




Is it possible to refuel this way?

turtle help

  • You cannot reply to this topic
5 replies to this topic

#1 The_Awe35

  • Members
  • 71 posts
  • LocationNerdfightaria 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?

#2 Eric

  • Members
  • 92 posts
  • LocationUK

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?

#3 Willibilly19

  • Members
  • 48 posts
  • LocationColorado, 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.

#4 The_Awe35

  • Members
  • 71 posts
  • LocationNerdfightaria Island

Posted 23 January 2013 - 09:26 AM

View PostEric, on 23 January 2013 - 09:22 AM, said:

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.

View PostWillibilly19, on 23 January 2013 - 09:24 AM, said:

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

#5 Eric

  • Members
  • 92 posts
  • LocationUK

Posted 23 January 2013 - 09:36 AM

http://computercraft...le.getFuelLevel, to which I am incidentally awarding the prize for "least consistent function page".

#6 ChunLing

  • Members
  • 2,027 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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users