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

A program to fill an area from the outside to the inside?

Started by Lilcrash, 04 June 2015 - 01:54 PM
Lilcrash #1
Posted 04 June 2015 - 03:54 PM
Hello,

my Turtle is supposed to fill a circular area with cobblestone. I want it to go along the wall and place blocks, so it's gotta go kinda like a spiral. I'm very new to turtle programming so I didn't know what to look for.

Thanks in advance!

PS: Please point me in a direction if I'm wrong here.
Cranium #2
Posted 04 June 2015 - 04:13 PM
You can use a "maze-navigating" method, where the turtle constantly hugs one side or another while it is building.
Lilcrash #3
Posted 04 June 2015 - 04:28 PM
And how do I do that? Sorry I'm really new, so far I only dug tunnels with the turtle.
Bomb Bloke #4
Posted 05 June 2015 - 03:48 AM
Exactly what sort of shape are you talking about? Do you have a simple circle you need to fill in? Or is it a cylinder? Perhaps even a sphere? Do you need the turtle to be able to do the job multiple times? If so, does the circle radius vary?

More details, and of course any code you've tried to write thus far, would be useful.
Lilcrash #5
Posted 05 June 2015 - 03:05 PM
Ok, so here's the situation:
http://i.imgur.com/dpxIW9B.jpg
I need to fill only one layer of this with cobblestone, so it's just a 1 block high fill. (Ignore the water.) The problem is that I have already placed some cobblestone there, so it's a very irregular shape now, which is why I want it to hug the wall and place blocks, because the border of the shape is already there.

The turtle only needs to do this job once.

http://imgur.com/P4pgu3q This is what I've tried so far. I think the problem lies in the turtle.back() == false because I didn't know if that is a thing or not.
malleusmintaka #6
Posted 05 June 2015 - 09:49 PM
Well, you could hardwrite the whole thing, so lets say you start in the bottom left and write while l<length do {}end turn right while l2<length2 … would be stupid though.

You could try to do this with a var, lets say

var = turtle.back()
if var == false then
CODE
end


Actually, if you need this only once, then i would recommend you to try something else, i dont know if you have any other mods, but even with just cc, you should be faster with your hands
Bomb Bloke #7
Posted 06 June 2015 - 05:10 AM
You want to fill that in with cobble? On top of, or even between, that lovely glass you've got there? Urgh.

Note that when you do:

if turtle.back() == false then

… you're saying:

Attempt to go backwards, and if that attempt fails, then

It doesn't just check to see if the turtle can go back - it actually goes back, if it can.

Better logic would be:

while true do
  while not turtle.back() do  -- "not turtle.back()" resolves the same as "turtle.back() == false"
    turtle.turnRight()
  end
  turtle.place()
  turtle.turnLeft()
end

Something more efficient could be made by having the turtle hover above the area, using turtle.inspect() to determine when to turn based on when it hovers over whatever that edging material is.
Lilcrash #8
Posted 06 June 2015 - 09:05 AM
You want to fill that in with cobble? On top of, or even between, that lovely glass you've got there? Urgh.

Hah, don't worry I just need to construct something under there, so I only need the cobble momentarily. Thanks for your info though, I will try it out and report back!