Jump to content

Recommended Posts

Posted

------------------------------
-- get id
------------------------------
function get_id(groupName)
   local i,j,k
   if env.mission.coalition then
       for coa,coaTable in pairs(env.mission.coalition) do
           if type(coaTable) == 'table' and coaTable.country then
               for i=1,#coaTable.country do
                   local country = coaTable.country[i]
                   for uType,uTable in pairs(country) do
                       if uType == 'helicopter' or uType == 'ship' or uType == 'vehicle' or uType == 'plane' then
                           if type(uTable)=='table' and uTable.group then
                               for j=1,#uTable.group do
                                   local group = uTable.group[j]
                                   if group.units then
                                       for k=1,#group.units do
                                           local unit = group.units[k]					
										if group.name and group.name == groupName then
                                               return unit.unitId
                                           end											 
                                       end
                                   end
                               end
                           end
                       end
                   end
               end
           end
       end
   end
   return nil
end
------------------------------
-- get country
------------------------------
function getCountry(groupName)
   local i,j,k
   if env.mission.coalition then
       for coa,coaTable in pairs(env.mission.coalition) do
           if type(coaTable) == 'table' and coaTable.country then
               for i=1,#coaTable.country do
                   local country = coaTable.country[i]
                   for uType,uTable in pairs(country) do
                       if uType == 'helicopter' or uType == 'ship' or uType == 'vehicle' or uType == 'plane' then
                           if type(uTable)=='table' and uTable.group then
                               for j=1,#uTable.group do
                                   local group = uTable.group[j]
                                   if group.units then
                                       for k=1,#group.units do
                                           local unit = group.units[k]
                                           -- if unit.name and unit.name == groupName then
                                               -- return group.name--country.name
                                           -- end
										 if group.name and group.name == groupName then
                                               return country.name
                                            end
                                       end
                                   end
                               end
                           end
                       end
                   end
               end
           end
       end
   end
   return nil
end

 

I 126 in the version I was using these functions and can help me to use them with the version 153

  • Like 1

====VIAF====

Spinter 155° "Pantere Nere"

 

TsSimComms

 

My Site aiupgrade.net

 

 

 

Posted

Group and unit names are now saved in the mission file as "dict keys" for localization purposes. You can use env.getValueDictByKey() to return the actual value. Basically anything that can be used for localization in multiple languages is given a unique value. Within the mission is a lookup table in different languages that defines what the players sees. As a result you don't need to have 6 different versions of the mission created for the different languages.

 

if group.name and env.getValueDictByKey(group.name) == groupName then

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...