Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local dots = {} --//variable: store enemy position.
- local dotsEnterLos = {} --//variable: remember if enemy is in LOS.
- function widget:UnitEnteredRadar(unitID, allyTeam)
- dots[unitID] = {wasInLOS=false}--store something something
- if (dotsEnterLos[unitID] == true) then
- dots[unitID].wasInLOS = true
- end
- end
- function widget:UnitLeftRadar(unitID, allyTeam)
- dots[unitID] = nil
- end
- function widget:UnitEnteredLos(unitID, allyTeam )
- dotsEnterLos[unitID] = true
- if ( dots[unitID] ~= nil ) then
- dots[unitID].wasInLOS = true
- end
- end
- function widget:UnitLeftLos(unitID, allyTeam)
- dotsEnterLos[unitID] = nil
- end
- function widget:Update(n)
- for unitID, content in pairs(dots) do --//iterate over all dots and draw them
- if (dotsEnterLos[unitID] == nil) then
- local x, y, z = spGetUnitPosition(unitID)
- if x == nil then
- dots[unitID] = nil
- Spring.Echo("I am non-existent!")
- else
- if content.wasInLOS then
- Spring.Echo("I am identified radar contact!")
- else
- Spring.Echo("I am UN-identified radar contact!")
- end
- end
- else
- Spring.Echo("I am Visible to naked eye!")
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment