Jump to content
NFG WhatHiMean

Help with spawning compositions script

Recommended Posts

I am trying to spawn in preset mini missions on mission start using the script from this post

 

I'm not %100 I set this up correctly but I followed the instructions as best as I could and I wasn't able to get it working. This is more complicated then the stuff I've been doing so far and I'm still learning so sorry for any dumb questions.

 

I've also looked at this post which is basically what I want, I found the post above from here

 

Anyways on to my actual issues, I get this error loading the mission in the editor saying

Spoiler

mpmissions\missionname\compositions\compositions.cfg, line 0: /: ' ' encountered instead of '{'

 

 

This is the relating .cfg file

class CfgCompositions {
    class ArtyMission { spawnartymission
        #include "spawnartymission.sqe"
    };
};

 

 

I'm not much of a scripter so I followed what larrow said in their post but clearly I don't know what I'm doing here

 

This is how I'd like to use the function in my own script, real simple, I just want to pick a random marker and then spawn the composition on said marker one time. I made and run a mission in a pvp scenario with some friends who memorize and prioritize targets like, the enemy artillery. So unless I can make it dynamic enough to change spawn locations the balancing of the mission is fucked up in two or three runs.

 

Spoiler

private _ArtySpawnMarkers = [
    "arty_spawn_marker", "arty_spawn_marker_1", "arty_spawn_marker_2", "arty_spawn_marker_3", 
    "arty_spawn_marker_4", "arty_spawn_marker_5", "arty_spawn_marker_6"
];

private _artmarker = selectRandom _ArtySpawnMarkers;
["spawnartymission", _artmarker, 0, 0, true, true] call LARs_fnc_spawnComp;
_spwndArt = _spwndArt + 1;


I have read through the posts multiple times and read through every comment to see what issues other people have had and found nothing that worked for me. Any help would be greatly appreciated as this seems to be the only way to spawn in things like triggers or modules with all settings intact and functioning. I've looked around online for a while now and I can't find a way to spawn in compositions while keeping data like trigger settings, not just object variable names and similar simple data. Thanks in advance!

 

 

To make sure I have the install correct, these are the other files larrow had me add/change

 

description.ext

Spoiler

class CfgFunctions {
    #include "LARs\spawnComp\functions\functions.cpp"
};

#include "compositions\compositions.cfg"

 

 

The full LARs\spawnComp\functions\ file structure with all the fn_~~~.sqf files and other nested files. All of this is placed in the root mission folder and should be in place according to larrows post

Share this post


Link to post
Share on other sites

without digging deep into your entire mission, this part is incorrect:

Spoiler

class CfgCompositions {
    class ArtyMission { spawnartymission
        #include "spawnartymission.sqe"
    };
}; 

 

and should be:

Spoiler

class CfgCompositions {
    class ArtyMission {// spawnartymission
        #include "spawnartymission.sqe"
    };
};

with // in front of spawnartymission

Share this post


Link to post
Share on other sites
1 minute ago, panther42 said:

without digging deep into your entire mission, this part is incorrect:

  Reveal hidden contents


class CfgCompositions {
    class ArtyMission { spawnartymission
        #include "spawnartymission.sqe"
    };
}; 

 

and should be:

  Reveal hidden contents

class CfgCompositions {
    class ArtyMission {// spawnartymission
        #include "spawnartymission.sqe"
    };
};

with // in front of spawnartymission

Tyty like I said in the op I'm not a very good scripter, so if you'd explain why do I need the //?

Share this post


Link to post
Share on other sites

// is a comment line, and is not read.  Just as @Larrow instructed in his thread:
 

Spoiler

//LARs_spawnComp_debug = 1; //1 = RPT output, 2 = RPT output and ingame visual positioning info

class CfgCompositions {
    class Walk { //Name that the composition is spawned by
        #include "walk.sqe" //Renamed composition.sqe
    };
};

 

Here is a bit more on Class Inheritance

Share this post


Link to post
Share on other sites

so just from starting the mission I get both of these errors

