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

I don't know why this doesn't work?

Started by aileron565, 31 August 2012 - 09:43 PM
aileron565 #1
Posted 31 August 2012 - 11:43 PM
This is for a 13x15 tree farm.
Can someone please help me?
I am new to this.
Thx.


turtle.select(1)
up8()
layer()
layer()
layer()
layer()
layer()
layer()
layer()
layer()
function up8()
turtle.up()
turtle.up()
turtle.up()
turtle.up()
turtle.up()
turtle.up()
turtle.up()
end
function forward13()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
end
function layer()
row()
right()
row()
left()
row()
right()
row()
left()
row()
right()
row()
left()
row()
right()
row()
left()
row()
right()
row()
left()
row()
right()
row()
left()
row()
turtle.turnright()
forward13()
turtle.turnright()
forward13()
turtle.forward()
turtle.forward()
turtle.turnright()
turtle.turnright()
turtle.down()
end
function row()
digg()
digg()
digg()
digg()
digg()
digg()
digg()
digg()
digg()
digg()
digg()
digg()
digg()
digg()
digg()
end
function right()
turtle.turnright()
turtle.forward()
turtle.turnright()
end
function left()
turtle.turnleft()
turtle.forward()
turtle.turnleft()
end
function.digg()
turtle.dig()
turtle.forward()
end
Lyqyd #2
Posted 01 September 2012 - 01:41 AM
This belongs in the Ask a Pro section.
Xhisor #3
Posted 01 September 2012 - 11:01 PM
This is for a 13x15 tree farm.
Can someone please help me?
I am new to this.
Thx.
Spoiler

turtle.select(1)
up8()
layer()
layer()
layer()
layer()
layer()
layer()
layer()
layer()
function up8()
turtle.up()
turtle.up()
turtle.up()
turtle.up()
turtle.up()
turtle.up()
turtle.up()
end
function forward13()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
end
function layer()
row()
right()
row()
left()
row()
right()
row()
left()
row()
right()
row()
left()
row()
right()
row()
left()
row()
right()
row()
left()
row()
right()
row()
left()
row()
turtle.turnright()
forward13()
turtle.turnright()
forward13()
turtle.forward()
turtle.forward()
turtle.turnright()
turtle.turnright()
turtle.down()
end
function row()
digg()
digg()
digg()
digg()
digg()
digg()
digg()
digg()
digg()
digg()
digg()
digg()
digg()
digg()
digg()
end
function right()
turtle.turnright()
turtle.forward()
turtle.turnright()
end
function left()
turtle.turnleft()
turtle.forward()
turtle.turnleft()
end
function.digg()
turtle.dig()
turtle.forward()
end
LUA is case sensitive.
ficolas #4
Posted 06 October 2012 - 11:05 PM
Yo need to put the fuctions at the start to inicialice em
slango20 #5
Posted 12 October 2012 - 12:01 PM
You need to actually call the functions in something other than another function, if I'm reading the code right, it only declares the functions, it doesn't use them
robhol #6
Posted 12 October 2012 - 12:07 PM
Copypasting lines 50 times when you can just use for i=1,50 do whatever(); end is so extremely pointless. Read a tutorial.
ChunLing #7
Posted 12 October 2012 - 04:04 PM

function up8() for i=1,7 do turtle.up() end end
function forward13() for i=1,13 do turtle.forward() end end
function.digg() turtle.dig() turtle.forward() end
function row() for i = 1, 15 digg() end end
function right()
turtle.turnright()
turtle.forward()
turtle.turnright()
end
function left()
turtle.turnleft()
turtle.forward()
turtle.turnleft()
end
function layer()
for i=1,6 do row() right() row() left() row() end
for i=1,2 do turtle.turnright() forward13() end
turtle.forward()
turtle.forward()
turtle.turnright()
turtle.turnright()
turtle.down()
end
-- all functions defined, now you can use them
turtle.select(1)
up8()
for i=1,8 do layer() end
Note that I have no idea what this is supposed to do, but what it actually does is go up 8 times (if there is nothing in the way, which there probably will be if you're growing trees nearby), then attempt to chop down things, one layer at a time. Since there is position adjustment at the end of each row that doesn't check for obstacles (which are quite likely, if this is in a tree farm) and the down command at the end of a layer also lacks any way to deal with leaves in the way, I'm guessing that the turtle will go up two or three, run into a leaf block overhead, then chew through the farm for 15 blocks, then probably not be able to move over a row because of leaves, thus come back the way it came and go back and forth like that a bunch, then try to go down. When the turtle has gotten low enough that it isn't running into leaves anymore, it will start cutting a full 15 x 13 layer out of the trunks. But there is an even chance that it will cut the remaining two layers in the direction away from where you intended. At least it will stop once it hits the ground.