This commit is contained in:
Jeremy Smitherman 2018-12-24 20:54:40 -06:00
commit af4fa9d854
4 changed files with 53 additions and 16 deletions

View File

@ -2,4 +2,5 @@ dofile(HOGGIT.script_base..[[\HOGGIT\lib\error_handling.lua]])
dofile(HOGGIT.script_base..[[\HOGGIT\lib\logging.lua]]) dofile(HOGGIT.script_base..[[\HOGGIT\lib\logging.lua]])
dofile(HOGGIT.script_base..[[\HOGGIT\lib\utils.lua]]) dofile(HOGGIT.script_base..[[\HOGGIT\lib\utils.lua]])
dofile(HOGGIT.script_base..[[\HOGGIT\lib\spawner.lua]]) dofile(HOGGIT.script_base..[[\HOGGIT\lib\spawner.lua]])
dofile(HOGGIT.script_base..[[\HOGGIT\lib\group_commands.lua]]) dofile(HOGGIT.script_base..[[\HOGGIT\lib\communication.lua]])
dofile(HOGGIT.script_base..[[\HOGGIT\lib\group.lua]])

19
lib/group.lua Normal file
View File

@ -0,0 +1,19 @@
-- Returns the location of the first unit in a given group.
-- If the group is nil, this function returns nil.
-- @param grp The group you want coordinates for.
-- @return Vec3 The group's first unit's coordinates, or nil if the group is nil
HOGGIT.groupCoords = function(grp)
if grp ~= nil then
return grp:getUnits()[1]:getPosition().p
end
return nil
end
-- Starts a smoke beacon at the specified group's location
-- @param grp The group to smoke. Will be placed on or near the first unit.
-- @param smokeColor The trigger.smokeColor enum value to use. Defaults to White smoke
HOGGIT.smokeAtGroup = function(grp, smokeColor)
local pos = HOGGIT.groupCoords(grp)
if smokeColor == nil then smokeColor = trigger.smokeColor.White end
trigger.action.smoke(pos, smokeColor)
end

View File

@ -1,24 +1,41 @@
HOGGIT.randomInList = function(list) HOGGIT.randomInList = function(list)
local idx = math.random(1, #list) local idx = math.random(1, #list)
return list[idx] return list[idx]
end end
HOGGIT.filterTable = function(t, filter) HOGGIT.filterTable = function(t, filter)
local out = {} local out = {}
for k,v in pairs(t) do for k,v in pairs(t) do
if filter(v) then out[k] = v end if filter(v) then out[k] = v end
end end
return out return out
end end
HOGGIT.listContains = function(list, elem) HOGGIT.listContains = function(list, elem)
for _, value in ipairs(list) do for _, value in ipairs(list) do
if value == elem then if value == elem then
return true return true
end
end end
end
return false 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
-- Returns a textual smoke name based on the provided enum
-- @param a trigger.smokeColor enum
-- @return the English word as a string representing the color of the smoke. i.e. trigger.smokeColor.Red returns "Red"
HOGGIT.getSmokeName = function(smokeColor)
if smokeColor == trigger.smokeColor.Green then return "Green" end
if smokeColor == trigger.smokeColor.Red then return "Red" end
if smokeColor == trigger.smokeColor.White then return "White" end
if smokeColor == trigger.smokeColor.Orange then return "Orange" end
if smokeColor == trigger.smokeColor.Blue then return "Blue" end
end end
HOGGIT.GroupIsAlive = function(group) HOGGIT.GroupIsAlive = function(group)