Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

[ADDED] Locating my units?

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> [ADDED] Locating my units? Page: [1] 2   next >   >>
Login
Message << Older Topic   Newer Topic >>
[ADDED] Locating my units? - 6/25/2019 9:39:08 AM   
goldfinger35


Posts: 142
Joined: 1/1/2009
Status: offline
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?


< Message edited by Dimitris -- 7/16/2019 11:51:08 AM >
Post #: 1
RE: Locating my units? - 6/25/2019 1:36:14 PM   
stilesw


Posts: 1497
Joined: 6/26/2014
From: Hansville, WA, USA
Status: offline
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

< Message edited by stilesw -- 6/25/2019 1:38:33 PM >


_____________________________

“There is no limit to what a man can do so long as he does not care a straw who gets the credit for it.”

Charles Edward Montague, English novelist and essayist
~Disenchantment, ch. 15 (1922)

(in reply to goldfinger35)
Post #: 2
RE: Locating my units? - 6/25/2019 3:22:21 PM   
goldfinger35


Posts: 142
Joined: 1/1/2009
Status: offline
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.

(in reply to stilesw)
Post #: 3
RE: Locating my units? - 6/26/2019 3:11:10 AM   
magi

 

Posts: 1529
Joined: 2/1/2014
Status: offline
i know..... life is hard.... that is why i want voice activated commands.......

(in reply to goldfinger35)
Post #: 4
RE: Locating my units? - 6/26/2019 3:13:16 AM   
magi

 

Posts: 1529
Joined: 2/1/2014
Status: offline
i think we should have a secretary.... and they could do these things for us.... and make us coffee....

(in reply to magi)
Post #: 5
RE: Locating my units? - 6/26/2019 11:59:12 AM   
goldfinger35


Posts: 142
Joined: 1/1/2009
Status: offline
That. Or a simple search function in order of battle.

(in reply to magi)
Post #: 6
RE: Locating my units? - 6/26/2019 12:55:32 PM   
spike2071

 

Posts: 1
Joined: 9/27/2017
Status: offline
I would love a Jump To Location ability from the message log directly. Similar to the pop up, but without the actual pop up.

(in reply to goldfinger35)
Post #: 7
RE: Locating my units? - 6/26/2019 3:12:59 PM   
stilesw


Posts: 1497
Joined: 6/26/2014
From: Hansville, WA, USA
Status: offline
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/).






Attachment (1)

(in reply to magi)
Post #: 8
RE: Locating my units? - 6/26/2019 5:55:34 PM   
gregb41352

 

Posts: 198
Joined: 10/5/2013
Status: offline
You can select a group and CTL+a number.
Then when you select that number, it will center on that group.

(in reply to stilesw)
Post #: 9
RE: Locating my units? - 6/26/2019 9:34:42 PM   
stilesw


Posts: 1497
Joined: 6/26/2014
From: Hansville, WA, USA
Status: offline
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

_____________________________

“There is no limit to what a man can do so long as he does not care a straw who gets the credit for it.”

Charles Edward Montague, English novelist and essayist
~Disenchantment, ch. 15 (1922)

(in reply to gregb41352)
Post #: 10
RE: Locating my units? - 6/26/2019 10:44:34 PM   
Gunner98

 

Posts: 5508
Joined: 4/29/2005
From: The Great White North!
Status: offline
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

_____________________________

Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/

(in reply to gregb41352)
Post #: 11
RE: Locating my units? - 6/27/2019 7:10:51 AM   
Dimitris

 

Posts: 13282
Joined: 7/31/2005
Status: offline

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.

_____________________________


(in reply to spike2071)
Post #: 12
RE: Locating my units? - 6/27/2019 10:23:28 AM   
nudn1k

 

Posts: 54
Joined: 7/18/2013
Status: offline
This is when things get interesting.

Nud.

(in reply to Dimitris)
Post #: 13
RE: Locating my units? - 6/27/2019 3:28:45 PM   
Dimitris

 

Posts: 13282
Joined: 7/31/2005
Status: offline

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.

_____________________________


(in reply to goldfinger35)
Post #: 14
RE: Locating my units? - 6/27/2019 6:04:03 PM   
goldfinger35


Posts: 142
Joined: 1/1/2009
Status: offline
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.