Spoiler

LARs_error.png?ex=65526e8f&is=653ff98f&h

&

error_2.png?ex=65526e8f&is=653ff98f&hm=f

Either I messed up the marker placement OR the script itself is broken IDK 😕

Share this post


Link to post
Share on other sites

Did you try entering by the Class you defined?  class ArtyMission

Otherwise, I'd stick to naming the class the same as the .sqe as Larrow did

Share this post


Link to post
Share on other sites
3 minutes ago, NFG WhatHiMean said:

 

  Hide contents

error_2.png?ex=65526e8f&is=653ff98f&hm=f

Either I messed up the marker placement OR the script itself is broken IDK 😕


Similar to //comments, which will "end" at the end of the line, you can have
/*/ comments /*/
or
/*   comments * /  .

Meaning, if you have more things to comment or to write that are NOT part of the code, you can add all that stuff inside /* ..... */  or /*/ .... /*/ .
In your case up there, it's very likely "Grab data... " is part of a comment (note the /* before it), and if so it's probably missing its closure */ .

Such things you can track more easily when you realize the game will add a symbol # right before the error it detects.

Share this post


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

// is a comment line, and is not read.  Just as @Larrow instructed in his thread:
 

  Hide contents


//LARs_spawnComp_debug = 1; //1 = RPT output, 2 = RPT output and ingame visual positioning info

class CfgCompositions {
    class Walk { //Name that the composition is spawned by
        #include "walk.sqe" //Renamed composition.sqe
    };
};

 

Here is a bit more on Class Inheritance

I see, the commented out "Name that the composition is spawned by" confused me, reading it again it makes more sense lol.
 

When I go to call the spawn function I use the class name "ArtyMission" in this case right?
 

Spoiler

private _ArtySpawnMarkers = [
    "arty_spawn_marker", "arty_spawn_marker_1", "arty_spawn_marker_2", "arty_spawn_marker_3", 
    "arty_spawn_marker_4", "arty_spawn_marker_5", "arty_spawn_marker_6"
];

private _artmarker = selectRandom _ArtySpawnMarkers;
["ArtyMission", _artmarker, 0, 0, true, true] call LARs_fnc_spawnComp;

 

Share this post


Link to post
Share on other sites
1 minute ago, JCataclisma said:


Similar to //comments, which will "end" at the end of the line, you can have
/*/ comments /*/
or
/*   comments * /  .

Meaning, if you have more things to comment or to write that are NOT part of the code, you can add all that stuff inside /* ..... */  or /*/ .... /*/ .
In your case up there, it's very likely "Grab data... " is part of a comment (note the /* before it), and if so it's probably missing its closure */ .

Such things you can track more easily when you realize the game will add a symbol # right before the error it detects.

Ty I'll try and track it down then and find the specific issue

Share this post


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

Did you try entering by the Class you defined?  class ArtyMission

Otherwise, I'd stick to naming the class the same as the .sqe as Larrow did

Ty, ngl I was high when I was first looking into this so half of what I have was written / researched by high me lmao

Share this post


Link to post
Share on other sites

_compReference = [ COMP_NAME, POS_ATL, OFFSET, DIR, ALIGN_TERRAIN, ALIGN_WATER, IGNORE_ATLOFFSET ] call LARs_fnc_spawnComp;

 

Use the private variable _compReference, or something of your choice, because Larrows code is built to return: "The function call will also return a reference string for the composition. Which can be used with some of the provided utility functions."

Share this post


Link to post
Share on other sites

New error, I did check my description.ext and it should be defined as a function not sure why it can't see that tho

Spoiler

image.png?ex=655271b5&is=653ffcb5&hm=bad

 

Share this post


Link to post
Share on other sites
Just now, panther42 said:

_compReference = [ COMP_NAME, POS_ATL, OFFSET, DIR, ALIGN_TERRAIN, ALIGN_WATER, IGNORE_ATLOFFSET ] call LARs_fnc_spawnComp;

 

