Posted 05 September 2012 - 08:35 PM
Hi,
I wrote this script to go to some coordinates, it works by you telling it which way it is facing, it will then turn to north, then ask for the destination coordinates. Currently, its asking for lots of "ends", which I got confused about because I am rubbish at making it look nice with spaces.
Your mission, should you chose to accept it is to put in all the "ends" and make it work!
THANKS!
H
I wrote this script to go to some coordinates, it works by you telling it which way it is facing, it will then turn to north, then ask for the destination coordinates. Currently, its asking for lots of "ends", which I got confused about because I am rubbish at making it look nice with spaces.
function look(direction)
write("Direction? ")
curDir = read()
if curDir == n then
print("Facing North")
end
if curDir == e then
turtle.turnLeft()
print("Facing North")
end
if curDir == s then
turtle.turnRight()
turtle.turnRight()
print("Facing North")
end
if curDir == w then
turtle.turnRight()
print("Facing North")
end
else
print("Invalid Entry")
shell.run("goto")
end
end
if direction == "north" then
end
if direction == "east" then
turtle.turnLeft()
end
if direction == "south" then
turtle.turnRight()
turtle.turnRight()
end
if direction == west then
turtle.turnLeft()
end
end
end
end
end
end
write("Enter X Coord: ")
xTarget = read()
write("Enter Y Coord; ")
yTarget = read()
write("Enter Z Coord: ")
zTarget = read()
x, y, z = gps.locate(5)
while yTarget < y do
turtle.down()
end
while yTarget > y do
turtle.up()
end
if xTarget < x then
look("west")
while xTarget < x do
turtle.forward()
end
end
if xTarget > x then
look("east")
while xTarget > x do
turtle.forward()
end
end
if zTarget < z then
look("north")
while zTarget < z do
turtle.forward()
end
end
if zTarget > z then
look("south")
while zTarget > z do
turtle.forward()
end
end
end
Your mission, should you chose to accept it is to put in all the "ends" and make it work!
THANKS!
H