[ADDED] Locating my units? (Full Version)

All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series



Message


goldfinger35 -> [ADDED] Locating my units? (6/25/2019 9:39:08 AM)

Is there an easy way of locating my specific unit? I have hundreds of units (planes) all over map and I get a message on message log that plane STRIKER ONE is doing something. I want to locate that plane on the map to manage it manually but it is not an easy task. Order of battle helps slightly but since there is no filter option, I still have to go through huge list of planes to locate STRIKER ONE.
Is there an easier way?




stilesw -> RE: Locating my units? (6/25/2019 1:36:14 PM)

goldfinger35,

You can press "O" to open the Order of Battle window. Then find the unit you are looking for and select it with the left mouse key. The unit will then be selected and centered on the map. You still have to search for the unit in the OOB screen but at least it is sorted alphabetically.

-Wayne




goldfinger35 -> RE: Locating my units? (6/25/2019 3:22:21 PM)

Wayne, thanks but I know about Order of battle and it still takes a LOT of time to locate the unit because planes are sorted by
1.home base
2.unit name.




magi -> RE: Locating my units? (6/26/2019 3:11:10 AM)

i know..... life is hard.... that is why i want voice activated commands.......




magi -> RE: Locating my units? (6/26/2019 3:13:16 AM)

i think we should have a secretary.... and they could do these things for us.... and make us coffee....




goldfinger35 -> RE: Locating my units? (6/26/2019 11:59:12 AM)

That. Or a simple search function in order of battle.




spike2071 -> RE: Locating my units? (6/26/2019 12:55:32 PM)

I would love a Jump To Location ability from the message log directly. Similar to the pop up, but without the actual pop up.




stilesw -> RE: Locating my units? (6/26/2019 3:12:59 PM)

WTF Dennis....

You must have purchased a corrupted version of CMANO!!! Mine came with an administrative assistant AND the built in mental control option much Clint Eastwood demonstrated in the movie Firefox.

Unfortunately, you have to think the commands in Klingon as Clint had to think in Russian to get it to work. But for a small additional cost you can get the Klingon translation interface.

qaStaHvIS yIn 'ej jagh jey. (https://www.translator.eu/english/klingon/translation/).



[image]local://upfiles/49187/60D0A1474AA14BECAE3408F4E779C1AB.jpg[/image]




gregb41352 -> RE: Locating my units? (6/26/2019 5:55:34 PM)

You can select a group and CTL+a number.
Then when you select that number, it will center on that group.




stilesw -> RE: Locating my units? (6/26/2019 9:34:42 PM)

quote:

You can select a group and CTL+a number.
Then when you select that number, it will center on that group.


Greg,

I did not know that. Many thanks for the tip.

-Wayne Stiles




Gunner98 -> RE: Locating my units? (6/26/2019 10:44:34 PM)

quote:

You can select a group and CTL+a number


A very handy feature, you can save up to 9 slots, they show up in the menu bar as well but just hitting the # is faster.

B




Dimitris -> RE: Locating my units? (6/27/2019 7:10:51 AM)


quote:

ORIGINAL: spike2071
I would love a Jump To Location ability from the message log directly. Similar to the pop up, but without the actual pop up.


Stick around.




nudn1k -> RE: Locating my units? (6/27/2019 10:23:28 AM)

This is when things get interesting.

Nud.




Dimitris -> RE: Locating my units? (6/27/2019 3:28:45 PM)


quote:

ORIGINAL: goldfinger35
That. Or a simple search function in order of battle.


How do you envision the use case for this?

Asking because we had considered a filter in the Orbat window at one point, but it proved quite tricky to make the flow work.




goldfinger35 -> RE: Locating my units? (6/27/2019 6:04:03 PM)

quote:

ORIGINAL: Dimitris


quote:

ORIGINAL: goldfinger35
That. Or a simple search function in order of battle.


How do you envision the use case for this?

Asking because we had considered a filter in the Orbat window at one point, but it proved quite tricky to make the flow work.


It would be used when you neeed to locate unit(s) in large scenarios with many units (mostly planes).
Maybe add a filed on bottom of order of battle menu (below side proficiency) which would work similar to "Filter by class" option in editor when adding a new unit, but this would filter by callsign or type of unit.
But if you are working on the above mentioned option to "Jump To Location ability from the message log directly" that would be even better.




kevinkins -> RE: Locating my units? (6/27/2019 9:58:42 PM)

Hire a former Google summer intern for a week. Case closed. If they can code and grab all our personal data and locate where we are at any given second, then finding my F-16 named Saturn5 on the map should not be too difficult.[8D] [:D]

