Posted 17 February 2015 - 02:12 AM
Evening.
I need help with translating my GPS location into a GUI mapping representing the past and present gps locations.
For starters; I have a gps system set up for my mining-specific turtle which keeps track of it's X and Z coordinates.
The X and Z coordinates are tantamount to the X and Y of the command term.setCursorPos(x,y).
For each xPos and zPos, the program should be able to identify the new term.setCursorPos(+x,+y) position.
For each xNeg and zNeg the program should be able to identify the new term.setCursorPos(-x,-y) position.
Ex:
Starting Location: 100, 50
New Location: 103, 50
The program should identify whether or not the x or z coordinates changes and move the cursor position in correspondence.
Since the X value had changed, the cursor position should change it in a positive value.
Ex:
Starting Location: term.setCursorPos(4,4)
New Location: term.setCursorPos(4,1)
(Note: The X value is reversed in terms of neg-to-pos; The base starting point of the mapping starts at a higher number as to place the mark " X " at the base of the page.)
*–*–*
|…|…| The turtle starts at the location represented by the 'x' and begins moving forward.
|…|…| Each move should be identified as a positive or negative movement and remap the new location.
*–X–* term.setCursorPos(4,4)
*–X–*
|…|…| Being said, if the starting location was 100, 50 and the ending location is 103, 50, only the x should change which moves the
|…|…| mark-of-current-location.
*–*–* term.setCursorPos(4,1)
I might have made it appear more complex than it actually is. Here is the specified code I am referring to:
(NOTE: I am aware of the minor no-point faults of code. No matter the location, the program seems to have common trouble with the x2-x1, z2-z1 (new gps location - old gps location). It manages to print out only one or two points instead off all four points (one for each move the turtle makes.)
The program identifies whether-or-not the gps translation is a positive number or negative number by subtracting the second gps.locate() by the first. This should identify as a Pos, Neg, or 0 (0 being no movement; which should keep the term.setCursorPos()
at the starting point).
I have re-written this code in many different ways. I feel as if I am making it harder than it is.. or that I am unaware of another piece of code that would help. I appreciate any contributions toward my progress and I am more than happy to simplify (or at least attempt) my program to answer any questions that you may possess.
Thanks Again. - Edible
I need help with translating my GPS location into a GUI mapping representing the past and present gps locations.
For starters; I have a gps system set up for my mining-specific turtle which keeps track of it's X and Z coordinates.
The X and Z coordinates are tantamount to the X and Y of the command term.setCursorPos(x,y).
For each xPos and zPos, the program should be able to identify the new term.setCursorPos(+x,+y) position.
For each xNeg and zNeg the program should be able to identify the new term.setCursorPos(-x,-y) position.
Ex:
Starting Location: 100, 50
New Location: 103, 50
The program should identify whether or not the x or z coordinates changes and move the cursor position in correspondence.
Since the X value had changed, the cursor position should change it in a positive value.
Ex:
Starting Location: term.setCursorPos(4,4)
New Location: term.setCursorPos(4,1)
(Note: The X value is reversed in terms of neg-to-pos; The base starting point of the mapping starts at a higher number as to place the mark " X " at the base of the page.)
*–*–*
|…|…| The turtle starts at the location represented by the 'x' and begins moving forward.
|…|…| Each move should be identified as a positive or negative movement and remap the new location.
*–X–* term.setCursorPos(4,4)
*–X–*
|…|…| Being said, if the starting location was 100, 50 and the ending location is 103, 50, only the x should change which moves the
|…|…| mark-of-current-location.
*–*–* term.setCursorPos(4,1)
I might have made it appear more complex than it actually is. Here is the specified code I am referring to:
--XBranch Test_ GPS Location and Printing.
a1 = 4
b1 = 4
term.setCursorPos(a1,b1)
local x, y, z = gps.locate(5)
a = 4
term.clear()
term.setCursorPos(1,10)
print("Starting Location: ("..x..", "..z..")")
while a > 0 do
a1 = 4
b1 = 4
a2 = a1
b2 = b1
local x, y, z = gps.locate(5)
x1 = x
z1 = z
local aa, bb, cc = gps.locate(5)
x2 = aa
z2 = cc
if x2-x1 == 0 and z2-z1 == 0 then
term.setCursorPos(a2, b2)
end
if x2-x1 > 0 then
term.setCursorPos(a2, b2-1)
end
if x2-x1 < 0 then
term.setCursorPos(a2, b2+1)
end
if z2-z1 > 0 then
term.setCursorPos(a2+1, b2)
end
if z2-z1 < 0 then
term.setCursorPos(a2-1, b2)
end
print("*")
turtle.forward()
a = a-1
end
term.setCursorPos(1,11)
local x, y, z = gps.locate(5)
print(" Ending Location: ("..x..", "..z..")")
(NOTE: I am aware of the minor no-point faults of code. No matter the location, the program seems to have common trouble with the x2-x1, z2-z1 (new gps location - old gps location). It manages to print out only one or two points instead off all four points (one for each move the turtle makes.)
The program identifies whether-or-not the gps translation is a positive number or negative number by subtracting the second gps.locate() by the first. This should identify as a Pos, Neg, or 0 (0 being no movement; which should keep the term.setCursorPos()
at the starting point).
I have re-written this code in many different ways. I feel as if I am making it harder than it is.. or that I am unaware of another piece of code that would help. I appreciate any contributions toward my progress and I am more than happy to simplify (or at least attempt) my program to answer any questions that you may possess.
Thanks Again. - Edible
Edited on 18 February 2015 - 02:19 AM