Jump to content
Northup

Spawning Composition not Working

Recommended Posts

I am trying to write a script that reads a composition.sqe with loadconfig and then walks through the items using configClasses and spawn them one by one. So far, no luck.

I have the following code:

Spoiler

 


// Load the configuration file
_config = loadConfig "composition.sqe";

// Get the entities
_entities = configClasses (_config >> "items" >> "Item0" >> "Entities");

// Iterate through each entity
{
    // Check if the dataType is an object or logic
    if ((_x >> "dataType") isEqualTo "Object" || (_x >> "dataType") isEqualTo "Logic") then {

        // Get the position and direction of the entity
        _pos = getArray (_x >> "PositionInfo" >> "position");
        _dir = getArray (_x >> "PositionInfo" >> "angles");

        // Spawn the entity
        _entity = createVehicle (_x >> "type"), [(_pos select 0) + (center select 0), (_pos select 1) + (center select 1), (_pos select 2) + (center select 2)], [], 0, "CAN_COLLIDE";
        _entity setDir (_dir select 0);

        // Set the attributes of the entity
        _entity setVariable ["atlOffset", _x >> "atlOffset"];
        _entity setVariable ["id", _x >> "id"];
        _entity setVariable ["side", _x >> "side"];

        // Set the attributes of the entity, if any
        _attributes = configClasses (_x >> "Attributes");
        {
            _entity setVariable [(configName _x), _x];
        } forEach _attributes;
    }
} forEach _entities;

 

 

 

Currently this is what the error report says:

Spoiler

 

{
private _entit>
15:55:52   Error Missing ;
15:55:52 File C:\Users\jmint\Documents\Arma 3 - Other Profiles\Dapperstache\mpmissions\06A-SZ-Altis-COMPSPAWNTEST.Altis\SpawnList\Abdera.sqf..., line 7
15:55:52 Error in expression <");


private _entities = configClasses (_config >> "items");


{
private _entit>
15:55:52   Error position: <(_config >> "items");

 


For reference, here is the test composition.sqe:

Spoiler



version=54;
center[]={9437.0068,123.12376,20306.428};
class items
{
    items=1;
    class Item0
    {
        dataType="Layer";
        name="H Barrier - Razor";
        class Entities
        {
            items=3;
            class Item0
            {
                dataType="Layer";
                name="H Barrier - Razor";
                class Entities
                {
                    items=2;
                    class Item0
                    {
                        dataType="Object";
                        class PositionInfo
                        {
                            position[]={2.5908203,1.3677444,-0.38867188};
                            angles[]={0.037514176,5.129302,6.2718234};
                        };
                        side="Empty";
                        flags=4;
                        class Attributes
                        {
                        };
                        id=46782;
                        type="Land_HBarrier_01_big_4_green_F";
                        atlOffset=-0.22571564;
                    };
                    class Item1
                    {
                        dataType="Object";
                        class PositionInfo
                        {
                            position[]={2.8134766,3.2416534,-0.42382813};
                            angles[]={0.037510466,5.1293039,6.2718163};
                        };
                        side="Empty";
                        class Attributes
                        {
                        };
                        id=46783;
                        type="Land_Razorwire_F";
                        atlOffset=2.0817642;
                    };
                };
                id=46781;
                atlOffset=0.92804718;
            };
            class Item1
            {
                dataType="Layer";
                name="H Barrier - Razor_1";
                class Entities
                {
                    items=2;
                    class Item0
                    {
                        dataType="Object";
                        class PositionInfo
                        {
                            position[]={-2.3212891,1.3677444,-1.4003906};
                            angles[]={0.017958056,3.7406018,0.034842271};
                        };
                        side="Empty";
                        flags=4;
                        class Attributes
                        {
                        };
                        id=46786;
                        type="Land_HBarrier_01_big_4_green_F";
                        atlOffset=0.09942627;
                    };
                    class Item1
                    {
                        dataType="Object";
                        class PositionInfo
                        {
                            position[]={-2.2529297,3.2416534,-1.2050781};
                            angles[]={0.017964279,3.7406042,0.03483738};
                        };
                        side="Empty";
                        class Attributes
                        {
                        };
                        id=46787;
                        type="Land_Razorwire_F";
                        atlOffset=2.4292526;
                    };
                };
                id=46785;
                atlOffset=1.2643509;
            };
            class Item2
            {
                dataType="Layer";
                name="H Barrier - Razor_2";
                class Entities
                {
                    items=2;
                    class Item0
                    {
                        dataType="Object";
                        class PositionInfo
                        {
                            position[]={-0.33496094,1.2099991,1.4960938};
                            angles[]={6.2684999,2.8803582,0.03634182};
                        };
                        side="Empty";
                        flags=4;
                        class Attributes
                        {
                        };
                        id=46789;
                        type="Land_HBarrier_01_big_4_green_F";
                        atlOffset=-0.092430115;
                    };
                    class Item1
                    {
                        dataType="Object";
                        class PositionInfo
                        {
                            position[]={-0.43652344,3.0839081,1.6757813};
                            angles[]={6.2685075,2.8803606,0.036343243};
                        };
                        side="Empty";
                        class Attributes
                        {
                        };
                        id=46790;
                        type="Land_Razorwire_F";
                        atlOffset=2.2503967;
                    };
                };
                id=46788;
                atlOffset=1.07901;
            };
        };
        id=46784;
        atlOffset=1.0900955;
    };
};


 




Any ideas?

Share this post


Link to post
Share on other sites

 

1 hour ago, Northup said:

I am trying to write a script that reads a composition.sqe ... then walks through the items ... and spawn them one by one.

Ive already done this and is available here...

...your welcome to go through it see what helps.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks Larrow.
I tried yours first, but I'm inexperienced enough that with yours I couldn't add the lines to description.ext, since the mission I have is somewhat complex and has a ton of other functions and was throwing me errors. Not comfortable enough to perform that kind of surgery on existing scripts and functions. 
I also couldn't figure out how to just straight up spawn in something on mission start without using addactions. 

Just trying to come of with a small, simple script that will do what I need. 

Share this post


Link to post
Share on other sites
On 2/17/2023 at 5:41 PM, Larrow said:

 

Ive already done this and is available here...

...your welcome to go through it see what helps.

@Larrow, I gave it another shot and was able to get into my mission, but I am unsure of how to spawn my comp via trigger?

I tried

_compReference = [ SAB ] call LARs_fnc_spawnComp; 

no luck. My composition is called SAB. Any suggestions?

Share this post


Link to post
Share on other sites
2 minutes ago, demonline said:

I initially attempted using yours, but because of my inexperience, I was unable to add the lines to the description. ext, since my mission was throwing me errors and is quite complicated and has many more features. Not secure enough to operate that way on scripts and functions that already exist.
Also, I was unable to figure out how to just spawn in a location upon mission start without the use of addactions.

I'm just attempting to come up with a short, straightforward script that will accomplish my goals.

??? 

Share this post


Link to post
Share on other sites

Solved. Still leaning syntax. My apologies. @Larrow thanks for the script. Works like a charm once I figured it out. 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×