birgersp / dcs-gws

Ground Warfare Script for DCS World mission making
24 stars 4 forks source link

Made a small edit locally to get names based on coalition #116

Closed thebgpikester closed 2 years ago

thebgpikester commented 4 years ago
function giveCoaltionGrpName(group)
local newName
  if group["taskSequence"]["tasks"][1]["coalition"] == 1 then
    newName = "Red AutoGFT"
  elseif group["taskSequence"]["tasks"][1]["coalition"] == 2 then
    newName = "Blue AutoGFT"
  elseif group["taskSequence"]["tasks"][1]["coalition"] == 0 then
    newName = "Neutral AutoGFT"
  else newName = "AutoGFT"
  end
return newName
end
function autogft.getUniqueGroupName(grp)
  local groupName
  local index = 0
  while (not groupName) or Group.getByName(groupName) do
    index = index + 1
    groupName = giveCoaltionGrpName(grp) .. index
  --  if prefix then groupName = prefix .. "-" .. groupName end
  end
  return groupName
end

Net result of this is instead of the "autogft group" unique name, you get a red or blue prefix. What this does is allow a script I wrote to save group position in between restarts to not have to fight autogft over names when scanning units and renaming them. scanUnits("Blue AutoGFT")

This allows two coalitions to have each their own persistent AutoGFT over restarts. I'd have prefered name retention but it seemed a bit more complex to pass the group object to this without a lot more unpicking of the script. I couldnt work out what "group" actually was until I printed it out but I saw coalition and grabbed it and this achieved what I needed.

AutoGFT doing its thing persistently is a great thing to watch.