Smarter Turtles: A Teaser

Bane83

New Member
Jul 29, 2019
17
0
0
Hey guys! Just wanted to show off something I recently started working on around making turtles a little bit smarter.

Essentially what I'm trying to do is make turtles a little more fail proof as well as make things easier.


  1. There are situations where a mob (or player or animal or whatever) might walk into the path of your turtle and most people don't check for failure on forward, up, back, or down. My updated turtle API will automatically retry if the turtle fails to move. If a max # of retries is hit, the turtle will pause the script and wait for you to tell it to resume... it will then continue where it left off as if nothing happened.
  2. The ability to pass a number into your movement options (up/down/back/forward) in order to move a certain # of blocks without having to write your own loop.
  3. The ability to pass a function in to your movement commands in order to perform an extra set of code for each step your turtle makes (ex: turtle.forward(10, functionThatPlantsASeedAtEveryStepGoesHere))
  4. Falling blocks (sand, gravel) can often interfere with a turtle's script (again, if you don't account for it). The updated turtle API that I'm building will always check for falling blocks when digging in an attempt to avoid unexpected behaviour.
  5. New movement options:
    • turtle.right(num, reorientOnEachStep, functionPerStep)
      • Move to the right a certain number of blocks without having to call turtle.turnRight() followed by several turtle.forward()s
      • reorientOnEachStep (true/false) will make the turtle turn left after each step in case your function requires the turtle to be facing the original direction (ex: putting a bunch of signs up on walls, maybe?)
    • turtle.left(num, reorientOnEachStep, functionPerStep)
      • Same as turtle.right... but to go left
    • turtle.rectangle(path, width, length, functionPerStep)
      • The turtle will follow a predefined (or maybe even custom) rectangular path (such as backAndForthRows, shrinkingPerimeter, or onlyPerimeter)
      • The rectangle that the turtle follows this path within will be sized to the width and length provided
      • As with other movement functions, the turtle will perform a function at each step
      • Use this to fill in an area with blocks or dig blocks out, etc
      • Never have to write custom code to move your turtle in a rectangular pattern again!
    • turtle.box(path, width, length, height, functionPerStep)
      • As with turtle.rectangle, but add height!
      • Allows the turtle to perform a series of functions within a predefined box area! (ex: build a boxtacular house!)
      • Never have to write custom code to move your turtle in a box pattern again!
  6. Automatic refueling
    • I hope (but am not promising) to also have the turtle be able to remember any charge stations it might come across. This would be handy if you have a turtle performing some task within a predefined area... no need to check if the turtle runs out of fuel... it will take care of itself.
  7. Internal GPS (no promises on this one)
    • After an initial calibration (each time you put down the turtle) - either manual or through an existing GPS - the turtle will track its own location
I believe that's the majority of what I had thought to include.


Unfortunately, I'm not sure that anything can be done to handle chunk unloads... the turtle's simply not aware of chunk unloads. VikeStep had a good idea about saving turtle state and resuming on startup, but after further investigation I just don't think this is feasible (at least not with my limited knowledge of Lua). It looks as if the Lua debug library would be helpful here, but the developers of CC have purposefully omitted this from ComputerCraft as it is extremely dangerous.

An important note is that this will be a startup script (or a script you can call from an existing startup script, if you have one) which will overwrite the existing turtle API meaning everything will be accessible directly off of the turtle API without having to include anything special in your programs. Any existing code will automatically be updated to use the new API as well. Not to fear, though, as everything I've created so far is backwards compatible. If there's anything I can't make backwards compatible, it will get a name that does not clash with the turtle API.

Thoughts?
 

jumpfight5

New Member
Jul 29, 2019
1,750
0
1
Just a suggestion, we can't all watch videos (laptop may be sucky, may be in public w/o headphones, phone's data/signal may be crap), so do you think you could post your video description and make your own summary?
It does seem very cool, by smarter do you mean not messing up in unloaded chunks? (Couldn't watch the video :p)

And...does your voice sound like Bane? :D
 

Bane83

New Member
Jul 29, 2019
17
0
0
Just for you, I've updated the OP with more information. :)

And yes... I sound exactly like Bane.. ie: myself. But nothing like the Bane from Batman whom I have absolutely no affiliation with. :p
 
  • Like
Reactions: jumpfight5

VikeStep

New Member
Jul 29, 2019
1,117
0
0
I was going to create an API that handled chunk unloads. It is implemented in the program in my sig. I just save the data to a file and load it up on restart. The problem is how many programs will need to use it differently and it is hard to make it save something specific. I was just gonna make the API save selected variables.
 

jumpfight5

New Member
Jul 29, 2019
1,750
0
1
Just for you, I've updated the OP with more information. :)

And yes... I sound exactly like Bane.. ie: myself. But nothing like the Bane from Batman whom I have absolutely no affiliation with. :p
Okay, that sounds pretty cool. I like the re-orientation (signs and stuff). If you can make this so easy you can just toss it into a code at the beginning and add whatever stuff you want at the top, I may have to try it out! Now I have to watch this video...tomorrow...hopefully :p

And I'm not sure, but the GPS (if you choose to include it) could handle chunk unloads, kinda. Along with the re-orientation, you could tell it to re-orient itself and it would continue along with a resume program or something. But I don't turtle, learning Lua past the basics is more time consuming than I thought it would be. And I can't log into Minecraft, haven't been able to for months (why am I still on these forums? I don't know!), so that's out of the question.

That re-orient thing seems to be able to help me with a code I've always wanted to make. I want to make a turtle tear down a house with check inventory and stuff, and re-build it exactly, and while supplied with materials, an infinite amount of houses stored in the memory of the code (which is probably the only reason this code may not exist sometime in the far off future). But stairs and signs pose a problem, and this would obviously help me if I am ever able to make it...
 

Bane83

New Member
Jul 29, 2019
17
0
0
If you can make this so easy you can just toss it into a code at the beginning and add whatever stuff you want at the top, I may have to try it out!
One important thing I forgot to mention. No need to throw this into your own program. This will be a startup program (or something you can call from an existing startup program if you already have one) and it will overwrite the existing turtle API. But that's fine, as my updates (so far) are backwards compatible. Anything that I can't make backwards compatible (or someone proves is not backwards compatible) I will give a special name so that it doesn't interfere with the regular API... but still, you'll be able to call anything with turtle.whatever and not have to include anything extra in your own programs.
 

jumpfight5

New Member
Jul 29, 2019
1,750
0
1
One important thing I forgot to mention. No need to throw this into your own program. This will be a startup program (or something you can call from an existing startup program if you already have one) and it will overwrite the existing turtle API. But that's fine, as my updates (so far) are backwards compatible. Anything that I can't make backwards compatible (or someone proves is not backwards compatible) I will give a special name so that it doesn't interfere with the regular API... but still, you'll be able to call anything with turtle.whatever and not have to include anything extra in your own programs.
That makes it sound a lot easier.
 

KhrFreak

New Member
Jul 29, 2019
689
0
0
I'll probably not going to ever use it because im not a huge turtle person but if your api can do what you claim it can do it sounds great :D good luck
 

kallekulle

New Member
Jul 29, 2019
77
0
0
oh man, if you could get this implemented into ftb ultimate, I'd never be more satisfied.. when it comes to turtles that is :3
 

jumpfight5

New Member
Jul 29, 2019
1,750
0
1
If it's good enough, it could actually happen.
Now, I don't have a say, and the amount of credit you get would probably be low, since you didn't make CC.

But adding programs into the game for new players in addition to the few we get would be amazing!