FAForever Forums
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Login

    LUA Help with order

    Scheduled Pinned Locked Moved Modding & Tools
    11 Posts 4 Posters 622 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • speed2S
      speed2
      last edited by

      https://github.com/FAForever/fa/blob/deploy/fafdevelop/engine/Sim/Unit.lua#L377-L381
      states are listed at the top of the file

      B 1 Reply Last reply Reply Quote 0
      • B
        Broker @speed2
        last edited by Broker

        @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

        maudlin27M 1 Reply Last reply Reply Quote 0
        • Ctrl-KC
          Ctrl-K
          last edited by

          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

          B 1 Reply Last reply Reply Quote 0
          • maudlin27M
            maudlin27 @Broker
            last edited by

            @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
            

            M27AI and M28AI developer; Devlogs and more general AI development guide:
            https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v71-devlog
            https://forum.faforever.com/topic/5331/m28ai-devlog-v150

            B 1 Reply Last reply Reply Quote 0
            • B
              Broker @maudlin27
              last edited by

              @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

              1 Reply Last reply Reply Quote 0
              • B
                Broker @Ctrl-K
                last edited by

                @ctrl-k i I made an autogroup

                1 Reply Last reply Reply Quote 0
                • B
                  Broker
                  last edited by Broker

                  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?

                  1 Reply Last reply Reply Quote 0
                  • B
                    Broker
                    last edited by

                    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

                    maudlin27M 1 Reply Last reply Reply Quote 0
                    • maudlin27M
                      maudlin27 @Broker
                      last edited by

                      @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?

                      M27AI and M28AI developer; Devlogs and more general AI development guide:
                      https://forum.faforever.com/topic/2373/ai-development-guide-and-m27ai-v71-devlog
                      https://forum.faforever.com/topic/5331/m28ai-devlog-v150

                      B 1 Reply Last reply Reply Quote 0
                      • B
                        Broker @maudlin27
                        last edited by Broker

                        @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()

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post