EDIT: I was going off the first post, not the 2nd post which I didn't see.
First of all, shell.run("move", x, y)
will not do what you
think it will do. Just off the top of my head, this would be similar to what you want, though there are probably more efficient ways of doing things:
local function forward(dist)
for x = 1, dist do
while not turtle.forward() do --Tries to move forward 1, if it fails, it will keep trying until it succeedes
--You may want to put turtle.dig() in here to clear out gravel (and simplify your code)
--You may want to put turtle.attack() in here to get rid of mobs in the way
os.sleep(1)
end
end
end
local function move(dir, dist)
if dir == "f" then forward(dist) end
if dir == "r" then turtle.turnRight() end
if dir == "l" then turtle.turnLeft() end
end
That's just something to get you started using the Turtle API.
Regarding your specific problem, d is undefined, and so is bit.band(), I think. Here's what I use in my zig-zag algorithms (using the forward() function above, but one that includes a turtle.dig()):
if x < width then --Do not go beyond the bounds if last row
if x % 2 == 0 then
turtle.turnLeft() --Turn left (assuming 1st row is x=1)
forward(1)
turtle.turnLeft()
else
turtle.turnRight() --Turn right
forward(1)
turtle.turnRight()
end
end
A similar pattern for z can be done since it's similar to x and you don't want to descend too far down.
Also, since the forward() function has a distance parameter, you don't need the y variable anymore. Just call forward(length - 1) with a dig line inside forward(). (The -1 is because you're starting on the 1st spot.)
Finally, a tip, in Minecraft, z refers to a horizontal dimention, not the vertical dimension. In my own programs, I treat z as "forward" in local/relative coordinate space (with x as "rightward" and y as "downward" or "upward"). Using z as a vertical unit may confuse you or others in the future. Just something to keep in mind. As variables, it won't change how your program behaves.
Your first program is off to a great start, Shawn!
Edited by Buho, 26 November 2014 - 04:29 PM.