Jump to content

More Lua help needed


Recommended Posts

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)
 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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