LUA Help with order
-
https://github.com/FAForever/fa/blob/deploy/fafdevelop/engine/Sim/Unit.lua#L377-L381
states are listed at the top of the file -
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.
-
@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 chunkmay be need some kind import?
-
work
GetGuardedEntitybut
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()