any way. Well that code of for CC 1.63. so the options do work. like turtle.select(log) or turtle.compare(sapling). I think all this was added in CC version 1.6x.
Sorry, but you've gotten a bit confused there - let's go over this again, with a few more details:
In Lua, when you define a function, you can set it up to accept a given number of parameters (values you can pass to it that it'll use to do its job). However, when people
use that function, Lua doesn't actually "care" how many parameters they supply to it.
If they supply less then the function creator considered, then Lua assumes that all the missing parameters are "nil". Depending on how the function was coded, this may work, or the function may error out when it tries to
use those values.
If they supply
more parameters then the function creator considered, then Lua simply ignores them. They get discarded - no errors appear, they just go out the window and the script carries on.
Note "considered", as opposed to "wanted". It
is possible for a function author to make his function throw informative errors if the wrong amount of parameters are passed to it, but Lua won't do it for him, and you shouldn't expect it.
So, with this in mind:
turtle.select() expects one parameter, a number. Fail to provide it and it will error out (because you can't select slot "nil").
turtle.compare() expects no parameters. Provide one, it ignores it - it will
always compare the block in the currently selected inventory slot to the block in front of it. You can pass it a string containing the full lyrics to bohemian rhapsody for all it cares, the end result is the same.
ComputerCraft 1.6 and later change nothing out of the above. The lesson to take away is that sometimes there's only so much you'll learn from trial and error; I recommend taking a read through the
turtle API documentation if you've not come across it thus far.
And way. I need a code that will put 4 trees down in a row and add 4 more trees to the 2nd row. and them maintain it in a loop. I been looking and havn't fount any thing yet.
The problem I have is under standing how to turn and when and where to go next.
Well, at the moment you've got this:
for i = 1, x do
mforward()
checkSapling()
end
nextRow()
for i = 1, x do
mforward()
checkSapling()
end
Home()
At a glance, best I can make out you've already rigged things so that at the end of this process the turtle will be back where it was at the start of it.
So, all you've gotta do is loop the entire segment:
while true do -- Start a loop that repeats indefinitely.
for i = 1, x do -- Repeat four times.
mforward() -- Move forward four times.
checkSapling() -- Handle tree stuff.
end
nextRow() -- Move to the beginning of the next row.
for i = 1, x do
mforward()
checkSapling()
end
Home() -- Move back to the start position.
-- Maybe throw in code at this point to drop off / refuel.
end