< Message edited by goldfinger35 -- 6/27/2019 6:07:43 PM >

(in reply to Dimitris)
Post #: 15
RE: Locating my units? - 6/27/2019 9:58:42 PM   
kevinkins


Posts: 2257
Joined: 3/8/2006
Status: offline
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.

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

Kevin

_____________________________

“The study of history lies at the foundation of all sound military conclusions and practice.”
― Alfred Thayer Mahan


(in reply to goldfinger35)
Post #: 16
RE: Locating my units? - 6/27/2019 10:32:21 PM   
lumiere

 

Posts: 99
Joined: 3/19/2019
From: Japan
Status: offline
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} )


_____________________________

"War claims its bitter, useless, sacrifice."

(in reply to kevinkins)
Post #: 17
RE: Locating my units? - 6/28/2019 9:55:08 PM   
LMychajluk

 

Posts: 126
Joined: 10/8/2017
Status: offline

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?

(in reply to lumiere)
Post #: 18
RE: Locating my units? - 6/28/2019 11:04:07 PM   
lumiere

 

Posts: 99
Joined: 3/19/2019
From: Japan
Status: offline
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.


< Message edited by lumiere -- 6/28/2019 11:55:24 PM >


_____________________________

"War claims its bitter, useless, sacrifice."

(in reply to LMychajluk)
Post #: 19
RE: Locating my units? - 6/28/2019 11:47:30 PM   
Rory Noonan

 

Posts: 2816
Joined: 12/18/2014
From: Brooklyn, NY
Status: offline

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!

_____________________________


(in reply to lumiere)
Post #: 20
RE: Locating my units? - 6/29/2019 12:18:48 AM   
Rory Noonan

 

Posts: 2816
Joined: 12/18/2014
From: Brooklyn, NY
Status: offline
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.


Attachment (1)

< Message edited by apache85 -- 6/29/2019 12:25:05 AM >


_____________________________


(in reply to Rory Noonan)
Post #: 21
RE: Locating my units? - 6/29/2019 12:27:38 AM   
magi

 

Posts: 1529
Joined: 2/1/2014
Status: offline
there are some really smart guys here......

(in reply to Rory Noonan)
Post #: 22
RE: Locating my units? - 6/29/2019 6:00:27 AM   
lumiere

 

Posts: 99
Joined: 3/19/2019
From: Japan
Status: offline

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.





_____________________________

"War claims its bitter, useless, sacrifice."

(in reply to Rory Noonan)
Post #: 23
RE: Locating my units? - 6/29/2019 9:08:57 AM   
goldfinger35


Posts: 142
Joined: 1/1/2009
Status: offline
lumiere and apache

(in reply to lumiere)
Post #: 24
RE: Locating my units? - 6/29/2019 12:40:28 PM   
Phoenix100

 

Posts: 2826
Joined: 9/28/2010
Status: offline
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.

(in reply to goldfinger35)
Post #: 25
RE: Locating my units? - 6/29/2019 12:54:18 PM   
Dimitris

 

Posts: 13282
Joined: 7/31/2005
Status: offline
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.


_____________________________


(in reply to Phoenix100)
Post #: 26
RE: Locating my units? - 6/29/2019 11:02:09 PM   
Whicker

 

Posts: 664
Joined: 6/20/2018
Status: offline
This works for contacts too - just change out lumiere's line 2 with:

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

(in reply to Dimitris)
Post #: 27
RE: Locating my units? - 6/30/2019 11:25:09 PM   
Whicker

 

Posts: 664
Joined: 6/20/2018
Status: offline
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::


< Message edited by Whicker -- 7/2/2019 1:52:35 AM >

(in reply to Whicker)
Post #: 28
RE: Locating my units? - 7/1/2019 8:37:05 AM   
michaelm75au


Posts: 13500
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
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.

_____________________________

Michael

(in reply to Whicker)
Post #: 29
RE: Locating my units? - 7/1/2019 6:43:24 PM   
Whicker

 

Posts: 664
Joined: 6/20/2018
Status: offline
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.

(in reply to michaelm75au)
Post #: 30
Page:   [1] 2   next >   >>
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> [ADDED] Locating my units? Page: [1] 2   next >   >>
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

3.328