Use the private variable _compReference, or something of your choice, because Larrows code is built to return: "The function call will also return a reference string for the composition. Which can be used with some of the provided utility functions."

Ahh interesting alright, ty

Share this post


Link to post
Share on other sites
5 minutes ago, NFG WhatHiMean said:

Ty I'll try and track it down then and find the specific issue 


By a fortunate coincidence, we have just talked about notepad++ in another topic today, so I also ask: are you using a software like it for your code/tests, or just regular notepad/wordpad? Because when in Notepad++ (or any other script software), if you activate a language like C++, it will instantly show you everything that might be considered CODE or COMMENT 😉
 

 

Share this post


Link to post
Share on other sites
Just now, JCataclisma said:


By a fortunate coincidence, we have just talked about notepad++ in another topic today, so I also ask: are you using a software like it for your code/tests, or just regular notepad/wordpad? Because when in Notepad++ (or any other script software), if you activate a language like C++, it will instantly show you everything that might be considered CODE or COMMENT 😉
 

 

Yeah, I've been using notepad++ for a few years now with my on/off coding experience. I only recently got into the scripting side of arma mission making, so I defined the sqf language for ++ and it seems to be working well.

Share this post


Link to post
Share on other sites
5 minutes ago, NFG WhatHiMean said:

New error, I did check my description.ext and it should be defined as a function not sure why it can't see that tho

  Hide contents

image.png?ex=655271b5&is=653ffcb5&hm=bad

 

ok, what is on line 7 of artymissionspwn.sqf?

Share this post


Link to post
Share on other sites
Just now, panther42 said:

ok, what is on line 7 of artymissionspwn.sqf?

 

Spoiler

private _ArtySpawnMarkers = [
    "arty_spawn_marker", "arty_spawn_marker_1", "arty_spawn_marker_2", "arty_spawn_marker_3", 
    "arty_spawn_marker_4", "arty_spawn_marker_5", "arty_spawn_marker_6"
];

private _artmarker = selectRandom _ArtySpawnMarkers;
["spawnartymission.sqe", _artmarker, 0, 0, true, true] call LARs_fnc_spawnComp;                          <--- Line 7 Here
_spwndArt = _spwndArt + 1;

 

Share this post


Link to post
Share on other sites

That line should include your class defined...

private _compReference = [ ArtyMission, _artmarker, 0, 0, true, true] call LARs_fnc_spawnComp;

 

Also, your parameters do not align correctly with what Larrow mentioned:

Spoiler

COMP_NAME - Classname given to composition in CfgCompositions

 

POS_ATL( optional, default compositions saved position ) - Position to spawn composition If not given or empty array passed then original saved composition position is used

Also accepts OBJECT, MARKER, LOCATION

 

OFFSET( optional, default none ) - ARRAY [ x, y, z ] ammount to offset composition, as a compositions base pos can vary from what you want when its saved

 

DIR( optional, deafault 0 ) - Direction to face composition in, If POS_ATL is of type OBJECT, MARKER, LOCATION passing TRUE for direction will use objects direction

 

ALIGN_TERRAIN( optional, default True ) - BOOL, Whether composition objects should align themselves to their positions surface normal

 

ALIGN_WATER( optional, default True ) - BOOL, If a composition objects position is over water should they align themselves to sea level

 

IGNORE_ATLOFFSET( optional, default False ) - BOOL, If True each item in the composition will ignore its ATLOffset that usually gets added to its Z(height)

 

Share this post


Link to post
Share on other sites
3 minutes ago, panther42 said:

That line should include your class defined...

private _compReference = [ ArtyMission, _artmarker, 0, 0, true, true] call LARs_fnc_spawnComp;

Ty I have changed to that however once I tried the mission I received this error

Spoiler

image.png?ex=65527758&is=65400258&hm=cfb

 

Share this post


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

Ty I have changed to that however once I tried the mission I received this error

  Hide contents

image.png?ex=65527758&is=65400258&hm=cfb

 

This is a snippet of code where the error is at

Spoiler

