How to pick up units of some category in a rectangle?

Interesting mapping tools and mapping help.

Moderator: Morax

How to pick up units of some category in a rectangle?

Postby Ghoustaq » 03 Apr 2018, 20:37

local units = GetUnitsInRect( rect):GetListOfUnits(categories.MOBILE, false, false)

the 'rect' here has been defined , don't worry about it

I am not sure if it is right to use two commands in one sentence?
User avatar
Ghoustaq
Avatar-of-War
 
Posts: 65
Joined: 25 Dec 2017, 13:54
Has liked: 10 times
Been liked: 0 time
FAF User Name: Ghoustaq

Re: How to pick up units of some category in a rectangle?

Postby speed2 » 03 Apr 2018, 20:44

That wont work, since GetListOfUnits has to be called on army brain
But something like this will do the job

Code: Select all
    local entities = GetUnitsInRect(rect)
    local units
    if entities then
        units = EntityCategoryFilterDown(category, entities)
    end


And if you want to get units only of a specific army, then there's function for that in ScenarioFramework.lua

https://github.com/FAForever/fa/blob/develop/lua/ScenarioFramework.lua#L390-L409
User avatar
speed2
Contributor
 
Posts: 3189
Joined: 05 Jan 2013, 15:11
Has liked: 636 times
Been liked: 1119 times
FAF User Name: speed2


Return to Mapping

Who is online

Users browsing this forum: No registered users and 1 guest