r/ComputerCraft • • Sep 27 '21

Turtle idea/help needed

Playing minecraft 1.16.5 with ATM6

So I have a base that I am trying to automate with turtles, specifically I wish to automate my rubber production.

The process is as follows: Harvest Acacia tree Place wood in front of fluid extractors, IF a block is not there. Plant acacia sapling. Repeat.

If this possible with LUA coding and turtles? If so can someone help me with the coding?

8 Upvotes

7 comments sorted by

View all comments

2

u/Chaosfox_Firemaker Sep 27 '21

Yep, perfectly doable. Acacia makes it a little bit tricky, but not too bad. I will be talking in pseudo code, rather than lua, but it should still help.

Initial state, acacia sapling in front, space to put the wood bellow.

while the sappling hasnt turned into a log yet

checck if theres a log beloow you, and if there isnt, place one.

dig then, forward

repeat until stop

check the block above you.

if its a log:

dig up

go up

else:

go up

stop

check all four sides:

do the previous repeat if there is a log. until all four sides arent a log

your turtle is now up in the sky and we want to get down. We could gps our way there. Or you could keep track whenever you move the turtle. or you could have everything in functions that undo themselves, just get back to the starting position. then have it place a sapling.

getting the saplings can be a bit harder, a common solution is to have the setup in a water pit that funnels all the dropped saplings in one spot for the turtle to pick up

burn the wood for fuel while your at it

3

u/IKnowATonOfStuffAMA Sep 27 '21 edited Sep 28 '21

A recursive function would be great.

Function acacia()
   Dig up
   Go up
   If acacia log above
      acacia()
   Else
      Check all four sides around turtle, even after finding acacia logs
      If acacia log is found
         dig towards it and move forward
         acacia()
         Move backwards
   go down
End

3

u/Chaosfox_Firemaker Sep 27 '21

That's basically what I was trying to say, very badly.

1

u/IKnowATonOfStuffAMA Sep 27 '21

Thats probably the first time I've actually thought about a turtle moving recursively even though it would've been useful before, so not like I'm a genius either.