Difference between revisions of "MIST dynAdd"

From DCS World Wiki - Hoggitworld.com
(Created page with "{{Mission Scripting |fName= mist.dynAdd |vNum = Mist 3.0 |desc= With valid data, this function will dynamically spawn a group consisting of unitsTable within the categoryNa...")
 
 
Line 5: Line 5:
 
|vNum = Mist 3.0
 
|vNum = Mist 3.0
  
|desc= With valid data, this function will dynamically spawn a group consisting of unitsTable within the categoryName for countryName using the built in scripting function coalition.addGroup.
+
|desc= With valid data, this function will dynamically spawn a group consisting of unitsTable within the categoryName for countryName using the built in scripting function coalition.addGroup. See examples for different group types here:
 +
 
 +
    [[DCS_exam_group_ground|Ground Group]]
 +
    [[DCS_exam_group_ship|Ship Group]] 
 +
    [[DCS_exam_group_heli|Helicopter Group]]
 +
    [[DCS_exam_group_plane|Plane Group]]
  
 
|rtnType= table
 
|rtnType= table
Line 79: Line 84:
 
|rtnExamples= groupDataTable
 
|rtnExamples= groupDataTable
  
|example= <pre>
+
|example= The following would get the current information pertaining to a ground group that is currently on the red coalition country of East Germany and changes the country of it to "Germany". Due to the ids and names of the units being identical the original units will disappear and be replaced by the same units but simply belonging to a different country and coalition as a result. 
   local vars = {}
+
<pre>
  vars.gpName = ‘group1’
+
   local gp = mist.getCurrentGroupData('HasselhoffTankPlatoon2')
   vars.action = 'clone'  
+
   gp.country = 'Germany'
  vars.point = vec3
+
   mist.dynAdd(gp)
  vars.radius = 1000
 
  vars.disperse = ‘disp’
 
  vars.maxDisp = 500
 
   mist.teleportToPoint(vars)  
 
 
</pre>
 
</pre>
  

Latest revision as of 08:58, 4 June 2021


mist.dynAdd

Added with: Mist 3.0
Description
With valid data, this function will dynamically spawn a group consisting of unitsTable within the categoryName for countryName using the built in scripting function coalition.addGroup. See examples for different group types here:
   Ground Group
   Ship Group  
   Helicopter Group
   Plane Group
Syntax
table mist.dynAdd(table vars )
Valid Input Values:

vars tables have the following recognized fields( required entries in blue, optional in green):

 vars = 
 {
 units = table units, 
 country = string/number country, 
 category = string/number category,
 groupName/name = string groupName/name, 
 groupId = number groupId, 
 clone = boolean clone, 
 route = table route,
 }

units is a unitTable as formatted in the mission editor

country is the country name the group will spawn for

category is the category of the group to spawn

groupName/name is an optional variable that defines the group name. If not present the function will generate a new name based on country, category, and groupId. If it is the same as a pre-existing group, this function will overwrite and remove that group existing from the mission.

groupId is an optional variable that defines the group Id. If not present the function will generate a new group Id based off of the number of existing groups. If it is the same as a pre-existing groups Id, this function will overwrite and remove that existing group from the mission.

clone is an optional variable that defines whether or not it should treat the passed group data as a clone. If present it will create a new group Id and groupName regardless if you passed a custom name or Id.

route is an optional variable that defines the default route assigned to the group. Function is overloaded to accept it as either:

 route.points = { 
  [1] = {pointTable}, 
  [2] = {pointTable}, 
 ... 
 },

or

 route = { 
  [1] = {pointTable}, 
  [2] = {pointTable}, 
  ... 
 }
Return value:
table
Return example:
groupDataTable
Usage Examples:
The following would get the current information pertaining to a ground group that is currently on the red coalition country of East Germany and changes the country of it to "Germany". Due to the ids and names of the units being identical the original units will disappear and be replaced by the same units but simply belonging to a different country and coalition as a result.
  local gp = mist.getCurrentGroupData('HasselhoffTankPlatoon2')
  gp.country = 'Germany'
  mist.dynAdd(gp)
Notes:
Related Functions
dynAdd, dynAddStatic, groupTableCheck, getNextUnitId, getNextGroupId, respawnGroup, respawnInZone, cloneGroup, cloneInZone, teleportGroup, teleportInZone, teleportToPoint, spawnRandomizedGroup

Scripting Engine

MIST Root Page