Honestly, I don't think the OOB tree is that bad.

Kevin




lumiere -> RE: Locating my units? (6/27/2019 10:32:21 PM)

Simple location finder Lua (player side-only now)

local name = ScenEdit_InputBox('Enter the unit name\nyou want to find its location.')

local unit = ScenEdit_GetUnit({side=ScenEdit_PlayerSide(), name=name})

ScenEdit_SpecialMessage(ScenEdit_PlayerSide(),"" .. name .. ' is here. (Click "Jump to Location" button below) ', {lat=unit.latitude,lon=unit.longitude} )




LMychajluk -> RE: Locating my units? (6/28/2019 9:55:08 PM)


quote:

ORIGINAL: lumiere

Simple location finder Lua (player side-only now)

local name = ScenEdit_InputBox('Enter the unit name\nyou want to find its location.')

local unit = ScenEdit_GetUnit({side=ScenEdit_PlayerSide(), name=name})

ScenEdit_SpecialMessage(ScenEdit_PlayerSide(),"" .. name .. ' is here. (Click "Jump to Location" button below) ', {lat=unit.latitude,lon=unit.longitude} )


quote:

Simple location finder Lua (player side-only now)

local name = ScenEdit_InputBox('Enter the unit name\nyou want to find its location.')

local unit = ScenEdit_GetUnit({side=ScenEdit_PlayerSide(), name=name})

ScenEdit_SpecialMessage(ScenEdit_PlayerSide(),"" .. name .. ' is here. (Click "Jump to Location" button below) ', {lat=unit.latitude,lon=unit.longitude} )


So while I'm playing a scenario and need to find a unit, how would I use this?




lumiere -> RE: Locating my units? (6/28/2019 11:04:07 PM)

OK.
(1) Play in Scenario Editor (sorry but Lua Console is Scenario Editor mode only) and Open Lua Console (Ctrl + Shift + C).
(2) Copy & Paste the script to console and click "RUN" button.
(3) Input box will shown, enter unit name you want to know the location.
(4) If unit name really exists, special message will shown and you can jump by "Jump to Location" button.
else "Cannot find the unit" message box.




Rory Noonan -> RE: Locating my units? (6/28/2019 11:47:30 PM)


quote:

ORIGINAL: lumiere

Simple location finder Lua (player side-only now)

local name = ScenEdit_InputBox('Enter the unit name\nyou want to find its location.')

local unit = ScenEdit_GetUnit({side=ScenEdit_PlayerSide(), name=name})

ScenEdit_SpecialMessage(ScenEdit_PlayerSide(),"" .. name .. ' is here. (Click "Jump to Location" button below) ', {lat=unit.latitude,lon=unit.longitude} )



Nice one!




Rory Noonan -> RE: Locating my units? (6/29/2019 12:18:48 AM)

Just to expand on lumiere's excellent example above, here is a special action that will match partial names and allows retries if the unit name isn't correct or produces multiple results:

quote:


local function Round(num, numDecimalPlaces)
local mult = 10^(numDecimalPlaces or 0)
return math.floor(num * mult + 0.5) / mult
end

local function ConvertDecimalPositionToDegrees(latitude,longitude)
local latitidePrefix, longitudePrefix
if latitude > 0 then
latitidePrefix = "N"
else
latitidePrefix = "S"
latitude = latitude*-1
end

local latitudeDegrees = math.floor(latitude)
local latitudeMinutes = math.floor((latitude - latitudeDegrees)*60)
local latitudeSeconds = (((latitude-latitudeDegrees)*60) - latitudeMinutes)*60
latitudeSeconds = Round(latitudeSeconds, 0)

if longitude > 0 then
longitudePrefix = "E"
else
longitudePrefix = "W"
longitude = longitude*-1
end

local longitudeDegrees = math.floor(longitude)
local longitudeMinutes = math.floor((longitude - longitudeDegrees)*60)
local longitudeSeconds = (((longitude-longitudeDegrees)*60) - longitudeMinutes)*60
longitudeSeconds = Round(longitudeSeconds, 0)

local result = (latitidePrefix..latitudeDegrees .. "°" .. latitudeMinutes .. "'" .. latitudeSeconds .. '", '..
longitudePrefix..longitudeDegrees .. "°" .. longitudeMinutes .. "'" .. longitudeSeconds .. '"')
return result
end

local function GeneratePlayerSideUnitDataTable()
local result, unitList = {}, VP_GetSide({side='playerside'}).units
for k,v in ipairs (unitList) do
local unit = ScenEdit_GetUnit({guid=v.guid})
table.insert(result, unit)
end
return result
end

