Posted 10 January 2013 - 12:00 PM
Here is my code:
My issue is that it doesn't seem to be defining the vx, vy, and vz variables… Can anybody tell me why?
rednet.open("right")
local x, y, z = gps.locate(2)
term.clear()
term.setCursorPos(1, 1)
print("Current Position: "..x..", "..y..", "..z)
print("Enter target X.")
local tx = tonumber(read())
print("Enter target Y.")
local ty = tonumber(read())
print("Enter target Z.")
local tz = tonumber(read())
print("Target Position: "..tx..", "..ty..", "..tz)
if ty <= 0 then
print("Target is not valid")
error()
end
if x > tx then
local vx = x - tx
elseif tx > x then
local vx = tx - x
else
local vx = 0
end
if y > ty then
local vy = x - ty
elseif ty > y then
local vy = ty - y
else
local vy = 0
end
if z > tz then
local vz = z - tz
elseif tz > z then
local vz = tz - z
else
local vz = 0
end
print("Distance X: "..vx)
print("Distance Y: "..vy)
print("Distance Z: "..vz)
My issue is that it doesn't seem to be defining the vx, vy, and vz variables… Can anybody tell me why?