rednet.open("right")
connected = 0
oid = 0
x = 0
y = 0
z = 0
rotation = 0
function Forward()
while turtle.detect() do
turtle.dig()
end
turtle.forward()
while turtle.detectUp() do
turtle.digUp()
end
while turtle.detectDown() do
turtle.digDown()
end
if rotation == 0 then
z = z - 1
elseif rotation == 1 then
x = x - 1
elseif rotation == 2 then
z = z + 1
elseif rotation == 3 then
x = x + 1
end
end
function Left()
turtle.turnLeft()
if rotation < 3 then
rotati + 1
else
rotati
end
end
function Right()
turtle.turnRight()
if rotation > 0 then
rotation = rotation - 1
else
rotation = 3
end
end
function Backwards()
turtle.back()
if rotation == 0 then
z = z + 1
elseif rotation == 1 then
x = x + 1
elseif rotation == 2 then
z = z - 1
elseif rotation == 3 then
x = x - 1
end
end
function Up()
end
function Down()
end
function StartMine()
distance = 0
while true do
distance = distance + 1
if distance < 25 then
Forward()
elseif rotati 0 then
Left()
Forward()
Left()
distance = 0
elseif rotati 2 then
Right()
Forward()
Right()
distance = 0
end
id, msg = rednet.receive(1)
if id == oid and msg == "StopMine" then
break
end
end
end
function Return()
while true do
if rotation > 0 then
Right()
else
if z > 0 then
Forward()
elseif z < 0 then
Left()
Left()
while z < 0 do
Forward()
end
elseif x > 0 then
while rotation ~= 1 do
Left()
end
Forward()
elseif x < 0 then
while rotation ~= 3 do
Left()
end
Forward()
break
end
end
end
end
while true do
if c 0 then
id, msg = rednet.receive()
print("got msg: " .. msg)
if msg == "Connect" then
rednet.send(id, "kt")
print("sent msg: kt")
oid = id
id, msg = rednet.receive()
print("got msg: " .. msg)
if id == oid then
c
end
end
elseif c 1 then
id, msg = rednet.receive()
print("got msg: " .. msg)
if msg == "Mine" and id == oid then
StartMine()
elseif msg == "Return" and id == oid then
Return()
end
end
end
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}