This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
user7755's profile picture

Turtle Pump Placing

Started by user7755, 16 April 2014 - 07:21 PM
user7755 #1
Posted 16 April 2014 - 09:21 PM
Hi everyone,

so I, as a Computercraft noob, am having trouble writing a Turtle Program and I wonder if any of you guys could help me with that. So what I want the Turtle to do is: If it receives a
Redstone Signal, I want it to dig out of the wall, move to the center of the room, place a pump a tesseract and a endertank, wait some time, break the whole contraption, get back in the wall and wait for another signal.

Thanks in advance

-user7755
Cranium #2
Posted 16 April 2014 - 09:40 PM
Welcome to the forums.
While we'd like to help you, more people would be interested in helping you if you posted some code on your own. Generally, we won't write a program for you, we'd prefer to teach you how.
For detecting redstone signals, try reading about the Redstone API on our wiki.
Also, while you're at it, chek out the Turtle API as well.
Shrooblord #3
Posted 17 April 2014 - 06:40 PM
Welcome to the forums.
While we'd like to help you, more people would be interested in helping you if you posted some code on your own. Generally, we won't write a program for you, we'd prefer to teach you how.
For detecting redstone signals, try reading about the Redstone API on our wiki.
Also, while you're at it, chek out the Turtle API as well.
I'd like to add to this by helping you on your way, user7755, but I won't write the entire thing for you (solving that puzzle is the entire point and fun of programming - also in ComputerCraft).

There's a few functions in the Redstone API that will get you started. The one you're interested in is rs.getInput(side). This will determine whether or not a Turtle detects a Redstone signal. For example, rs.getInput("left") will return true if there is Redstone active to the Turtle's left.

1. Now, start writing a program by writing 'edit YOURPROGRAMNAME' in the turtle.

2. Look up what a 'while' loop is on Google and see if you can figure out how to make your Turtle wait until he receives a Redstone signal.

3. You'll have to find out how a Turtle can determine how large the room is, but this depends on your own choice: do you have a specific room in mind and will the Turtle only ever operate in that one room? If so, the issue is easy - you tell the Turtle exactly how large the room is and/or how many steps forwards he will have to make (look at how Turtles move using turtle.forward() by looking it up on the Wiki) to get to its centre. Or: do you want the program to be flexible, to have the Turtle be able to go into any-sized room and perform this task? If so, you'll have to think of a way for the Turtle to count how many steps he takes as he reaches the far wall of a room, then move half that many steps backwards to determine where the centre of the room is. Maybe you'll want to make him save that number so he doesn't have to do this every time he goes to work.

4. Look up turtle.placeDown() and turtle.digDown() for the rest of your program.

5. Have the turtle move back into his little hole (if you've come this far, you should know how to do this by now).


There - I've given you a good basis to work with for writing your program. Now get out there and code it yourself - the best way to learn is by experimentation!

PS
Of course we'll help you once you write some of the program and run into problems - just post your code here and we'll see how we can assist you!
Edited on 17 April 2014 - 04:41 PM