Jump to content




Automatic Tree Harvester

turtle lua

  • You cannot reply to this topic
No replies to this topic

#1 pythonDan

  • New Members
  • 1 posts

Posted 23 July 2014 - 03:18 PM

I have created a program that makes a turtle go around in a specific pattern (that can be programmed into the array [SPAN]
local order
[/SPAN] using the three functions listed, which do as their names imply.

Unfortunately, it has to be reset to a specific position every time the program stops.

Copy and paste into the computer directory in saves.

--VERSION 0.1, 9:25 PM 7/3/2014
--slot 1: saplings
--slot 2: wood of sapling type
function goLeft ()
turtle.turnLeft();
turtle.forward();
turtle.turnRight();
turtle.forward();
turtle.turnLeft();
while not turtle.detect() do turtle.forward() end
end

function goRight ()
turtle.turnRight();
turtle.forward();
turtle.turnLeft();
turtle.forward();
turtle.turnRight();
while not turtle.detect() do turtle.forward() end
end

function goStraight ()
turtle.turnLeft();
turtle.forward();
turtle.turnRight();
turtle.forward();
turtle.forward();
turtle.turnRight();
turtle.forward();
turtle.turnLeft();
while not turtle.detect() do turtle.forward() end
end

function harvest ()
turtle.select(2);
local height = 0;
while turtle.compare() do
turtle.dig();
turtle.digUp();
turtle.up();
height = height + 1;
end
for i=1,height do
turtle.down();
end
turtle.select(1);
turtle.place();
end

local order = {goStraight, goLeft, goStraight, goLeft, goLeft, goRight, goLeft, goLeft};
--set order to whatever pattern for tree harvesting; trees MUST be in same row or column
while 1 do
for i=1,#order do
order[i]();
harvest();
end
end






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users