How to make a turtle return when it is out of fuel?

  • Please make sure you are posting in the correct place. Server ads go here and modpack bugs go here
  • The FTB Forum is now read-only, and is here as an archive. To participate in our community discussions, please join our Discord! https://ftb.team/discord

tehBlobLord

New Member
Jul 29, 2019
547
0
0
If they are out of fuel then they can't return..
Of course you could detect if they have about 10 fuel left and place a turtle teleporter or something (correct me if i'm wrong) but otherwise you'd have to make sure it is well fuelled which isn't too hard.
OFC I'm a total noob at CC so I can't help too much.
 

Lambert2191

New Member
Jul 29, 2019
3,265
0
0
If they are out of fuel then they can't return..
Of course you could detect if they have about 10 fuel left and place a turtle teleporter or something (correct me if i'm wrong) but otherwise you'd have to make sure it is well fuelled which isn't too hard.
OFC I'm a total noob at CC so I can't help too much.
that wouldn't work, if a turtle was to teleport 10 blocks, it costs 20 fuel.
 

YooKahZee

New Member
Jul 29, 2019
80
0
0
if thats our attitude about search how are you expected to understand answers to this question? Willful ignorance and laziness are not virtues required for computercraft or coding.
I mean I searched but the search results weren't showing what I wanted and they were too complicated so I thought If I asked here someone would give me less complicated stuff XD I was also really tired yesterday when I was posting this stuff :p
 

Lawbroken

New Member
Jul 29, 2019
1,336
0
0
What are you trying to do anyway?

Some of the things you may want to do with turtles have already been written in lua and posted on the Computercraft forums anyway.
 

Guswut

New Member
Jul 29, 2019
2,152
0
0
less complicated stuff


Sure.

To get your turtle to return to a specific place when it runs out of fuel, you need to first rethink that concept: You need the turtle to return somewhere to refuel BEFORE it has run out of fuel.

With that rethought, what you want is a way for the turtle to return to a specific place, to refuel, before it has run out of fuel. That means you need to do the following things:

First, you need to know where that spot is.
Second, you need to know where the turtle is, currently.
And finally, you need to know how to get back to the first point from the second point.

The easiest way to do this is the record the starting point in variables saved to a file on the turtle. For example, if you put your turtle down at 152x 23y -339z, your turtle would record its current position as 0,0,0.

Then update the file with the turtle's current position. For example, if your turtle had moved to 151x 23y -339z, the turtle would have recorded it as -1,0,0 to denote it has moved negative one block in the x direction.

From there, you recall the turtle by having it go the direction needed to make the current position 0,0,0 again.

This is likely as simple as you're going to get a description for turtle recall. It does not deal with the possibility of retracing steps in case of a non-simple return path, nor do I even start to mention calculating current fuel level versus cost of return because you need to work out this step, first.