::retry::

local sideUnits = GeneratePlayerSideUnitDataTable()

local userInput = ScenEdit_InputBox('Which unit do you want to locate? \n\nType any unique part of the unit name, e.g. 73, col or collins will match SSG 73 Collins; case insensitive.')
userInput = string.lower(userInput)
if userInput == '' then goto finish end

local matchCount, matchedUnit = 0, nil

for k,v in ipairs (sideUnits) do
match = string.find(string.lower(v.name),userInput)
if match ~= nil then
matchedUnit = ScenEdit_GetUnit({guid=v.guid})
matchCount = matchCount + 1
end
end

local choice, retry = nil, nil

if matchCount == 0 then

retry = ScenEdit_MsgBox('No matches found. \n\nTry typing a more specific part of the unit name. Case is not important, but at least some of the name needs to be a match! \n\nDo you want to try again?',4)

if retry == 'Yes' then goto retry end

elseif matchCount == 1 then

choice = ScenEdit_MsgBox("Is the "..matchedUnit.type..", "..matchedUnit.classname.." '"..matchedUnit.name.."' the unit you're looking for ?",4)

elseif matchCount > 1 then

retry = ScenEdit_MsgBox('Multiple matches found. \n\nTry typing a more specific part of the unit name. Case is not important, but at least some of the name needs to be a match! \n\nDo you want to try again?',4)

if retry == 'Yes' then goto retry end

end

if choice == 'Yes' then
local unit = ScenEdit_GetUnit({guid=matchedUnit.guid})
local unitPositionDescription = ConvertDecimalPositionToDegrees(unit.latitude,unit.longitude)
ScenEdit_SpecialMessage('playerside',unit.name..' is currently located at '..unitPositionDescription..'<BR><BR> Click "Jump to Location" to go to this position.',{latitude=unit.latitude,longitude=unit.longitude})
end

::finish::



Also attached is a demo .scen file and a separate .lua file with the above code nicely formatted.




magi -> RE: Locating my units? (6/29/2019 12:27:38 AM)

there are some really smart guys here......




lumiere -> RE: Locating my units? (6/29/2019 6:00:27 AM)


quote:

ORIGINAL: apache85

Just to expand on lumiere's excellent example above, here is a special action that will match partial names and allows retries if the unit name isn't correct or produces multiple results:

quote:


local function Round(num, numDecimalPlaces)
local mult = 10^(numDecimalPlaces or 0)
return math.floor(num * mult + 0.5) / mult
end

local function ConvertDecimalPositionToDegrees(latitude,longitude)
local latitidePrefix, longitudePrefix
if latitude > 0 then
latitidePrefix = "N"
else
latitidePrefix = "S"
latitude = latitude*-1
end

local latitudeDegrees = math.floor(latitude)
local latitudeMinutes = math.floor((latitude - latitudeDegrees)*60)
local latitudeSeconds = (((latitude-latitudeDegrees)*60) - latitudeMinutes)*60
latitudeSeconds = Round(latitudeSeconds, 0)

if longitude > 0 then
longitudePrefix = "E"
else
longitudePrefix = "W"
longitude = longitude*-1
end

local longitudeDegrees = math.floor(longitude)
local longitudeMinutes = math.floor((longitude - longitudeDegrees)*60)
local longitudeSeconds = (((longitude-longitudeDegrees)*60) - longitudeMinutes)*60
longitudeSeconds = Round(longitudeSeconds, 0)

local result = (latitidePrefix..latitudeDegrees .. "°" .. latitudeMinutes .. "'" .. latitudeSeconds .. '", '..
longitudePrefix..longitudeDegrees .. "°" .. longitudeMinutes .. "'" .. longitudeSeconds .. '"')
return result
end

local function GeneratePlayerSideUnitDataTable()
local result, unitList = {}, VP_GetSide({side='playerside'}).units
for k,v in ipairs (unitList) do
local unit = ScenEdit_GetUnit({guid=v.guid})
table.insert(result, unit)
end
return result
end

::retry::

local sideUnits = GeneratePlayerSideUnitDataTable()

local userInput = ScenEdit_InputBox('Which unit do you want to locate? \n\nType any unique part of the unit name, e.g. 73, col or collins will match SSG 73 Collins; case insensitive.')
userInput = string.lower(userInput)
if userInput == '' then goto finish end

local matchCount, matchedUnit = 0, nil

for k,v in ipairs (sideUnits) do
match = string.find(string.lower(v.name),userInput)
if match ~= nil then
matchedUnit = ScenEdit_GetUnit({guid=v.guid})
matchCount = matchCount + 1
end
end

