normre14232 Posted July 27, 2023 Posted July 27, 2023 Below is a script intended to create a table of all Red Groups and if inside a certain range give BRA updates to the player. The script runs with no errors logged in DCS.log file, however the BRA message never prints. Also the debugging messages as commented in code never print. I suspect there is a problem with my table or point finding method. Any help would be appreciated. Thanks in advance, NormRe local bogeyrange, bogeyrangeNM, update update = 60 function AWACS() -- create table of RED AIRPLANE Group redgroups = mist.getGroupsByAttribute({category = 'AIRPLANE', coalition = "red"}, 2, true) -- get location of RED groups for i, redgroup in ipairs(redgroups) do trigger.action.outText('Iterating Table',30) --msg never prints redgroupPos = mist.getLeadPos(redgroup) trigger.action.outText('Current Group Position ' ..redgroupPos, 30) --msg never prints -- get location of player Unit playerPos = Unit.getByName('player'):getPosition().p -- determine range of RED Groups to player bogeyrange = mist.utils.get2DDist(redgroupPos, playerPos) bogeyrangeNM = mist.utils.metersTONM(bogeyrange) trigger.action.outText('Range to Bogey is ' ..bogeyrangeNM, 30) --msg never prints -- determine if bogey relevant to player if bogeyrangeNM <= 100 then -- output BRA of RED groups to player mist.msgBRA({ units = Group.getUnits(redgroup), ref = 'player', metric = false, text = 'Bogey BRA ', displaytime = 15, msgFor = {units = {'player'}} }) end end -- set update rate based on Bogey Range --if bogeyrangeNM < 60 and bogeyrangeNM >= 40 then update = 30 --elseif bogeyrangeNM < 40 and bogeyrangeNM >= 10 then update = 15 --elseif bogeyrangeNM > 10 then update = 10 end end mist.scheduleFunction(AWACS, {}, timer.getTime()+ 10, update)
dark_wood Posted July 28, 2023 Posted July 28, 2023 Maybe category value 'AIRPLANE', is wrong? Check here: https://wiki.hoggitworld.com/view/DCS_enum_attributes ["Planes"] = {"Air",},
Chump Posted July 28, 2023 Posted July 28, 2023 I believe that you have the correct Group category attribute name for this to work. Group.Category = { AIRPLANE, HELICOPTER, GROUND, SHIP } I noticed that MiST is trying to find the matches by criteria, but category is spelled incorrectly in the code. I have opened an issue for it here: https://github.com/mrSkortch/MissionScriptingTools/issues/78
Recommended Posts