Posted 16 October 2012 - 11:40 AM
term.clear()
term.setCursorPos(1,1)
local tArgs = {...}
local xto = tArgs[1]
local yto = tArgs[2]
local zto = tArgs[3]
local dir = 0
--[getting the direction (look at calibration)]--
if tArgs[4] == nil then
dirto = 1
elseif tArgs[4] > "3" then
dirto = 1
print("direction to = 1")
elseif tArgs[4] < "0" then
dirto = 1
print("direction to = 1")
else
dirto = tArgs[4]
end
--[acceptions in tArgs]--
if xto == nil or yto == nil or zto == nil then
print("usage: goto <x to> <y to> < z to>... and optinal <set direction>")
return
end
if size == tonumber( tArgs[1]) or size == tonumber( tArgs[2]) or size == tonumber( tArgs[3]) then
print("x,y,z ( and dir ) must be a number")
return
end
--[basics movs.]--
local function turnLeft()
turtle.turnLeft()
dir = dir - 1
if dir < 0 then
dir = 3
end
end
local function turnRight()
turtle.turnRight()
dir = dir + 1
if dir > 3 then
dir = 0
end
end
rednet.open("right")
local function locate()
x,y,z = gps.locate(3)
end
--[calibration]--
local function calibration()
locate()
if turtle.forward() == false then
print("impossible calibration")
return false
else
xf,yf,zf = gps.locate(3)
if xf == x + 1 then
dir = 3
turtle.back()
return true
elseif xf == x - 1 then
dir = 1
turtle.back()
return true
elseif xf == x then
if zf == z + 1 then
dir = 0
turtle.back()
return true
elseif zf == z - 1 then
dir = 2
turtle.back()
return true
end
end
end
end
--[goto movs.]--
local function gotox()
print(xto)
if xto > x then
print("grande")
elseif xto < x then
print("pequeño")
end
end
calibration()
print(x.." "..y.." "..z.." "..dir)
gotox()
rednet.close("right")
Can you help me?¿I'm doing my own goto program, and it says that my argument isn't a number, when I try to compare the position in X to the X destination.
thanks.