local choice, retry = nil, nil

if matchCount == 0 then

retry = ScenEdit_MsgBox('No matches found. \n\nTry typing a more specific part of the unit name. Case is not important, but at least some of the name needs to be a match! \n\nDo you want to try again?',4)

if retry == 'Yes' then goto retry end

elseif matchCount == 1 then

choice = ScenEdit_MsgBox("Is the "..matchedUnit.type..", "..matchedUnit.classname.." '"..matchedUnit.name.."' the unit you're looking for ?",4)

elseif matchCount > 1 then

retry = ScenEdit_MsgBox('Multiple matches found. \n\nTry typing a more specific part of the unit name. Case is not important, but at least some of the name needs to be a match! \n\nDo you want to try again?',4)

if retry == 'Yes' then goto retry end

end

if choice == 'Yes' then
local unit = ScenEdit_GetUnit({guid=matchedUnit.guid})
local unitPositionDescription = ConvertDecimalPositionToDegrees(unit.latitude,unit.longitude)
ScenEdit_SpecialMessage('playerside',unit.name..' is currently located at '..unitPositionDescription..'<BR><BR> Click "Jump to Location" to go to this position.',{latitude=unit.latitude,longitude=unit.longitude})
end

::finish::



Also attached is a demo .scen file and a separate .lua file with the above code nicely formatted.



[X(] [:)] [sm=00000947.gif] [sm=happy0065.gif]




goldfinger35 -> RE: Locating my units? (6/29/2019 9:08:57 AM)

lumiere and apache [&o]




Phoenix100 -> RE: Locating my units? (6/29/2019 12:40:28 PM)

I do remember asking for this - click unit in message log to centre in main map - around 4 years ago. Is it coming anytime soon, then, Dimitris? That would be a really cool addition.




Dimitris -> RE: Locating my units? (6/29/2019 12:54:18 PM)

quote:

ORIGINAL: Phoenix100
I do remember asking for this - click unit in message log to centre in main map - around 4 years ago. Is it coming anytime soon, then, Dimitris? That would be a really cool addition.


I wish I could say more right now.

Not long yet, though.




Whicker -> RE: Locating my units? (6/29/2019 11:02:09 PM)

This works for contacts too - just change out lumiere's line 2 with:

local unit = ScenEdit_GetContact({side=ScenEdit_PlayerSide(), name=name})




Whicker -> RE: Locating my units? (6/30/2019 11:25:09 PM)

modified to work with contacts - though the contact name must be an exact match - you can just copy it from the log (before running the action). Added trim function so if you copy a space at the end it will still match (only trimming on contacts). Can't do partial match on contacts I don't think since they all seem to start at #10 - so if you put in 13 there would likely be multiple #13s.

quote:


local function sanitize(str)
local s = string.gsub(str, "[%(%)%.%+%-%*%?%[%]%^%$%%]", "%%%1")
return s
end

local function trim(s)
-- from PiL2 20.4
return (s:gsub("^%s*(.-)%s*$", "%1"))
end

local function Round(num, numDecimalPlaces)
local mult = 10^(numDecimalPlaces or 0)
return math.floor(num * mult + 0.5) / mult
end

local function ConvertDecimalPositionToDegrees(latitude,longitude)
local latitidePrefix, longitudePrefix
if latitude > 0 then
latitidePrefix = "N"
else
latitidePrefix = "S"
latitude = latitude*-1
end --if
local latitudeDegrees = math.floor(latitude)
local latitudeMinutes = math.floor((latitude - latitudeDegrees)*60)
local latitudeSeconds = (((latitude-latitudeDegrees)*60) - latitudeMinutes)*60
latitudeSeconds = Round(latitudeSeconds, 0)
if longitude > 0 then
longitudePrefix = "E"
else
longitudePrefix = "W"
longitude = longitude*-1
end --if
local longitudeDegrees = math.floor(longitude)
local longitudeMinutes = math.floor((longitude - longitudeDegrees)*60)
local longitudeSeconds = (((longitude-longitudeDegrees)*60) - longitudeMinutes)*60
longitudeSeconds = Round(longitudeSeconds, 0)
local result = (latitidePrefix..latitudeDegrees .. "°" .. latitudeMinutes .. "'" .. latitudeSeconds .. '", '..
longitudePrefix..longitudeDegrees .. "°" .. longitudeMinutes .. "'" .. longitudeSeconds .. '"')
return result
end --end function

