From cfe5f1082344f49baf88363600f9d167e4037127 Mon Sep 17 00:00:00 2001 From: Lugghawk Date: Mon, 24 Dec 2018 18:39:56 -0500 Subject: [PATCH] adds group.lua. getLatLongString to utils. --- hoggit.lua | 1 + lib/group.lua | 8 ++++++++ lib/utils.lua | 6 ++++++ 3 files changed, 15 insertions(+) create mode 100644 lib/group.lua diff --git a/hoggit.lua b/hoggit.lua index c5418dc..63cda70 100644 --- a/hoggit.lua +++ b/hoggit.lua @@ -3,3 +3,4 @@ dofile(HOGGIT.script_base..[[\HOGGIT\lib\logging.lua]]) dofile(HOGGIT.script_base..[[\HOGGIT\lib\utils.lua]]) dofile(HOGGIT.script_base..[[\HOGGIT\lib\spawner.lua]]) dofile(HOGGIT.script_base..[[\HOGGIT\lib\communication.lua]]) +dofile(HOGGIT.script_base..[[\HOGGIT\lib\group.lua]]) diff --git a/lib/group.lua b/lib/group.lua new file mode 100644 index 0000000..a7ee839 --- /dev/null +++ b/lib/group.lua @@ -0,0 +1,8 @@ +-- Returns the location of the first unit in a given group. +-- If the group is nil, this function returns nil. +HOGGIT.groupCoords = function(grp) + if grp ~= nil then + return grp:getUnits()[1]:getPosition().p + end + return nil +end diff --git a/lib/utils.lua b/lib/utils.lua index 0d0f821..0678804 100644 --- a/lib/utils.lua +++ b/lib/utils.lua @@ -20,3 +20,9 @@ HOGGIT.listContains = function(list, elem) return false end + +HOGGIT.getLatLongString = function(pos, decimal) + local lat, long = coord.LOtoLL(pos) + if decimal == nil then decimal = false end + return mist.tostringLL(lat, long, 3, decimal) +end