Posted 16 May 2013 - 04:01 PM
Title: Ask a Pro
[Lua] Need help with program
Its a "Auto=Pilot" program that I'm working on and I would like some assistance
Program so far:
[Lua] Need help with program
Its a "Auto=Pilot" program that I'm working on and I would like some assistance
Program so far:
local a = vector.new(gps.locate())
turtle.forward()
local b = vector.new(gps.locate())
turtle.back()
--Tells direction
if a.x < b.x then
local d = ("East")
end
if a.x > b.x then
local d = ("West")
end
if a.z < b.z then
local d = ("South")
end
if a.z > b.z then
local d = ("North")
end
--Part of "Planning Path"
print("Currently Facing: ",d)
print("Currently at: ",a)
term.write("X: ")
local x = read()
term.write("Y: ")
local y = read()
term.write("Z: ")
local z = read()
local g = vector.new(x, y, z)
--Planning Path WIP...
local p = g - a
local n, n2, n3 = math.abs(p.x), math.abs(p.y), math.abs(p.z)
print("X Distance: ", n, "\nY Change: ", n2, "\nZ Distance: ", n3, "\nTotal Distance: ", (n + n2 + n3))
local f = turtle.getFuelLevel()
if f < (n + n2 + n3) then
print("Need more fuel")
end
I would apprecate it if someone would help me with this.