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

    Spawn Loaded Transports

    Scheduled Pinned Locked Moved Modding & Tools
    9 Posts 4 Posters 734 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.
    • R Offline
      Rama
      last edited by

      I'm trying to use this function to attach units to transports, but I seem to be doing something wrong.

      ScenarioFramework.AttachUnitsToTransports(units, transports)

      After running a script that spawns a transport, I've tried:

      transport = spawnedunit ScenarioFramework.AttachUnitsToTransports({"xel0305", "uel0303"}, {transport})

      Also Tried:
      transports = aiBrain:GetListOfUnits(categories.xea0306, false)
      units = {"xel0305", "uel0303"}
      ScenarioFramework.AttachUnitsToTransports(units, transports)

      And other combinations. The transport still spawns with no units attached.

      1 Reply Last reply Reply Quote 0
      • ? Offline
        A Former User
        last edited by A Former User

        The Trident mission spawns transports with units.

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

          You must pass unit object instead of string.

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

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

            This is how it is done with Oxygen in my coop mission: https://github.com/4z0t/MapsCoopDev/blob/GW/maps/Test/Test1_script.lua#L70-L78

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

            R 1 Reply Last reply Reply Quote 1
            • R Offline
              Rama @Ctrl-K
              last edited by

              @azath0th

              Thanks for the information. I've read through your example, and also scoured github (and the scripts used in Survival Verses) and other LUA documentation, but I still haven't been able to make sense of what you mean of unit object. Is there an example of creating a unit object? I was under the impression that a table was an object, but that didn't work when I tried.

              1 Reply Last reply Reply Quote 0
              • R Offline
                relentless
                last edited by relentless

                In your example you are using the unit id's in that function, its like saying you want to put someones name into a car instead of a person and wondering why they are not in the car.

                What you would want to do is create the units first, for example. Actually I'm not sure how the units are being created but you get the idea.

                local unit1 = armybrain:CreateUnitNearSpot('UEB0101', posX, posY)
                local unit2 = armybrain:CreateUnitNearSpot('UEB0101', posX, posY)

                ScenarioFramework.AttachUnitsToTransports({unit1, unit2}, {transport})

                p.s just to clarify your confusion. The function takes a table of objects rather than the table being an object itself.

                1 Reply Last reply Reply Quote 1
                • R Offline
                  Rama
                  last edited by

                  I got the transports loaded, and also got them to drop their units and fly off. Each transport has its own platoon of troops. I am trying to get the platoons to target specific units after being dropped. I've tried the following commands, but without luck:

                  CPlatoon:AttackTarget(Target, platoon) <-- Got the error "access to nonexistent global variable CPlatoon"
                  IssueAttack(platoon:GetPlatoonUnits(), Target) <-- No errors, script completed, but platoon did not attack the targeted unit.
                  PlatoonAttackClosestUnit(platoon) <-- Function from ScenarioPlatoonAI.lua, introduced an error "access to nonexistent global variable PlatoonAttackClosestUnit"

                  R 1 Reply Last reply Reply Quote 0
                  • R Offline
                    relentless @Rama
                    last edited by

                    @rama

                    CPlatoon:AttackTarget(Target, platoon)

                    Needs to be the platoon object in question.

                    e.g platoon:AttackTarget(Target)

                    This is assuming that 'platoon' is the object for the platoon that came off the transport. and that 'Target' is the unit object for a target that you have already got via some other means.

                    R 1 Reply Last reply Reply Quote 1
                    • R Offline
                      Rama @relentless
                      last edited by

                      @relentless

                      That worked perfect! Thanks!

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