mirror of
https://github.com/mrSkortch/MissionScriptingTools.git
synced 2025-08-15 10:47:23 +00:00
fixed indention
This commit is contained in:
parent
337d93b2aa
commit
33aa8ec3d5
423
mist.lua
423
mist.lua
@ -45,7 +45,6 @@ do -- the main scope
|
||||
mist.nextGroupId = 1
|
||||
mist.nextUnitId = 1
|
||||
|
||||
mist.addEventHandler(groupSpawned)
|
||||
|
||||
local function updateAliveUnits() -- coroutine function
|
||||
local lalive_units = mist.DBs.aliveUnits -- local references for faster execution
|
||||
@ -843,7 +842,7 @@ do -- the main scope
|
||||
idNum = idNum + 1
|
||||
handler.id = idNum
|
||||
handler.f = f
|
||||
function handler.onEvent(self, event)
|
||||
function handler:onEvent(event)
|
||||
self.f(event)
|
||||
end
|
||||
world.addEventHandler(handler)
|
||||
@ -1048,7 +1047,6 @@ do -- the main scope
|
||||
end
|
||||
|
||||
--[[ table attitude = getAttitude(string unitname) -- will work on any unit, even if not an aircraft.
|
||||
|
||||
attitude = {
|
||||
Heading = number, -- in radians, range of 0 to 2*pi, relative to true north
|
||||
Pitch = number, -- in radians, range of -pi/2 to pi/2
|
||||
@ -1251,7 +1249,6 @@ attitude = {
|
||||
end
|
||||
|
||||
function mist.makeUnitTable(tbl)
|
||||
|
||||
--[[
|
||||
Prefixes:
|
||||
"[-u]<unit name>" - subtract this unit if its in the table
|
||||
@ -1343,7 +1340,8 @@ Country names to be used in [c] and [-c] short-cuts:
|
||||
for unit_type, unit_type_tbl in pairs(country_table) do
|
||||
if type(unit_type_tbl) == 'table' then
|
||||
for group_ind, group_tbl in pairs(unit_type_tbl) do
|
||||
if type(group_tbl) == 'table' and group_tbl.groupName == unit:sub(4) then -- index 4 to end
|
||||
if type(group_tbl) == 'table' and group_tbl.groupName == unit:sub(4) then
|
||||
-- index 4 to end
|
||||
for unit_ind, unit in pairs(group_tbl.units) do
|
||||
units_by_name[unit.unitName] = true --add
|
||||
end
|
||||
@ -1359,7 +1357,8 @@ Country names to be used in [c] and [-c] short-cuts:
|
||||
for unit_type, unit_type_tbl in pairs(country_table) do
|
||||
if type(unit_type_tbl) == 'table' then
|
||||
for group_ind, group_tbl in pairs(unit_type_tbl) do
|
||||
if type(group_tbl) == 'table' and group_tbl.groupName == unit:sub(5) then -- index 5 to end
|
||||
if type(group_tbl) == 'table' and group_tbl.groupName == unit:sub(5) then
|
||||
-- index 5 to end
|
||||
for unit_ind, unit in pairs(group_tbl.units) do
|
||||
if units_by_name[unit.unitName] then
|
||||
units_by_name[unit.unitName] = nil --remove
|
||||
@ -2094,6 +2093,7 @@ function mist.getLeadingBRString(vars)
|
||||
end
|
||||
end
|
||||
|
||||
mist.addEventHandler(groupSpawned)
|
||||
end
|
||||
|
||||
do -- group functions scope
|
||||
@ -2720,124 +2720,6 @@ do -- group functions scope
|
||||
return newGroup
|
||||
end
|
||||
|
||||
function mist.ground.patrolRoute(vars)
|
||||
|
||||
|
||||
local tempRoute = {}
|
||||
local useRoute = {}
|
||||
local gpData = vars.gpData
|
||||
if type(gpData) == 'string' then
|
||||
gpData = Group.getByName(gpData)
|
||||
end
|
||||
|
||||
local useGroupRoute
|
||||
if not vars.useGroupRoute then
|
||||
useGroupRoute = vars.gpData
|
||||
else
|
||||
useGroupRoute = vars.useGroupRoute
|
||||
end
|
||||
local routeProvided = false
|
||||
if not vars.route then
|
||||
if useGroupRoute then
|
||||
tempRoute = mist.getGroupRoute(useGroupRoute)
|
||||
end
|
||||
else
|
||||
useRoute = vars.route
|
||||
local posStart = mist.getLeadPos(gpData)
|
||||
useRoute[1] = mist.ground.buildWP(posStart, useRoute[1].action, useRoute[1].speed)
|
||||
routeProvided = true
|
||||
end
|
||||
|
||||
|
||||
local overRideSpeed = vars.speed or 'default'
|
||||
local pType = vars.pType
|
||||
local offRoadForm = vars.offRoadForm or 'default'
|
||||
local onRoadForm = vars.onRoadForm or 'default'
|
||||
|
||||
if routeProvided == false and #tempRoute > 0 then
|
||||
local posStart = mist.getLeadPos(gpData)
|
||||
|
||||
|
||||
useRoute[#useRoute + 1] = mist.ground.buildWP(posStart, offRoadForm, overRideSpeed)
|
||||
for i = 1, #tempRoute do
|
||||
local tempForm = tempRoute[i].action
|
||||
local tempSpeed = tempRoute[i].speed
|
||||
|
||||
if offRoadForm == 'default' then
|
||||
tempForm = tempRoute[i].action
|
||||
end
|
||||
if onRoadForm == 'default' then
|
||||
onRoadForm = 'On Road'
|
||||
end
|
||||
if (string.lower(tempRoute[i].action) == 'on road' or string.lower(tempRoute[i].action) == 'onroad' or string.lower(tempRoute[i].action) == 'on_road') then
|
||||
tempForm = onRoadForm
|
||||
else
|
||||
tempForm = offRoadForm
|
||||
end
|
||||
|
||||
if type(overRideSpeed) == 'number' then
|
||||
tempSpeed = overRideSpeed
|
||||
end
|
||||
|
||||
|
||||
useRoute[#useRoute + 1] = mist.ground.buildWP(tempRoute[i], tempForm, tempSpeed)
|
||||
end
|
||||
|
||||
if pType and string.lower(pType) == 'doubleback' then
|
||||
local curRoute = mist.utils.deepCopy(useRoute)
|
||||
for i = #curRoute, 2, -1 do
|
||||
useRoute[#useRoute + 1] = mist.ground.buildWP(curRoute[i], curRoute[i].action, curRoute[i].speed)
|
||||
end
|
||||
end
|
||||
|
||||
useRoute[1].action = useRoute[#useRoute].action -- make it so the first WP matches the last WP
|
||||
end
|
||||
|
||||
local cTask3 = {}
|
||||
local newPatrol = {}
|
||||
newPatrol.route = useRoute
|
||||
newPatrol.gpData = gpData:getName()
|
||||
cTask3[#cTask3 + 1] = 'mist.ground.patrolRoute('
|
||||
cTask3[#cTask3 + 1] = mist.utils.oneLineSerialize(newPatrol)
|
||||
cTask3[#cTask3 + 1] = ')'
|
||||
cTask3 = table.concat(cTask3)
|
||||
local tempTask = {
|
||||
id = 'WrappedAction',
|
||||
params = {
|
||||
action = {
|
||||
id = 'Script',
|
||||
params = {
|
||||
command = cTask3,
|
||||
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
useRoute[#useRoute].task = tempTask
|
||||
mist.goRoute(gpData, useRoute)
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
function mist.ground.patrol(gpData, pType, form, speed)
|
||||
local vars = {}
|
||||
|
||||
if type(gpData) == 'table' and gpData:getName() then
|
||||
gpData = gpData:getName()
|
||||
end
|
||||
|
||||
vars.useGroupRoute = gpData
|
||||
vars.gpData = gpData
|
||||
vars.pType = pType
|
||||
vars.offRoadForm = form
|
||||
vars.speed = speed
|
||||
|
||||
mist.ground.patrolRoute(vars)
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
function mist.random(firstNum, secondNum) -- no support for decimals
|
||||
local lowNum, highNum
|
||||
@ -2890,93 +2772,7 @@ do -- group functions scope
|
||||
|
||||
mist.matchString = mist.stringMatch -- both commands work because order out type of I
|
||||
|
||||
mist.DBs.const = {}
|
||||
|
||||
--[[
|
||||
['LAND'] = 1,
|
||||
['SHALLOW_WATER'] = 2,
|
||||
['WATER'] = 3,
|
||||
['ROAD'] = 4,
|
||||
['RUNWAY'] = 5
|
||||
]]
|
||||
--[[mist.DBs.const.ME_SSE_terms = {
|
||||
['ME'] = {
|
||||
['vehicle'] = {'GROUND', 'GROUND_UNIT'},
|
||||
['plane'] = {'AIRPLANE'},
|
||||
},
|
||||
['SSE'] = {
|
||||
},
|
||||
|
||||
}]]
|
||||
|
||||
|
||||
mist.DBs.const.callsigns = { -- not accessible by SSE, must use static list :-/
|
||||
['NATO'] = {
|
||||
['rules'] = {
|
||||
['groupLimit'] = 9,
|
||||
},
|
||||
['AWACS'] = {
|
||||
['Overlord'] = 1,
|
||||
['Magic'] = 2,
|
||||
['Wizard'] = 3,
|
||||
['Focus'] = 4,
|
||||
['Darkstar'] = 5,
|
||||
},
|
||||
['TANKER'] = {
|
||||
['Texaco'] = 1,
|
||||
['Arco'] = 2,
|
||||
['Shell'] = 3,
|
||||
},
|
||||
['JTAC'] = {
|
||||
['Axeman'] = 1,
|
||||
['Darknight'] = 2,
|
||||
['Warrior'] = 3,
|
||||
['Pointer'] = 4,
|
||||
['Eyeball'] = 5,
|
||||
['Moonbeam'] = 6,
|
||||
['Whiplash'] = 7,
|
||||
['Finger'] = 8,
|
||||
['Pinpoint'] = 9,
|
||||
['Ferret'] = 10,
|
||||
['Shaba'] = 11,
|
||||
['Playboy'] = 12,
|
||||
['Hammer'] = 13,
|
||||
['Jaguar'] = 14,
|
||||
['Deathstar'] = 15,
|
||||
['Anvil'] = 16,
|
||||
['Firefly'] = 17,
|
||||
['Mantis'] = 18,
|
||||
['Badger'] = 19,
|
||||
},
|
||||
['aircraft'] = {
|
||||
['Enfield'] = 1,
|
||||
['Springfield'] = 2,
|
||||
['Uzi'] = 3,
|
||||
['Colt'] = 4,
|
||||
['Dodge'] = 5,
|
||||
['Ford'] = 6,
|
||||
['Chevy'] = 7,
|
||||
['Pontiac'] = 8,
|
||||
},
|
||||
|
||||
['unique'] = {
|
||||
['A10'] = {
|
||||
['Hawg'] = 9,
|
||||
['Boar'] = 10,
|
||||
['Pig'] = 11,
|
||||
['Tusk'] = 12,
|
||||
['rules'] = {
|
||||
['canUseAircraft'] = true,
|
||||
['appliesTo'] = {
|
||||
'A-10C',
|
||||
'A-10A',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
}
|
||||
--[[ scope:
|
||||
{
|
||||
units = {...}, -- unit names.
|
||||
@ -5116,6 +4912,75 @@ do -- mist.DBs scope
|
||||
|
||||
mist.DBs.removedAliveUnits = {} -- will be filled in by the "updateAliveUnits" coroutine in mist.main.
|
||||
|
||||
mist.DBs.const = {}
|
||||
|
||||
mist.DBs.const.callsigns = { -- not accessible by SSE, must use static list :-/
|
||||
['NATO'] = {
|
||||
['rules'] = {
|
||||
['groupLimit'] = 9,
|
||||
},
|
||||
['AWACS'] = {
|
||||
['Overlord'] = 1,
|
||||
['Magic'] = 2,
|
||||
['Wizard'] = 3,
|
||||
['Focus'] = 4,
|
||||
['Darkstar'] = 5,
|
||||
},
|
||||
['TANKER'] = {
|
||||
['Texaco'] = 1,
|
||||
['Arco'] = 2,
|
||||
['Shell'] = 3,
|
||||
},
|
||||
['JTAC'] = {
|
||||
['Axeman'] = 1,
|
||||
['Darknight'] = 2,
|
||||
['Warrior'] = 3,
|
||||
['Pointer'] = 4,
|
||||
['Eyeball'] = 5,
|
||||
['Moonbeam'] = 6,
|
||||
['Whiplash'] = 7,
|
||||
['Finger'] = 8,
|
||||
['Pinpoint'] = 9,
|
||||
['Ferret'] = 10,
|
||||
['Shaba'] = 11,
|
||||
['Playboy'] = 12,
|
||||
['Hammer'] = 13,
|
||||
['Jaguar'] = 14,
|
||||
['Deathstar'] = 15,
|
||||
['Anvil'] = 16,
|
||||
['Firefly'] = 17,
|
||||
['Mantis'] = 18,
|
||||
['Badger'] = 19,
|
||||
},
|
||||
['aircraft'] = {
|
||||
['Enfield'] = 1,
|
||||
['Springfield'] = 2,
|
||||
['Uzi'] = 3,
|
||||
['Colt'] = 4,
|
||||
['Dodge'] = 5,
|
||||
['Ford'] = 6,
|
||||
['Chevy'] = 7,
|
||||
['Pontiac'] = 8,
|
||||
},
|
||||
|
||||
['unique'] = {
|
||||
['A10'] = {
|
||||
['Hawg'] = 9,
|
||||
['Boar'] = 10,
|
||||
['Pig'] = 11,
|
||||
['Tusk'] = 12,
|
||||
['rules'] = {
|
||||
['canUseAircraft'] = true,
|
||||
['appliesTo'] = {
|
||||
'A-10C',
|
||||
'A-10A',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
}
|
||||
-- create mist.DBs.oldAliveUnits
|
||||
-- do
|
||||
-- local intermediate_alive_units = {} -- between 0 and 0.5 secs old
|
||||
@ -5614,7 +5479,124 @@ do -- group tasks scope
|
||||
end --for coa_name, coa_data in pairs(mission.coalition) do
|
||||
end
|
||||
|
||||
function mist.ground.buildPath() end -- ????
|
||||
-- function mist.ground.buildPath() end -- ????
|
||||
|
||||
function mist.ground.patrolRoute(vars)
|
||||
local tempRoute = {}
|
||||
local useRoute = {}
|
||||
local gpData = vars.gpData
|
||||
if type(gpData) == 'string' then
|
||||
gpData = Group.getByName(gpData)
|
||||
end
|
||||
|
||||
local useGroupRoute
|
||||
if not vars.useGroupRoute then
|
||||
useGroupRoute = vars.gpData
|
||||
else
|
||||
useGroupRoute = vars.useGroupRoute
|
||||
end
|
||||
local routeProvided = false
|
||||
if not vars.route then
|
||||
if useGroupRoute then
|
||||
tempRoute = mist.getGroupRoute(useGroupRoute)
|
||||
end
|
||||
else
|
||||
useRoute = vars.route
|
||||
local posStart = mist.getLeadPos(gpData)
|
||||
useRoute[1] = mist.ground.buildWP(posStart, useRoute[1].action, useRoute[1].speed)
|
||||
routeProvided = true
|
||||
end
|
||||
|
||||
|
||||
local overRideSpeed = vars.speed or 'default'
|
||||
local pType = vars.pType
|
||||
local offRoadForm = vars.offRoadForm or 'default'
|
||||
local onRoadForm = vars.onRoadForm or 'default'
|
||||
|
||||
if routeProvided == false and #tempRoute > 0 then
|
||||
local posStart = mist.getLeadPos(gpData)
|
||||
|
||||
|
||||
useRoute[#useRoute + 1] = mist.ground.buildWP(posStart, offRoadForm, overRideSpeed)
|
||||
for i = 1, #tempRoute do
|
||||
local tempForm = tempRoute[i].action
|
||||
local tempSpeed = tempRoute[i].speed
|
||||
|
||||
if offRoadForm == 'default' then
|
||||
tempForm = tempRoute[i].action
|
||||
end
|
||||
if onRoadForm == 'default' then
|
||||
onRoadForm = 'On Road'
|
||||
end
|
||||
if (string.lower(tempRoute[i].action) == 'on road' or string.lower(tempRoute[i].action) == 'onroad' or string.lower(tempRoute[i].action) == 'on_road') then
|
||||
tempForm = onRoadForm
|
||||
else
|
||||
tempForm = offRoadForm
|
||||
end
|
||||
|
||||
if type(overRideSpeed) == 'number' then
|
||||
tempSpeed = overRideSpeed
|
||||
end
|
||||
|
||||
|
||||
useRoute[#useRoute + 1] = mist.ground.buildWP(tempRoute[i], tempForm, tempSpeed)
|
||||
end
|
||||
|
||||
if pType and string.lower(pType) == 'doubleback' then
|
||||
local curRoute = mist.utils.deepCopy(useRoute)
|
||||
for i = #curRoute, 2, -1 do
|
||||
useRoute[#useRoute + 1] = mist.ground.buildWP(curRoute[i], curRoute[i].action, curRoute[i].speed)
|
||||
end
|
||||
end
|
||||
|
||||
useRoute[1].action = useRoute[#useRoute].action -- make it so the first WP matches the last WP
|
||||
end
|
||||
|
||||
local cTask3 = {}
|
||||
local newPatrol = {}
|
||||
newPatrol.route = useRoute
|
||||
newPatrol.gpData = gpData:getName()
|
||||
cTask3[#cTask3 + 1] = 'mist.ground.patrolRoute('
|
||||
cTask3[#cTask3 + 1] = mist.utils.oneLineSerialize(newPatrol)
|
||||
cTask3[#cTask3 + 1] = ')'
|
||||
cTask3 = table.concat(cTask3)
|
||||
local tempTask = {
|
||||
id = 'WrappedAction',
|
||||
params = {
|
||||
action = {
|
||||
id = 'Script',
|
||||
params = {
|
||||
command = cTask3,
|
||||
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
useRoute[#useRoute].task = tempTask
|
||||
mist.goRoute(gpData, useRoute)
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
function mist.ground.patrol(gpData, pType, form, speed)
|
||||
local vars = {}
|
||||
|
||||
if type(gpData) == 'table' and gpData:getName() then
|
||||
gpData = gpData:getName()
|
||||
end
|
||||
|
||||
vars.useGroupRoute = gpData
|
||||
vars.gpData = gpData
|
||||
vars.pType = pType
|
||||
vars.offRoadForm = form
|
||||
vars.speed = speed
|
||||
|
||||
mist.ground.patrolRoute(vars)
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
-- No longer accepts path
|
||||
function mist.ground.buildWP(point, overRideForm, overRideSpeed)
|
||||
@ -6043,7 +6025,8 @@ vars.msgFor - scope
|
||||
if text then
|
||||
if string.find(text, '%%s') then -- look for %s
|
||||
newText = string.format(text, s) -- insert the coordinates into the message
|
||||
else -- else, just append to the end.
|
||||
else
|
||||
-- just append to the end.
|
||||
newText = text .. s
|
||||
end
|
||||
else
|
||||
@ -6077,7 +6060,8 @@ function mist.msgLL(vars)
|
||||
if text then
|
||||
if string.find(text, '%%s') then -- look for %s
|
||||
newText = string.format(text, s) -- insert the coordinates into the message
|
||||
else -- else, just append to the end.
|
||||
else
|
||||
-- just append to the end.
|
||||
newText = text .. s
|
||||
end
|
||||
else
|
||||
@ -6115,7 +6099,8 @@ function mist.msgBR(vars)
|
||||
if text then
|
||||
if string.find(text, '%%s') then -- look for %s
|
||||
newText = string.format(text, s) -- insert the coordinates into the message
|
||||
else -- else, just append to the end.
|
||||
else
|
||||
-- just append to the end.
|
||||
newText = text .. s
|
||||
end
|
||||
else
|
||||
@ -6194,7 +6179,8 @@ function mist.msgLeadingMGRS(vars)
|
||||
if text then
|
||||
if string.find(text, '%%s') then -- look for %s
|
||||
newText = string.format(text, s) -- insert the coordinates into the message
|
||||
else -- else, just append to the end.
|
||||
else
|
||||
-- just append to the end.
|
||||
newText = text .. s
|
||||
end
|
||||
else
|
||||
@ -6238,7 +6224,8 @@ function mist.msgLeadingLL(vars)
|
||||
if text then
|
||||
if string.find(text, '%%s') then -- look for %s
|
||||
newText = string.format(text, s) -- insert the coordinates into the message
|
||||
else -- else, just append to the end.
|
||||
else
|
||||
-- just append to the end.
|
||||
newText = text .. s
|
||||
end
|
||||
else
|
||||
@ -6283,7 +6270,8 @@ function mist.msgLeadingBR(vars)
|
||||
if text then
|
||||
if string.find(text, '%%s') then -- look for %s
|
||||
newText = string.format(text, s) -- insert the coordinates into the message
|
||||
else -- else, just append to the end.
|
||||
else
|
||||
-- just append to the end.
|
||||
newText = text .. s
|
||||
end
|
||||
else
|
||||
@ -6299,7 +6287,6 @@ end
|
||||
end
|
||||
|
||||
do -- mist unitID funcs
|
||||
|
||||
for id, idData in pairs(mist.DBs.unitsById) do
|
||||
if idData.unitId > mist.nextUnitId then
|
||||
mist.nextUnitId = mist.utils.deepCopy(idData.unitId)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user