//Get position of a MARKER
    case ( _compPos isEqualType "" && { getMarkerPos _compPos != [0,0,0] } ) : {
        if ( _compRot isEqualType true ) then {
            _compRot = markerDir _compPos;
        };
        _compPos = ATLToASL getMarkerPos _compPos;
    };

I am using empty markers, could that be a issue?

Share this post


Link to post
Share on other sites
26 minutes ago, panther42 said:

Also, your parameters do not align correctly with what Larrow mentioned:

  Reveal hidden contents

COMP_NAME - Classname given to composition in CfgCompositions

 

POS_ATL( optional, default compositions saved position ) - Position to spawn composition If not given or empty array passed then original saved composition position is used

Also accepts OBJECT, MARKER, LOCATION

 

OFFSET( optional, default none ) - ARRAY [ x, y, z ] ammount to offset composition, as a compositions base pos can vary from what you want when its saved

 

DIR( optional, deafault 0 ) - Direction to face composition in, If POS_ATL is of type OBJECT, MARKER, LOCATION passing TRUE for direction will use objects direction

 

ALIGN_TERRAIN( optional, default True ) - BOOL, Whether composition objects should align themselves to their positions surface normal

 

ALIGN_WATER( optional, default True ) - BOOL, If a composition objects position is over water should they align themselves to sea level

 

IGNORE_ATLOFFSET( optional, default False ) - BOOL, If True each item in the composition will ignore its ATLOffset that usually gets added to its Z(height)

Adjusted to 

_compReference  =["ArtyMission", _artmarker, [], true] call LARs_fnc_spawnComp;

 

Share this post


Link to post
Share on other sites

You can't skip parameters.  Try like this (if you want ignore_atloffset to be true?  Your last parameter is true)

private _compReference  =["ArtyMission", _artmarker, [0,0,0], 0, true, true, true] call LARs_fnc_spawnComp;

 

I should clarify the above.  You can't skip if something you want to change is not the default.  I have no clue what your ending true is for.
You could just have the following if you do not want to change anything past the position:

private _compReference  =["ArtyMission", _artmarker] call LARs_fnc_spawnComp;

Edited by panther42
clarification

Share this post


Link to post
Share on other sites
5 minutes ago, panther42 said:

You can't skip parameters.  Try like this (if you want ignore_atloffset to be true?  Your last parameter is true)

private _compReference  =["ArtyMission", _artmarker, [0,0,0], 0, true, true, true] call LARs_fnc_spawnComp;

Larrow says everything other name the name is optional so apart from the incorrect formatting of offset I thought I was good. Not sure why ignore atloffset was true too

 

Still getting this error, can't tell if it's a issue on my part or the script (probably me tho)

Spoiler

image.png?ex=65528052&is=65400b52&hm=4e1

 

Share this post


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

Larrow says everything other name the name is optional so apart from the incorrect formatting of offset I thought I was good. Not sure why ignore atloffset was true too 

 

Still getting this error, can't tell if it's a issue on my part or the script (probably me tho)

  Reveal hidden contents

image.png?ex=65528052&is=65400b52&hm=4e1

 

This is true, but the composition will be spawned at the coordinates WHERE IT WAS CREATED (someone created this at some place on the map)

These markers are placed in the editor and named as you have given?

2 hours ago, NFG WhatHiMean said:

private _ArtySpawnMarkers = [
    "arty_spawn_marker", "arty_spawn_marker_1", "arty_spawn_marker_2", "arty_spawn_marker_3", 
    "arty_spawn_marker_4", "arty_spawn_marker_5", "arty_spawn_marker_6"
];

 

Share this post


Link to post
Share on other sites
27 minutes ago, panther42 said:

This is true, but the composition will be spawned at the coordinates WHERE IT WAS CREATED (someone created this at some place on the map)

These markers are placed in the editor and named as you have given?

 

Yes, the markers are just like this, only change is name and placement around the map

Spoiler

image.png?ex=655288b9&is=654013b9&hm=06a

 

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

×