local function GeneratePlayerSideUnitDataTable()
local result, unitList = {}, VP_GetSide({side='playerside'}).units
for k,v in ipairs (unitList) do
local unit = ScenEdit_GetUnit({guid=v.guid})
table.insert(result, unit)
end
return result
end

local function unitFound(u)
local unitPositionDescription = ConvertDecimalPositionToDegrees(u.latitude,u.longitude)
ScenEdit_SpecialMessage('playerside',u.name..' is currently located at '..unitPositionDescription..'<BR><BR> Click "Jump to Location" to go to this position.',{latitude=u.latitude,longitude=u.longitude})
end --function

local function listOfMatches(tableList)
local list = ''
for k,v in ipairs(tableList) do
list = list.. '\n' ..v
end
return list
end --function

::retry::

local userInput = ScenEdit_InputBox('Which unit do you want to locate? \n\nType any unique part of the unit name, e.g. 73, col or collins will match SSG 73 Collins; case insensitive.')
userInput = string.lower(userInput)
if userInput == '' then goto finish end --nothing entered

userInputTrimmed= trim(userInput) --trim only is doing exact comparison, spaces may be valuable in fuzzy search
-- check units for exact match, needed because fuzzy search returns both unit 1 and unit 11
local exactUnit = ScenEdit_GetUnit({side=ScenEdit_PlayerSide(), name=userInputTrimmed})
if exactUnit ~= nil then
unitFound(exactUnit)
return
end
--check contacts for exact match
local exactContact = ScenEdit_GetContact({side=ScenEdit_PlayerSide(), name=userInputTrimmed})
if exactContact ~= nil then
unitFound(exactContact)
return
end

local sideUnits = GeneratePlayerSideUnitDataTable()
local matchCount, matchedUnit, matches = 0, nil, {}
userInput = sanitize(userInput)

for k,v in ipairs (sideUnits) do
match = string.find(string.lower(v.name),userInput)
if match ~= nil then
matchedUnit = ScenEdit_GetUnit({guid=v.guid})
matchCount = matchCount + 1
table.insert(matches, matchedUnit.name)
end
end

local choice, retry = nil, nil

if matchCount == 0 then

retry = ScenEdit_MsgBox('No matches found. \n\nTry typing a more specific part of the unit name. Case is not important, but at least some of the name needs to be a match! \n\nDo you want to try again?',4)

if retry == 'Yes' then goto retry end

elseif matchCount == 1 then
choice = ScenEdit_MsgBox("Is the "..matchedUnit.type..", "..matchedUnit.classname.." '"..matchedUnit.name.."' the unit you're looking for ?",4)

elseif matchCount > 1 then
local possibleMatches = listOfMatches(matches)
retry = ScenEdit_MsgBox('Multiple matches found. \n\nTry typing a more specific part of the unit name. Case is not important, but at least some of the name needs to be a match! \nPossible Matches:\n'..possibleMatches..'\n\nDo you want to try again?',4)

if retry == 'Yes' then goto retry end
end

if choice == 'Yes' then
local unit = ScenEdit_GetUnit({guid=matchedUnit.guid})
unitFound(unit)
end

::finish::




michaelm75au -> RE: Locating my units? (7/1/2019 8:37:05 AM)

Contact number should be unique for a side; not sure if the uniqueness is overall or just for the contact type (e.g. SKUNK #1234, VAMPIRE #1234). I had a feeling it was side based so you shouldn't get SKUNK #1234 and VAMPIRE #1234 at same time for a single side.




Whicker -> RE: Locating my units? (7/1/2019 6:43:24 PM)

I edited my code above to fix some things:

- first it tries to match an exact unit name, without it you cannot get a result with units named 'Flanker #1' and 'Flanker #11' as the the string.match method can't tell the difference
- next it tries to match an exact contact name - that is the only try for contacts, string.match would find too many units as it would match anything with 21 in it*
- added the list of possible matches to the message that says multiple matches found
- units with a special character in the name like a hyphen would not match anything cause special characters need to be escaped (added sanitize function)

* I wonder if the use case for searching for a contact would always be to find the most recent contact, which would be a larger number than existing contacts so maybe the string match would work if the contact was #123 and there was no 1123 or 1230. Even then you would still have to be careful as you would need to combine the results of units and contacts in order to know which one the user is looking for. '318' could be a contact or it could be unit '318 LR ASW Regt #2'.

I tested this a bit with one of gunners large scenarios and it seemed to perform well, I was worried loading all of a sides units into a table would eat up all the memory but it didn't. Last time I did something like this it did so maybe something was fixed.

this is a really neat lua example for anyone looking for a fairly advanced but doable code sample.




Page: [1] 2   next >   >>

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
1.828125