Posted 08 May 2015 - 07:36 PM
ok I am writting a code system that uses 1 main computer craft computer for acting as the system interface and 9 wireless farming turtles for my planting
my farm system has been built like this
KEY
B = Brick
F = Farmland
W = Water
P = Piston
C = Computer
T = Turtle
Top Down View
Level
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBWWWBWWWBWWWBWWWBWWWBWWWBWWWBWWWBWWWBB
BBPPPBPPPBPPPBPPPBPPPBPPPBPPPBPPPBPPPBB
BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
-1 BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
-1 BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
-1 BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
-1 BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
-1 BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
-1 BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
-1 BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
-2 BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
-2 BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
-2 BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
-2 BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
-2 BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
-2 BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
-2 BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
-2 BBFFFBFFFBFFFBFFFBFFFBFFFBFFFBFFFBFFFBB
-3 BWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWB
-2 BBBTBBBTBBBTBBBTBBBTBBBTBBBTBBBTBBBTBBC
Side View
BBP
BWP
BBB
BBBFFFFFFF 0
BBBBBBBBBBFFFFFFF T -1
BBBBBBBBBBBBBBBBBFFFFFFFF B -2
BBBBBBBBBBBBBBBBBBBBBBBBBWB -3
BBBBBBBBBBBBBBBBBBBBBBBBBBB -4
thats how I have my farming system set up for the turtles now what I am hoping to do, is to have it so
the computer can send a message to one of the turtles to sow that row with seeds then using the same
computer to send via a wireless redstone block or via a computer to the pistons so that when the crop
is ready it can auto harvest by sending a message to the row that is harvesting so only one row can be
sent or so all the row can be harvested but I am only a beginner at LUA Coding and would like some help
with coding this system
so far I have worked out a way to get the turtles to line up with north south east and west with this
code below now I am sure it can be done with less work then I have done but as I say I do not known LUA
that well so I could do with some help with trimming what is not needed and keeping what is needed I
would love to be able to make it use GPS for the X/Y/Zcoord
my farm system has been built like this
KEY
B = Brick
F = Farmland
W = Water
P = Piston
C = Computer
T = Turtle
Top Down View
Level
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBWWWBWWWBWWWBWWWBWWWBWWWBWWWBWWWBWWWBB
BBPPPBPPPBPPPBPPPBPPPBPPPBPPPBPPPBPPPBB
BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
-1 BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
-1 BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
-1 BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
-1 BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
-1 BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
-1 BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
-1 BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
-2 BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
-2 BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
-2 BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
-2 BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
-2 BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
-2 BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
-2 BWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWFFFWB
-2 BBFFFBFFFBFFFBFFFBFFFBFFFBFFFBFFFBFFFBB
-3 BWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWB
-2 BBBTBBBTBBBTBBBTBBBTBBBTBBBTBBBTBBBTBBC
Side View
BBP
BWP
BBB
BBBFFFFFFF 0
BBBBBBBBBBFFFFFFF T -1
BBBBBBBBBBBBBBBBBFFFFFFFF B -2
BBBBBBBBBBBBBBBBBBBBBBBBBWB -3
BBBBBBBBBBBBBBBBBBBBBBBBBBB -4
thats how I have my farming system set up for the turtles now what I am hoping to do, is to have it so
the computer can send a message to one of the turtles to sow that row with seeds then using the same
computer to send via a wireless redstone block or via a computer to the pistons so that when the crop
is ready it can auto harvest by sending a message to the row that is harvesting so only one row can be
sent or so all the row can be harvested but I am only a beginner at LUA Coding and would like some help
with coding this system
so far I have worked out a way to get the turtles to line up with north south east and west with this
code below now I am sure it can be done with less work then I have done but as I say I do not known LUA
that well so I could do with some help with trimming what is not needed and keeping what is needed I
would love to be able to make it use GPS for the X/Y/Zcoord
xcoord = 0 --East/West
zcoord = 0 --North/South
ycoord = 64 --Height
xTarget -- East and West
zTarget -- North and South
yTarget --Height
zDiff = { -1, 0, 1, 0}
xDiff = { 0, 1,0, -1 }
Ori = 1
Ors = {"North", "East", "South", "West"}
function look(dir)
while dir ~= Ors[Ori]
right()
end
end
function goto(xTarget, zTarget, yTarget)
while yTarget < ycoord do
moveDown()
end
while yTarget > ycoord do
moveUp()
end
if xTarget < xcoord then
look("West")
while xTarget < xcoord do
moveForward()
end
end
if xTarget > xcoord then
look("East")
while xTarget > xcoord do
moveForward()
end
end
if zTarget < zcoord then
look("North")
while zTarget < zcoord do
moveForward()
end
end
if zTarget > zcoord then
look("South")
while zTarget > zcoord do
moveForward()
end
end
end
function left()
Ori = Ori - 1
Ori = (Ori - 1) % 4
Ori = Ori + 1
turtle.turnLeft()
end
function right()
Ori = Ori - 1
Ori = (Ori + 1) % 4
Ori = Ori + 1
turtle.turnRight()
end
function moveForward()
xcoord = xcoord + xDiff[Ori]
zcoord = zcoord + zDiff[Ori]
moved = false
while not(moved) do
moved = turtle.forward()
end
end
function moveUp()
ycoord = ycoord + 1
moved = false
while not(moved) do
moved = turtle.up()
end
end
function moveDown()
ycoord = ycoord - 1
moved = false
while not(moved) do
moved = turtle.down()
end
end
goto()