How to make a turtle command loop?

  • 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

Peppe

New Member
Jul 29, 2019
836
0
1
Is there any way to make the turtle come back once its out of fuel? :p
Turtles need fuel to move, so no.

You might try to estimate the fuel needed to run your program and not allow it to run unless the turtle has enough fuel. If it gets low during a program you can abort the program and code it to return home / to a fueling station and then resume its program when it has fuel. That is gets a little complex, so a simple fuel level check before running and manually feeding them fuel is probably enough.
 

YooKahZee

New Member
Jul 29, 2019
80
0
0
while true do
turtle.dig()
turtle.digUp()
turtle.digDown()
turtle.forward()
sleep(0.1)
end

I have this, where do I slot it in, and is it possible to make it place torches? :p Thanks for all the help, really appreciate it :D
 

Lambert2191

New Member
Jul 29, 2019
3,265
0
0
you mean return to starting position? No, unless like Peppe said, you estimate the amount of fuel.

maybe even have it get fuelLevel, then say if that is 1000, let it run 500 times
 

YooKahZee

New Member
Jul 29, 2019
80
0
0
How about when the turtle is full of items, it returns home.

Could you edit my script to do that please? Thanks Lambert :)
 

Peppe

New Member
Jul 29, 2019
836
0
1
Programs with some brains to them get complicated quickly.

For some ideas on how to solve common problems try looking at the excavate program that comes with the turtle.

excavate tracks it's position from its start point. -- if you want the turtle to return to its start point when it has issues then you need to track where that was and how far you have moved from it.
excavate makes an estimate on the fuel needed to run the program.
excavate checks it's fuel and inventory levels.
I think it auto refuels off its inventory if it is low on fuel
When low on inventory space or fuel it returns to the start position - unloads inventory and will wait at the start for the player to add fuel if it does not think it has enough fuel to finish its job.
 

zemerick

New Member
Jul 29, 2019
667
0
1
The best solution would be to give it 2 ender chests. 1 that would contain fuel, the other drop off to your sorting.

Then, when the turtle runs out of fuel, it drops the ender chest for fuel, pulls a stack out and refuels. It then picks the chest up, and continues.

Same with when it is full. Drop the appropriate chest, empty items into it, and pick the chest back up.

PS: http://computercraft.info/wiki/Main_Page

Bookmark it:)
 

jumpfight5

New Member
Jul 29, 2019
1,750
0
1
Or use one with a manager. It'll pull out everything and leave x stacks of your desired fuel. Useful for an extra inventory space.
 
  • Like
Reactions: Lambert2191

DaDubstep

New Member
Jul 29, 2019
2
0
0
How about when the turtle is full of items, it returns home.

Could you edit my script to do that please? Thanks Lambert :)
Send me the script and what your specific instructions and I can give it back. I took courses so I can help you.