r/ComputerCraft • • Jun 13 '21

Less Stupid: Turtle Programs

Hello Everyone,

After avoiding coding in minecraft for a long time, i got curious about the turtles, since i lacked another way to Quarry.

I have now created scripts:

  • pastebin get z9WbNS89 Miner

  • pastebin get ViyCvtJ1 Planer

  • pastebin get xn7XEVrU Refuel

  • pastebin get wKfL4vr1 Module

  • pastebin get PAR9xAc5 Chop

As you can probably tell, this led to an appreciation for this mod and all the possibilities.

Feel free to ask questions and modify the code.

i will update the Pastebin, whenever i have a new stable version for release.

Currently the code isn't exactly optimized, but it is definitely acceptable for my needs.

(and in my biased opinion, more practical than a lot of other turtle scripts)

Less Stupid: Mining Turtle

My take on a semi intelligent mining turtle.

This Miner will leave minimal change in landscape, as it attempts to only mine valuable resources.(There is a easy to edit "Blacklist" for unwanted materials)

I like to let 2 run at the same time, then when they mine away, i check tunnels previously made and get anything they missed. (The script isn't perfect but it takes out 90% of the work)

Less Stupid: Refueler

Uses all consumable fuel in it's inventory to refuel.

Less Stupid: Planer

Removes all blocks within and above coordinates.

If you place a stack of blocks in the inventory, it will use them to create a flat floor.

Less Stupid: Module Builder

Creates modules for the Chopper script to use. Uses items in Top row.

Less Stupid: Chopper

After trees has been planted and grown the Chopper can harvest all of the wood for you.

Use Diorite bricks instead of cobble.

NOTES:

Known issues:

  • Sand and gravel f*cks up the turtles pathing algorithm*(might fix it in a complete revisit of the miner script)*

  • The Fuel required is way off.(Just give it a lot of fuel, the turtle keeps its fuel when picked up)

  • Chopper script may or may not only accept Cobble and/or Diorite Bricks.

36 Upvotes

9 comments sorted by

6

u/Benzilla99 Jun 13 '21

If you want to fix the issue with sand and gravel, you can nest your dig command in a loop with "while turtle.detect() == true". I had the same issue and this solved it for me

9

u/Tjstretchalot Jun 13 '21

note that you have to be a bit careful because (rarely) when mining you'll break a block which causes gravel to fall more than a single block due to block updates and doing this

while turtle.detect() do turtle.dig() end
turtle.forward()

won't work because it'll break out of the loop while the gravel/sand is still falling. also you'll be vulnerable to mobs that happen to get in the way. easy technique adjustment that I think always works

while not turtle.forward() do turtle.dig() end

5

u/SadieWopen Jun 13 '21

You could also use the same technique on the planer to avoid issues like the spider.

While not turtle.placeDown() do turtle.attack() end

2

u/Chutny Jun 13 '21

Thank you, i will also note this.

2

u/Chutny Jun 13 '21

Thank you for this, will include in future updates.

3

u/Benzilla99 Jun 13 '21

Ooh yeah that's a better method. Good call

2

u/SadieWopen Jun 13 '21

If the turtle is likely to mine fuel items you can also use the following logic in a function every time it moves

Check fuel level

If it's less than whatever minimum you want like 20 or 80 (depends on the fuel)

Search for fuel items in inventory

Select 1 of them

Refuel 1

This way the turtle only consumes what it needs but always has enough fuel to move

You can also add a bucket to its inventory and detect lava to use to refuel whenever it encounters it - good in the nether.

2

u/Chutny Jun 14 '21

Thank you for the suggestion. This is definitely a good way of making sure the turtle always has enough fuel to move.

For me personally, I haven't had the turtle run out of fuel. I just fill it's inventory with charcoal, refuel and then it'll have so much fuel that I don't need to think about it for a very long time.

3

u/[deleted] Jun 14 '21

Hey I found an easy way to fix the sand and gravel problem.

Edit: I see someone else mentioned something similar, but this is my personal approach since it's more modular.

Add a custom dig function called dig() for example to replace the normal dig function.

In it, have a loop that constantly checks if there is a block in front of it, if there is, dig it, if not, end the loop. Simple.

With this you can also modify it to dig only certain blocks by getting the block's ID or something I haven't done this in a while. But I know its possible. I made it so it instantly throws away anything it that wasn't requested by the person starting the script.