mirror of
https://github.com/akaAgar/the-universal-mission-for-dcs-world.git
synced 2025-11-25 19:31:01 +00:00
Initial commit
This commit is contained in:
29
Script/Library/ObjectNames.lua
Normal file
29
Script/Library/ObjectNames.lua
Normal file
@@ -0,0 +1,29 @@
|
||||
Library.objectNames = {}
|
||||
|
||||
do
|
||||
local namesTable = {
|
||||
["F-16C_50"] = "F-16C",
|
||||
["FA-18C_hornet"] = "F/A-18C",
|
||||
["speedboat"] = "speedboat"
|
||||
}
|
||||
|
||||
function Library.objectNames.get(obj)
|
||||
if not obj then return "nothing" end
|
||||
|
||||
-- First, try to find a custom name in the names table
|
||||
local typeName = obj:getTypeName()
|
||||
if typeName and namesTable[typeName] then
|
||||
return namesTable[typeName]
|
||||
end
|
||||
|
||||
-- Else, try to find a display name in the description
|
||||
local desc = obj:getDesc()
|
||||
if desc and desc.DisplayName then
|
||||
return desc.DisplayName
|
||||
end
|
||||
|
||||
-- If nothing else was found, return the internal typename
|
||||
if not typeName then return "unknown" end
|
||||
return typeName
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user