Posted 16 April 2014 - 04:16 PM
Hello,
I'm currently working on my own logger program. However, there are a few issues that I can't seem to work out.
The main problem is that it is selecting slot 5 when it shouldn't be.
This is probably caused by my ineptness to place end statements in the correct positions.
IN A FEW MINUTES I WILL UPLOAD A VIDEO THAT OUTLINES THE ISSUE
The way that the program works is that it runs on cycles. There are four cycles, one for each type of tree. Cycle 1 is an Oak Tree, Cycle 2 is Spruce, 3 is Birch, 4 is Jungle.
When the program starts up, it asks for an input. Whatever the input is, that will be the FIRST CYCLE that it does
THIS PROGRAM IS NOT FINISHED! I've only completed the first two cycles.
The code can also be found at http://pastebin.com/bFvdWxFY
Here's the code for the program:
Thank you for all your help! I will definitly upload it when I am done.
I'm currently working on my own logger program. However, there are a few issues that I can't seem to work out.
The main problem is that it is selecting slot 5 when it shouldn't be.
This is probably caused by my ineptness to place end statements in the correct positions.
IN A FEW MINUTES I WILL UPLOAD A VIDEO THAT OUTLINES THE ISSUE
The way that the program works is that it runs on cycles. There are four cycles, one for each type of tree. Cycle 1 is an Oak Tree, Cycle 2 is Spruce, 3 is Birch, 4 is Jungle.
When the program starts up, it asks for an input. Whatever the input is, that will be the FIRST CYCLE that it does
THIS PROGRAM IS NOT FINISHED! I've only completed the first two cycles.
The code can also be found at http://pastebin.com/bFvdWxFY
Here's the code for the program:
term.clear()
term.setCursorPos(1,1)
print"Logger initialized!"
print"Please select cycle"
write"Cycle: "
local cycle = tonumber(read())
if cycle==1 then
print"Cycle 1"
if not turtle.detect() then
turtle.select(2)
turtle.place()
print"Cycle 1: Oak Tree Planted."
else
turtle.select(3)
if not turtle.compare() then
turtle.select(2)
if not turtle.compare() then
turtle.dig()
turtle.select(2)
turtle.place()
print"Cycle 1: Oak Tree Planted."
sleep(.5)
end
end
turtle.select(2)
while turtle.compare() do
sleep(1)
end
if not turtle.compare() then do
turtle.select(3)
if turtle.compare() then
print"Oak Tree detected. Cutting..."
end
end
while turtle.compare() do
turtle.dig()
turtle.digUp()
turtle.up()
end
while turtle.down() do
turtle.down()
end
if not turtle.detect() and not turtle.down() then do
cycle = 2
end
end
end
end
if cycle==2 then
print"Cycle 2"
if turtle.detect() then
turtle.select(5)
while not turtle.compare() do
turtle.dig()
turtle.place()
end
else
turtle.select(4)
turtle.place()
end
end
turtle.select(4)
while turtle.compare() do
sleep (1)
end
while not turtle.compare() do
turtle.select(5)
if turtle.compare() then
print"Spruce Tree detected! Cutting..."
end
end
while turtle.compare() do
turtle.dig()
turtle.digUp()
turtle.up()
end
while turtle.down() do turtle.down()
end
while not turtle.detect() and not turtle.down() do
cycle = 3
end
end
Thank you for all your help! I will definitly upload it when I am done.
Edited on 16 April 2014 - 02:18 PM