Posted 24 December 2012 - 07:33 PM
I have been searching for information everywere on a few topics and I couldent find any information maybe I can get some answers here:
What does this do?:
how is it used?
I know that print means what is says but I do not understand what the local args =(..) means mostly confused about what the … means does it mean the same thing as * in other codes?
———————————————————————————————————————————————————–
Second question:
What would this do? not even sure what it could mean.
————————————————————————————————————————————————————
Third Question:
If I just open the prompt in game, and I type "turtle.down" it would move down a single square how come when it is in
this format it goes on endlessly? is it because of the detectdown prompt? also can I get some help on turtle.compare?
how do I choose the slot it compares to? do I have to do turtle.select(2) to select slot 2?
If I could get some answers that would be nice :)/>
The code I am referencing is here:
————————————————————————————————————————————————————
What does this do?:
how is it used?
I know that print means what is says but I do not understand what the local args =(..) means mostly confused about what the … means does it mean the same thing as * in other codes?
local args = {...}
if #args ~= 1 then
print('Usage: lumberjack <size>')
return
———————————————————————————————————————————————————–
Second question:
What would this do? not even sure what it could mean.
for n = 1, args[1], 1 do
————————————————————————————————————————————————————
Third Question:
If I just open the prompt in game, and I type "turtle.down" it would move down a single square how come when it is in
this format it goes on endlessly? is it because of the detectdown prompt? also can I get some help on turtle.compare?
how do I choose the slot it compares to? do I have to do turtle.select(2) to select slot 2?
function up()
while not turtle.up() do
turtle.digUp()
end
end
function cutTree()
while turtle.compare() do
turtle.dig()
up()
end
while not turtle.detectDown() do
turtle.down()
end
end
———————————————————————————————————————————————————–If I could get some answers that would be nice :)/>
The code I am referencing is here:
————————————————————————————————————————————————————
function up()
while not turtle.up() do
turtle.digUp()
end
end
function cutTree()
while turtle.compare() do
turtle.dig()
up()
end
while not turtle.detectDown() do
turtle.down()
end
end
function search(dist)
while dist > 0 do
if turtle.compare() then
cutTree()
elseif not turtle.forward() then
up()
else
dist = dist - 1
while not turtle.detectDown() do
turtle.down()
end
end
end
end
local args = {...}
if #args ~= 1 then
print('Usage: lumberjack <size>')
return
end
turtle.select(1)
if turtle.getItemCount(1) == 0 then
print('ERROR: Requires unrefined wood block in slot #1.')
return
end
for n = 1, args[1], 1 do
search(n)
turtle.turnRight()
search(n)
turtle.turnRight()
end