Jump to content




Turtles and there Fuel


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

#1 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 27 November 2012 - 10:13 AM

I haven't really made turtle programs but a friend of mine asked me to make one that cuts down huge trees without any effort.

Is there a way to make the program check for available fuel sources in any slot and then ask the user if he want's to use it and if not it will go to the next one, etc.

#2 OmegaVest

  • Members
  • 436 posts

Posted 27 November 2012 - 10:20 AM

There's no way to automatically detect if a specific block or item can be used as fuel without using it first. On the other hand, you could just ask the user which slot it wants to use as a fuel slot, and then only have it drain down to one so it will not put anything else in that spot.

#3 Goof

  • Members
  • 751 posts

Posted 27 November 2012 - 10:27 AM

Deleted...


I'm sorry.. i dont think i was helpful with my example
D:

_____________________

-Mikk809h

ComputerCraft is awesome

#4 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 27 November 2012 - 10:48 AM

View PostOmegaVest, on 27 November 2012 - 10:20 AM, said:

There's no way to automatically detect if a specific block or item can be used as fuel without using it first.

Oh my word, I didn't even think about that.
So I would make it go through each slot and check if turtle.refuel() returns true. Thanks

Edit: Doing an if statement like this:
if turtle.refuel() then print("Fuel!") else print("Failed") end

I wanted it to just print 'worked' if it can but instead it printed worked and refueled itself. How can I make it just print 'fuel!' when it find's available fuel

#5 OmegaVest

  • Members
  • 436 posts

Posted 27 November 2012 - 10:55 AM

Again, it can only know if a fuel works once it works. If you don't want it to use up the fuel, it will never know if it does work. Unless you are using Aperture Science Turtles.


So there is no way to automatically tell if an item is fuel. It will only ever use up fuel if it can. It's like a car: you can put water in the tank all you want, but it won't run because it can't catalyze it. Same idea.

#6 KaoS

    Diabolical Coder

  • Members
  • 1,510 posts
  • LocationThat dark shadow under your bed...

Posted 27 November 2012 - 11:14 AM

turtle.refuel(0) returns true if it is a fuel type without using any....

#7 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 27 November 2012 - 11:55 AM

View PostKaoS, on 27 November 2012 - 11:14 AM, said:

turtle.refuel(0) returns true if it is a fuel type without using any....
Wait....you can define how much fuel it is to use?

#8 Kingdaro

    The Doctor

  • Members
  • 1,636 posts
  • Location'MURICA

Posted 27 November 2012 - 12:07 PM

View PostCranium, on 27 November 2012 - 11:55 AM, said:

View PostKaoS, on 27 November 2012 - 11:14 AM, said:

turtle.refuel(0) returns true if it is a fuel type without using any....
Wait....you can define how much fuel it is to use?
Yeah, but I didn't really think about using the number 0 either. That's pretty clever, KaoS :P

#9 KaoS

    Diabolical Coder

  • Members
  • 1,510 posts
  • LocationThat dark shadow under your bed...

Posted 27 November 2012 - 12:46 PM

View PostKingdaro, on 27 November 2012 - 12:07 PM, said:

View PostCranium, on 27 November 2012 - 11:55 AM, said:

View PostKaoS, on 27 November 2012 - 11:14 AM, said:

turtle.refuel(0) returns true if it is a fuel type without using any....
Wait....you can define how much fuel it is to use?
Yeah, but I didn't really think about using the number 0 either. That's pretty clever, KaoS :P

haha. I can take absolutely no credit for this innovation as it was actually noted on the documentation but thanks for the compliment :)

the defining the amount of fuel used is actually incredibly useful, on my turtles I like to run my networking coroutine as well as a fuelling coroutine in parallel with the shell. the fuel coroutinr keeps the fuel at a certain level (you can actually just make sure you always have JUST enough fuel for the next action to use fuel as it is needed). of course be careful when doing this... if you did it with a crafting turtle you may find your wood vanishing as you try to make planks etc... make a toggle switch or suffer





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users