function deposit()
i=0;
while i<9 do
sleep(1);
redstone.setOutput("left",true);
redstone.setOutput("right",true);
redstone.setOutput("front",true);
redstone.setOutput("back",true);
sleep(1);
redstone.setOutput("left",false);
redstone.setOutput("right",false);
redstone.setOutput("front",false);
redstone.setOutput("back",false);
i=i+1;
end
end

function gohome(locx,locy,locz)
homex=256
homey=73;
homez=281;
local landy=homey;
fhieght=100;
local lengthx=math.abs(locx-homex);
local lengthy=math.abs(locy-fhieght);
local lengthz=math.abs(locz-homez);
local countx=1;
local county=1;
local countz=1;
if homex>locx and homez~=locz then
while county<=lengthy do
turtle.up();
county=county+1;
end
turtle.turnRight();
while countx<=lengthx do
turtle.forward();
countx=countx+1;
end
if homez>locz then
turtle.turnRight();
while countz<=lengthz do
turtle.forward();
countz=countz+1;
end
end
if homez<locz then
turtle.turnLeft();
while countz<=lengthz do
turtle.forward();
countz=countz+1;
end
end
end

if homex<locx and homez~=locz then
while county<=lengthy do
turtle.up();
county=county+1;
end
turtle.turnLeft();
while countx<=lengthx do
turtle.forward();
countx=countx+1;
end
if homez<locz then
turtle.turnRight();
while countz<=lengthz do
turtle.forward();
countz=countz+1;
end
end
if homez>locz then
turtle.turnLeft();
while countz<=lengthz do
turtle.forward();
countz=countz+1;
end
end
end

if homex==locx then
while county<=lengthy do
turtle.up();
county=county+1;
end
if homez<locz then
while countz<=lengthz do
turtle.forward();
countz=countz+1;
end
end
if homez>locz then
while countz<=lengthz do
turtle.back();
countz=countz+1;
end
end
end

if homez==locz then
while county<=lengthy do
turtle.up();
county=county+1;
end
turtle.turnRight();
if homex>locx then
while countx<=lengthx do
turtle.forward();
countx=countx+1;
end
end
if homex<locx then
while countx<=lengthx do
turtle.back();
countx=countx+1;
end
end
end
while fhieght>landy do
turtle.down();
landy=landy+1;
end
deposit();
end





function rtnsender(loca,locb,locc)
local landy=input2;
local lengthx=math.abs(loca-homex);
local lengthy=math.abs(locb-fhieght);
local lengthz=math.abs(locc-homez);
local countx=1;
local county=1;
local countz=1;
if homex>loca and homez~=locc then
while county<=lengthy do
turtle.up();
county=county+1;
end
turtle.turnRight();
while countx<=lengthx do
turtle.forward();
countx=countx+1;
end
if homez>locc then
turtle.turnRight();
while countz<=lengthz do
turtle.forward();
countz=countz+1;
end
end
if homez<locc then
turtle.turnRight();
while countz<=lengthz do
turtle.forward();
countz=countz+1;
end
end
end

if homex<loca and homez~=locc then
while county<=lengthy do
turtle.up();
county=county+1;
end
turtle.turnRight();
while countx<=lengthx do
turtle.forward();
countx=countx+1;
end
if homez>locc then
turtle.turnRight();
while countz<=lengthz do
turtle.forward();
countz=countz+1;
end
end
if homez<locc then
turtle.turnRight();
while countz<=lengthz do
turtle.forward();
countz=countz+1;
end
end
end

if homex==loca then
while county<=lengthy do
turtle.up();
county=county+1;
end
if homez>locc then
while countz<=lengthz do
turtle.forward();
countz=countz+1;
end
end
if homez<locc then
while countz<=lengthz do
turtle.back();
countz=countz+1;
end
end
end

if homez==locc then
while county<=lengthy do
turtle.up();
county=county+1;
end

if homex<loca then
while countx<=lengthx do
turtle.forward();
countx=countx+1;
end
end
if homex>loca then
while countx<=lengthx do
turtle.back();
countx=countx+1;
end
end
end
while fhieght>landy do
turtle.down();
landy=landy+1;
end
end
term.clear();
term.setCursorPos(1,1);
print("Welcome to Robit Shuttle OS!")
term.setCursorPos(1,3);
print("What are the corodinates of where you placed the drone? NOTE:Use integers. For elevation use the number next to the one in parenthesis. Unit must be facing north to operate properly. Turtle corp. is not liable for loss of property due to operator error.");
print("Please enter X parameter...");
input1=tonumber(read());
print("Please enter Y parameter...");
input2=tonumber(read());
print("Please enter Z parameter...");
input3=tonumber(read());


gohome(input1,input2,input3);
rtnsender(input1,input2,input3);
