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

    LUA Help with order

    Scheduled Pinned Locked Moved Modding & Tools
    11 Posts 4 Posters 566 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 Offline
      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 Offline
        Broker Banned @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 Offline
          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 Offline
            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-v130

            B 1 Reply Last reply Reply Quote 0
            • B Offline
              Broker Banned @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 Offline
                Broker Banned @Ctrl-K
                last edited by

                @ctrl-k i I made an autogroup

                1 Reply Last reply Reply Quote 0
                • B Offline
                  Broker Banned
                  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 Offline
                    Broker Banned
                    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 Offline
                      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-v130

                      B 1 Reply Last reply Reply Quote 0
                      • B Offline
                        Broker Banned @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

                        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                        With your input, this post could be even better 💗

                        Register Login
                        • First post
                          Last post