LUA Help with order

Hello

how can i understand that units have active order GUARD?

add in this condition check like

and units dont have GUARD order

    if isInTable(Filters[group],bp) and ........ then
        table.insert(SelectedUnits,unit)

Thanks/

@speed2

unit.IsUnitState("GuardBusy") or unit.IsUnitState("Patrolling")

right?

allUnits = GetAllUnits()
allUnits = GetSelectedUnits()
for _,unit in allUnits do
local id = unit:GetEntityId()
local bp = unit:GetBlueprint().BlueprintId
if isInTable(Filters[group],bp) and not (unit.IsUnitState("GuardBusy") or unit.IsUnitState("Patrolling"))  then

warning: Error running lua command: ...nce\mods\filterselection\modules\filterselection.lua(163): attempt to call field IsUnitState' (a nil value) stack traceback: ...nce\mods\filterselection\modules\filterselection.lua(163): in function FilterSelect'
string "import('/mods/FilterSelection/modules/Filte...": in main chunk

On UI side you'd need this.

“Be a yardstick of quality. Some people aren’t used to an environment where excellence is expected.”
— Steve Jobs.
My UI Mods
Support me

@broker I've no experience with UI mods so this might not work, but for a SIM mod the following should work:

if not(unit:IsUnitState('Guarding') or unit:IsUnitState('Patrolling')) then

@maudlin27 i tired this but i receive

what this attempt to call method `IsUnitState' (a nil value)

warning: Error running lua command: ...nce\mods\filterselection\modules\filterselection.lua(165): attempt to call method IsUnitState' (a nil value) stack traceback: ...nce\mods\filterselection\modules\filterselection.lua(165): in function FilterSelect'
string "import('/mods/FilterSelection/modules/Filte...": in main chunk

@ctrl-k i I made an autogroup

maybe I'm calling the function incorrectly?

warning: Error running lua command: ...nce\mods\filterselection\modules\filterselection.lua(166): attempt to call method GetGuardedUnit' (a nil value) stack traceback: ...nce\mods\filterselection\modules\filterselection.lua(166): in function FilterSelect'
string "import('/mods/FilterSelection/modules/Filte...": in main chunk

may be need some kind import?

work
GetGuardedEntity

but
I saw the use of these functions in the files. but they didn't work for me. maybe you know why?
IsUnitState
GetGuardedUnit

@broker I've never had any issues with unit:IsUnitState('xxx'), have you used logs to confirm that what you're using it on is a unit? for example, if you do LOG('unit='..(unit.UnitId or 'nil')) what shows up in the log - is it the expected unit ID/blueprint reference, or a nil value?

@maudlin27 in discord they wrote that these are functions for the game and they are not available in UI mods.

told to use this
unit:GetGuardedEntity()