Help with Coding turtles

  • 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

Adonis0

New Member
Jul 29, 2019
1,800
0
0
With my server restarting soon, I was thinking I'd have another crack at trying to code turtles. The problem I had last time I tried was they kept on going rogue and running away.

I was using gps in my programs, but my question is how do you get the turtle to figure out what direction it's facing upon start-up?

Is there a way to code where it pulls what direction it's facing, or where it figures it out?
 
But that doesn't answer my question, I'm not after programs, I'm trying to code my own
I've searched around for an answer to the cardinal directions problem, and so far haven't found any

EDIT: this is so my programs are server crash-proof. Because the server I play on isn't up 24/7 and that screws up most programs that you find on paste-bin and whatnot if they're halted half-way through
 
But that doesn't answer my question, I'm not after programs, I'm trying to code my own
I've searched around for an answer to the cardinal directions problem, and so far haven't found any

EDIT: this is so my programs are server crash-proof. Because the server I play on isn't up 24/7 and that screws up most programs that you find on paste-bin and whatnot if they're halted half-way through
Ummm most programs don't do well with rebooting half-way through program. I suggest asking around the forums and/or using, "Startup" on the program. I ain't not good at computer craft codin'. I would help if i had da skittles.
 
Ummm most programs don't do well with rebooting half-way through program. I suggest asking around the forums and/or using, "Startup" on the program. I ain't not good at computer craft codin'. I would help if i had da skittles.
mm..

I think i have a way for the turtle to figure out how far through the program it is if I could figure out how to tell the turtle which way it was facing. Because then it's able to figure out where it is and how to get home for example at a worst case scenario. Or where it is, and where it should be, and continue the program from there in terms of a mining turtle.
 
mm..

I think i have a way for the turtle to figure out how far through the program it is if I could figure out how to tell the turtle which way it was facing. Because then it's able to figure out where it is and how to get home for example at a worst case scenario. Or where it is, and where it should be, and continue the program from there in terms of a mining turtle.
You should share it with the CC forums.. I don't know if some of them know.
 
I think i have a way for the turtle to figure out how far through the program it is if I could figure out how to tell the turtle which way it was facing. Because then it's able to figure out where it is and how to get home for example at a worst case scenario. Or where it is, and where it should be, and continue the program from there in terms of a mining turtle.

The only way I know of to figure out which way it's facing is to do a gps.locate() to get its current coordinates, then move it one block forward and do gps.locate() again. Compare the two coordinates, figure out which one changed and whether it went up or down, and then you'll know which way the Turtle is facing.

You'd have to include a case for there being an obstruction in front of the turtle, but you could then just have it turn and try again until it can move.
 
you can save the direction to a file (once you know the direction) and read the file when the turtle restarts. The problem would be that the direction would need to be updated to the file every time it changes.

if you dont know how to save a file have a look at this page
 
you can save the direction to a file (once you know the direction) and read the file when the turtle restarts. The problem would be that the direction would need to be updated to the file every time it changes.

if you dont know how to save a file have a look at this page
How did you make your sig? :3
 
you can save the direction to a file (once you know the direction) and read the file when the turtle restarts. The problem would be that the direction would need to be updated to the file every time it changes.

if you dont know how to save a file have a look at this page

I was doing that when they went rogue, but this ended up with the occasional one having a server crash inbetween it changing direction and saving the direction.

This meant that the file and it were misaligned, and then it went off thinking it was facing south, but was actually heading east. This resulted in one by one my turtles disappearing, and me figuring out why too late ;-;
 
How did you make your sig? :3
My friend made a youtube background for me and that was part of it. here is my youtube page if you want a look at it[DOUBLEPOST=1368233566][/DOUBLEPOST]
I was doing that when they went rogue, but this ended up with the occasional one having a server crash inbetween it changing direction and saving the direction.

This meant that the file and it were misaligned, and then it went off thinking it was facing south, but was actually heading east. This resulted in one by one my turtles disappearing, and me figuring out why too late ;-;
how about do the file thing plus when ever it moves check if it moved properly (like if it was facing properly then moving forward should go to this relative coordinate). then if it hasn't gone to the correct coordinate, figure out the direction it is in and go back
 
My friend made a youtube background for me and that was part of it. here is my youtube page if you want a look at it[DOUBLEPOST=1368233566][/DOUBLEPOST]
how about do the file thing plus when ever it moves check if it moved properly (like if it was facing properly then moving forward should go to this relative coordinate). then if it hasn't gone to the correct coordinate, figure out the direction it is in and go back
Bit of extra coding and whatnot, but.. I like this
Might be good for calculating where it is in a server.

Also since we're talking turtles, is there a way to make a block to not be destroyed by turtles, or code them to recognise blocks and not kill them..

Like I want to have a relay underneath the turtle starting position for depositing into pipes, and a charging station next to it so turtle comes back and refuels and deposits, but I don't want them to destroy those blocks.. is it just careful programming or can I code don't destroy charging stations?
 
Bit of extra coding and whatnot, but.. I like this
Might be good for calculating where it is in a server.

Also since we're talking turtles, is there a way to make a block to not be destroyed by turtles, or code them to recognise blocks and not kill them..

Like I want to have a relay underneath the turtle starting position for depositing into pipes, and a charging station next to it so turtle comes back and refuels and deposits, but I don't want them to destroy those blocks.. is it just careful programming or can I code don't destroy charging stations?
you can recognise blocks with turtle.detect() note this does not detect mobs
turtle.compare() will compare whether the block in front is the same as the item in the selected slot. you could keep a charging station in the inventory at all times and just check that way
 
you can recognise blocks with turtle.detect() note this does not detect mobs
turtle.compare() will compare whether the block in front is the same as the item in the selected slot. you could keep a charging station in the inventory at all times and just check that way
mmk, I was hoping to be able to hard-code it some way, like turtle.detect(chargingstation) or something like that, but anyhow
I shall start experimenting with actually making a set-up now ^^

Thanks for the help guys.