fixed mixed-indention, removed trailing spaces

This commit is contained in:
Lukas Kropatschek 2016-01-04 19:24:56 +01:00
parent 1120db661f
commit f80eb3ed10

259
mist.lua
View File

@ -588,8 +588,8 @@ do
end
mist.dynAdd = function(newGroup) -- same as coalition.add function in SSE. checks the passed data to see if its valid.
--Will generate groupId, groupName, unitId, and unitName if needed
--
--Will generate groupId, groupName, unitId, and unitName if needed
--
@ -770,8 +770,8 @@ do
end
---------------------------------------------------------------------------------------------
--Modified Slmod task scheduler, superior to timer.scheduleFunction
---------------------------------------------------------------------------------------------
--Modified Slmod task scheduler, superior to timer.scheduleFunction
local Tasks = {}
local task_id = 0
@ -875,7 +875,7 @@ do
end
mist.addEventHandler(groupSpawned)
-- mist.scheduleFunction(checkSpawnedEvents, {}, timer.getTime() + 5, 1)
-- mist.scheduleFunction(checkSpawnedEvents, {}, timer.getTime() + 5, 1)
end
------------------------------------------------------------------------------------------------------------
@ -1896,7 +1896,7 @@ end
mist.DBs.navPoints = {}
mist.DBs.units = {}
--Build mist.db.units and mist.DBs.navPoints
--Build mist.db.units and mist.DBs.navPoints
for coa_name, coa_data in pairs(env.mission.coalition) do
if (coa_name == 'red' or coa_name == 'blue') and type(coa_data) == 'table' then
@ -2060,16 +2060,16 @@ mist.DBs.aliveUnits = {} -- will be filled in by the "update_alive_units" corou
mist.DBs.removedAliveUnits = {} -- will be filled in by the "update_alive_units" coroutine in mist.main.
-- create mist.DBs.oldAliveUnits
-- do
-- local intermediate_alive_units = {} -- between 0 and 0.5 secs old
-- local function make_old_alive_units() -- called every 0.5 secs, makes the old_alive_units DB which is just a copy of alive_units that is 0.5 to 1 sec old
-- if intermediate_alive_units then
-- mist.DBs.oldAliveUnits = mist.utils.deepCopy(intermediate_alive_units)
-- end
-- intermediate_alive_units = mist.utils.deepCopy(mist.DBs.aliveUnits)
-- timer.scheduleFunction(make_old_alive_units, nil, timer.getTime() + 0.5)
-- end
-- local intermediate_alive_units = {} -- between 0 and 0.5 secs old
-- local function make_old_alive_units() -- called every 0.5 secs, makes the old_alive_units DB which is just a copy of alive_units that is 0.5 to 1 sec old
-- if intermediate_alive_units then
-- mist.DBs.oldAliveUnits = mist.utils.deepCopy(intermediate_alive_units)
-- end
-- intermediate_alive_units = mist.utils.deepCopy(mist.DBs.aliveUnits)
-- timer.scheduleFunction(make_old_alive_units, nil, timer.getTime() + 0.5)
-- end
-- make_old_alive_units()
-- make_old_alive_units()
-- end
@ -2295,7 +2295,7 @@ end
function mist.makeUnitTable(tbl)
--[[
--[[
Prefixes:
"[-u]<unit name>" - subtract this unit if its in the table
"[g]<group name>" - add this group to the table
@ -2396,7 +2396,7 @@ Country names to be used in [c] and [-c] short-cuts:
end
end
end
elseif unit:sub(1,4) == '[-g]' then -- subtract a group
elseif unit:sub(1,4) == '[-g]' then -- subtract a group
for coa, coa_tbl in pairs(l_munits) do
for country, country_table in pairs(coa_tbl) do
for unit_type, unit_type_tbl in pairs(country_table) do
@ -2413,7 +2413,7 @@ Country names to be used in [c] and [-c] short-cuts:
end
end
end
end
end
elseif unit:sub(1,3) == '[c]' then -- add a country
local category = ''
local country_start = 4
@ -2671,8 +2671,8 @@ end
mist.getDeadMapObjsInZones = function(zone_names)
-- zone_names: table of zone names
-- returns: table of dead map objects (indexed numerically)
-- zone_names: table of zone names
-- returns: table of dead map objects (indexed numerically)
local map_objs = {}
local zones = {}
for i = 1, #zone_names do
@ -2694,8 +2694,8 @@ end
mist.getDeadMapObjsInPolygonZone = function(zone)
-- zone_names: table of zone names
-- returns: table of dead map objects (indexed numerically)
-- zone_names: table of zone names
-- returns: table of dead map objects (indexed numerically)
local map_objs = {}
for obj_id, obj in pairs(mist.DBs.deadObjects) do
if obj.objectType and obj.objectType == 'building' then --dead map object
@ -2710,7 +2710,7 @@ end
mist.flagFunc = {}
mist.flagFunc.mapobjs_dead_zones = function(vars)
--[[vars needs to be:
--[[vars needs to be:
zones = table or string,
flag = number,
stopflag = number or nil,
@ -2720,7 +2720,7 @@ AND used by function,
initial_number
]]
-- type_tbl
-- type_tbl
local type_tbl = {
[{'zones', 'zone'}] = {'table', 'string'},
flag = {'number', 'string'},
@ -2757,7 +2757,7 @@ end
mist.flagFunc.mapobjs_dead_polygon = function(vars)
--[[vars needs to be:
--[[vars needs to be:
zone = table,
flag = number,
stopflag = number or nil,
@ -2767,7 +2767,7 @@ AND used by function,
initial_number
]]
-- type_tbl
-- type_tbl
local type_tbl = {
[{'zone', 'polyzone'}] = 'table',
flag = {'number', 'string'},
@ -2855,7 +2855,7 @@ mist.getUnitsInPolygon = function (unit_names, polyZone, max_alt)
end
function mist.flagFunc.units_in_polygon(vars)
--[[vars needs to be:
--[[vars needs to be:
units = table,
zone = table,
flag = number,
@ -2866,7 +2866,7 @@ req_num = number or nil
toggle = boolean or nil
unitTableDef = table or nil
]]
-- type_tbl
-- type_tbl
local type_tbl = {
[{'units', 'unit'}] = 'table',
[{'zone', 'polyzone'}] = 'table',
@ -3224,7 +3224,7 @@ mist.getUnitsLOS = function(unitset1, altoffset1, unitset2, altoffset2, radius)
end
mist.flagFunc.units_LOS = function(vars)
--[[vars needs to be:
--[[vars needs to be:
unitset1 = table,
altoffset1 = number,
unitset2 = table,
@ -3236,7 +3236,7 @@ interval = number or nil,
req_num = number or nil
toggle = boolean or nil
]]
-- type_tbl
-- type_tbl
local type_tbl = {
[{'unitset1', 'units1'}] = 'table',
[{'altoffset1', 'alt1'}] = 'number',
@ -3301,7 +3301,7 @@ toggle = boolean or nil
end
mist.flagFunc.group_alive = function(vars)
--[[vars
--[[vars
groupName
flag
toggle
@ -4330,7 +4330,7 @@ do
return true
end
return false
end]]
end]]
mist.message = {
@ -4755,14 +4755,14 @@ mist.msgMGRS = function(vars)
else -- else, just append to the end.
newText = text .. s
end
else
else
newText = s
end
mist.message.add{
end
mist.message.add{
text = newText,
displayTime = displayTime,
msgFor = msgFor
}
}
end
--[[ vars for mist.msgLL
@ -4789,15 +4789,15 @@ mist.msgLL = function(vars)
else -- else, just append to the end.
newText = text .. s
end
else
else
newText = s
end
end
mist.message.add{
mist.message.add{
text = newText,
displayTime = displayTime,
msgFor = msgFor
}
}
end
@ -4828,15 +4828,15 @@ mist.msgBR = function(vars)
else -- else, just append to the end.
newText = text .. s
end
else
else
newText = s
end
end
mist.message.add{
mist.message.add{
text = newText,
displayTime = displayTime,
msgFor = msgFor
}
}
end
@ -4911,15 +4911,15 @@ mist.msgLeadingMGRS = function(vars)
else -- else, just append to the end.
newText = text .. s
end
else
else
newText = s
end
end
mist.message.add{
mist.message.add{
text = newText,
displayTime = displayTime,
msgFor = msgFor
}
}
end
@ -4954,15 +4954,15 @@ mist.msgLeadingLL = function(vars)
else -- else, just append to the end.
newText = text .. s
end
else
else
newText = s
end
end
mist.message.add{
mist.message.add{
text = newText,
displayTime = displayTime,
msgFor = msgFor
}
}
end
@ -4999,15 +4999,15 @@ mist.msgLeadingBR = function(vars)
else -- else, just append to the end.
newText = text .. s
end
else
else
newText = s
end
end
mist.message.add{
mist.message.add{
text = newText,
displayTime = displayTime,
msgFor = msgFor
}
}
end
@ -5020,7 +5020,7 @@ end
do -- all function uses of group and unit Ids must be in this do statement
mist.groupTableCheck = function(groupData)
mist.groupTableCheck = function(groupData)
local isOk = false
if groupData.country then
@ -5042,9 +5042,9 @@ mist.groupTableCheck = function(groupData)
end
return isOk
end
end
mist.getCurrentGroupData = function(gpName)
mist.getCurrentGroupData = function(gpName)
local dbData = mist.getGroupData(gpName)
if Group.getByName(gpName) and Group.getByName(gpName):isExist() == true then
@ -5092,9 +5092,9 @@ mist.getCurrentGroupData = function(gpName)
return dbData
end
end
end
mist.getGroupData = function(gpName)
mist.getGroupData = function(gpName)
local found = false
local newData = {}
if mist.DBs.groupsByName[gpName] then
@ -5157,9 +5157,9 @@ mist.getGroupData = function(gpName)
env.info(gpName .. ' not found in mist.getGroupData')
return
end
end
end
mist.getPayload = function(unitIdent)
mist.getPayload = function(unitIdent)
-- refactor to search by groupId and allow groupId and groupName as inputs
local unitId = unitIdent
if type(unitIdent) == 'string' and not tonumber(unitIdent) then
@ -5197,9 +5197,9 @@ mist.getPayload = function(unitIdent)
end
env.info('mist.getPayload, payload not found')
return
end
end
mist.getGroupPayload = function(groupIdent)
mist.getGroupPayload = function(groupIdent)
local gpId = groupIdent
if type(groupIdent) == 'string' and not tonumber(groupIdent) then
gpId = mist.DBs.MEgroupsByName[groupIdent].groupId
@ -5236,9 +5236,9 @@ mist.getGroupPayload = function(groupIdent)
env.info('mist.getGroupPayload, payload not found')
return
end
end
mist.teleportToPoint = function(vars) -- main teleport function that all of teleport/respawn functions call
mist.teleportToPoint = function(vars) -- main teleport function that all of teleport/respawn functions call
local point = vars.point
local gpName
@ -5372,9 +5372,9 @@ mist.teleportToPoint = function(vars) -- main teleport function that all of tele
end
return mist.dynAdd(newGroupData)
end
end
mist.respawnInZone = function(gpName, zone, disperse, maxDisp)
mist.respawnInZone = function(gpName, zone, disperse, maxDisp)
if type(gpName) == 'table' and gpName:getName() then
gpName = gpName:getName()
@ -5397,9 +5397,9 @@ mist.respawnInZone = function(gpName, zone, disperse, maxDisp)
vars.disperse = disperse
vars.maxDisp = maxDisp
return mist.teleportToPoint(vars)
end
end
mist.cloneInZone = function(gpName, zone, disperse, maxDisp)
mist.cloneInZone = function(gpName, zone, disperse, maxDisp)
if type(gpName) == 'table' then
gpName = gpName:getName()
@ -5420,9 +5420,9 @@ mist.cloneInZone = function(gpName, zone, disperse, maxDisp)
vars.disperse = disperse
vars.maxDisp = maxDisp
return mist.teleportToPoint(vars)
end
end
mist.teleportInZone = function(gpName, zone, disperse, maxDisp) -- groupName, zoneName or table of Zone Names, keepForm is a boolean
mist.teleportInZone = function(gpName, zone, disperse, maxDisp) -- groupName, zoneName or table of Zone Names, keepForm is a boolean
if type(gpName) == 'table' and gpName:getName() then
gpName = gpName:getName()
else
@ -5443,9 +5443,9 @@ mist.teleportInZone = function(gpName, zone, disperse, maxDisp) -- groupName, zo
vars.disperse = disperse
vars.maxDisp = maxDisp
return mist.teleportToPoint(vars)
end
end
mist.respawnGroup = function(gpName, task)
mist.respawnGroup = function(gpName, task)
local vars = {}
vars.gpName = gpName
vars.action = 'respawn'
@ -5458,9 +5458,9 @@ mist.respawnGroup = function(gpName, task)
mist.scheduleFunction(mist.goRoute, {newGroup, newRoute}, timer.getTime() + task)
end
return newGroup
end
end
mist.cloneGroup = function(gpName, task)
mist.cloneGroup = function(gpName, task)
local vars = {}
vars.gpName = gpName
vars.action = 'clone'
@ -5473,9 +5473,9 @@ mist.cloneGroup = function(gpName, task)
mist.scheduleFunction(mist.goRoute, {newGroup, newRoute}, timer.getTime() + task)
end
return newGroup
end
end
mist.teleportGroup = function(gpName, task)
mist.teleportGroup = function(gpName, task)
local vars = {}
vars.gpName = gpName
vars.action = 'teleport'
@ -5488,9 +5488,9 @@ mist.teleportGroup = function(gpName, task)
mist.scheduleFunction(mist.goRoute, {newGroup, newRoute}, timer.getTime() + task)
end
return newGroup
end
end
mist.spawnRandomizedGroup = function(groupName, vars) -- need to debug
mist.spawnRandomizedGroup = function(groupName, vars) -- need to debug
if Group.getByName(groupName) and Group.getByName(groupName):isExist() == true then
local gpData = mist.getGroupData(groupName)
gpData.units = mist.randomizeGroupOrder(gpData.units, vars)
@ -5500,9 +5500,9 @@ mist.spawnRandomizedGroup = function(groupName, vars) -- need to debug
end
return true
end
end
mist.randomizeNumTable = function(vars)
mist.randomizeNumTable = function(vars)
local newTable = {}
local excludeIndex = {}
@ -5573,9 +5573,9 @@ mist.randomizeNumTable = function(vars)
end
]]
return newTable
end
end
mist.randomizeGroupOrder = function(passedUnits, vars)
mist.randomizeGroupOrder = function(passedUnits, vars)
-- figure out what to exclude, and send data to other func
local units = passedUnits
@ -5640,9 +5640,9 @@ mist.randomizeGroupOrder = function(passedUnits, vars)
end
end
return newGroup
end
end
mist.ground.patrolRoute = function(vars)
mist.ground.patrolRoute = function(vars)
local tempRoute = {}
@ -5741,9 +5741,9 @@ mist.ground.patrolRoute = function(vars)
mist.goRoute(gpData, useRoute)
return
end
end
mist.ground.patrol = function(gpData, pType, form, speed)
mist.ground.patrol = function(gpData, pType, form, speed)
local vars = {}
if type(gpData) == 'table' and gpData:getName() then
@ -5759,10 +5759,10 @@ mist.ground.patrol = function(gpData, pType, form, speed)
mist.ground.patrolRoute(vars)
return
end
end
mist.random = function(firstNum, secondNum) -- no support for decimals
mist.random = function(firstNum, secondNum) -- no support for decimals
local lowNum, highNum
if not secondNum then
highNum = firstNum
@ -5786,11 +5786,11 @@ mist.random = function(firstNum, secondNum) -- no support for decimals
rtnVal = math.random(#choices) -- iterate a few times for giggles
end
return choices[rtnVal]
end
end
mist.stringMatch = function(s1, s2, bool)
mist.stringMatch = function(s1, s2, bool)
local exclude = {'%-', '%(', '%)', '%_', '%[', '%]', '%.', '%#', '% ', '%{', '%}', '%$', '%%', '%?', '%+', '%^'}
if type(s1) == 'string' and type(s2) == 'string' then
for i , str in pairs(exclude) do
@ -5811,16 +5811,16 @@ mist.stringMatch = function(s1, s2, bool)
env.info('mist.stringMatch; Either the first or second variable were not a string')
return false
end
end
end
mist.matchString = mist.stringMatch -- both commands work because order out type of I
mist.matchString = mist.stringMatch -- both commands work because order out type of I
mist.time = {}
-- returns a string for specified military time
-- theTime is optional
-- if present current time in mil time is returned
-- if number or table the time is converted into mil tim
mist.time.convertToSec = function(timeTable)
mist.time = {}
-- returns a string for specified military time
-- theTime is optional
-- if present current time in mil time is returned
-- if number or table the time is converted into mil tim
mist.time.convertToSec = function(timeTable)
timeInSec = 0
if timeTable and type(timeTable) == 'number' then
@ -5841,9 +5841,9 @@ mist.time.convertToSec = function(timeTable)
end
return timeInSec
end
end
mist.time.getDHMS = function(timeInSec)
mist.time.getDHMS = function(timeInSec)
if timeInSec and type(timeInSec) == 'number' then
local tbl = {d = 0, h = 0, m = 0, s = 0}
if timeInSec > 86400 then
@ -5870,9 +5870,9 @@ mist.time.getDHMS = function(timeInSec)
env.info('mist.time.getDHMS didnt recieve number')
return
end
end
end
mist.getMilString = function(theTime)
mist.getMilString = function(theTime)
local timeInSec = 0
if theTime then
timeInSec = mist.time.convertToSec(theTime)
@ -5883,9 +5883,9 @@ mist.getMilString = function(theTime)
local DHMS = mist.time.getDHMS(timeInSec)
return tostring(string.format('%02d', DHMS.h) .. string.format('%02d',DHMS.m))
end
end
mist.getClockString = function(theTime, hour)
mist.getClockString = function(theTime, hour)
local timeInSec = 0
if theTime then
timeInSec = mist.time.convertToSec(theTime)
@ -5903,13 +5903,13 @@ mist.getClockString = function(theTime, hour)
else
return tostring(string.format('%02d', DHMS.h) .. ':' .. string.format('%02d',DHMS.m) .. ':' .. string.format('%02d',DHMS.s))
end
end
end
-- returns the date in string format
-- both variables optional
-- first val returns with the month as a string
-- 2nd val defins if it should be written the American way or the wrong way.
mist.time.getDate = function(convert)
-- returns the date in string format
-- both variables optional
-- first val returns with the month as a string
-- 2nd val defins if it should be written the American way or the wrong way.
mist.time.getDate = function(convert)
local cal = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} -- starts at june. 2011. 2012 is leap year, sigh. add a simple check for leap year
local date = {}
date.d = 0
@ -5940,15 +5940,15 @@ mist.time.getDate = function(convert)
start = start + 86400
end
return date
end
end
mist.time.relativeToStart = function(time)
mist.time.relativeToStart = function(time)
if type(time) == 'number' then
return time - timer.getTime0()
end
end
end
mist.getDateString = function(rtnType, murica, oTime) -- returns date based on time
mist.getDateString = function(rtnType, murica, oTime) -- returns date based on time
local word = {'January', 'Feburary', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' } -- 'etc
local curTime = 0
if oTime then
@ -5971,9 +5971,9 @@ mist.getDateString = function(rtnType, murica, oTime) -- returns date based on t
return tostring(tbl.d .. '.' .. tbl.m .. '.' .. tbl.y)
end
end
end
--WIP
mist.time.milToGame = function(milString, rtnType) --converts a military time. By default returns the abosolute time that event would occur. With optional value it returns how many seconds from time of call till that time.
end
--WIP
mist.time.milToGame = function(milString, rtnType) --converts a military time. By default returns the abosolute time that event would occur. With optional value it returns how many seconds from time of call till that time.
local curTime = mist.utils.round(timer.getAbsTime())
local milTimeInSec = 0
@ -6001,18 +6001,18 @@ mist.time.milToGame = function(milString, rtnType) --converts a military time. B
milTimeInSec = milTimeInSec - startTime
end
return milTimeInSec
end
end
mist.DBs.const = {}
mist.DBs.const = {}
--[[
--[[
['LAND'] = 1,
['SHALLOW_WATER'] = 2,
['WATER'] = 3,
['ROAD'] = 4,
['RUNWAY'] = 5
]]
--[[mist.DBs.const.ME_SSE_terms = {
]]
--[[mist.DBs.const.ME_SSE_terms = {
['ME'] = {
['vehicle'] = {'GROUND', 'GROUND_UNIT'},
['plane'] = {'AIRPLANE'},
@ -6023,7 +6023,7 @@ mist.DBs.const = {}
}]]
mist.DBs.const.callsigns = { -- not accessible by SSE, must use static list :-/
mist.DBs.const.callsigns = { -- not accessible by SSE, must use static list :-/
['NATO'] = {
['rules'] = {
['groupLimit'] = 9,
@ -6091,13 +6091,13 @@ mist.DBs.const.callsigns = { -- not accessible by SSE, must use static list :-/
}
--[[ scope:
{
{
units = {...}, -- unit names.
coa = {...}, -- coa names
countries = {...}, -- country names
CA = {...}, -- looks just like coa.
unitTypes = { red = {}, blue = {}, all = {}, Russia = {},}
}
}
scope examples:
@ -6113,3 +6113,6 @@ scope examples:
end
mist.main()
env.info(('Mist version ' .. mist.majorVersion .. '.' .. mist.minorVersion .. '.' .. mist.build .. ' loaded.'))
-- vim: sw=2:ts=2