Jump to content
yskonyn

Starting out with scripting; groups

Recommended Posts

Hello warriors,

 

I am starting out with ArmA 3's scripting engine, but I have a question about groups or unit names/id's.

 

Namely, I noticed you can give individual soldiers a name, which will make it a global variable. Groups can also have a custom name in the Eden editor, but for some reason I am able to call the infividual units in a script by their name entered into its Attributes page in Eden, but this does not work for groups for some reason.

 

So, for example;

 

I have 2 soldiers who are part of the same group in the editor.

One is called soldier1, the other soldier2.

Their group is called Guards in the editor and they are assigned to Red (OPFOR).

 

In a script I have no trouble calling functions for soldier1 or soldier2, but every time I want to reference Guards as a group, the script returns an error in-game.

 

How would I go about calling groups in a script, please?

 

Many thanks!

Yassy

 

Share this post


Link to post
Share on other sites

In the unit's init field use the command _groupname = group this;

The group you pull them from when placing them in the editor is not assigned to them. If you want to use a group name to do scripting stuff you need to assign them a group name yourself with the above command.

You can find additional information here: https://community.bistudio.com/wiki/group

Share this post


Link to post
Share on other sites

Thank you for replying, Mynock.

 

But if I use a local variable like _groupname in the unit's init box in Eden, it returns an error that I want to use a local variable in a global setting.

 

I have read and re-read the wiki link you posted, but I find the group handling confusing.

Basically, what I want to know is if you can assign custom group names (instead of Alpha, Bravo, etc) to a group to make calling them in a script easier.
For example. say I want to have a group called '_Guards', can I assign such a name to a group, so that I can then call _Guards in a script to reference to this group?

 

EDIT: I think I get it now. You do not let a script handle group names directly, as it were, but you first 'store' a group name into a variable and then handle that variable instead! Could you confirm that is correct, please? :)

 

I have used the following code in the group's init box:

 

groupname = group this; hint format ["Guards have been assigned group: %1", groupname];

 

It returns that Guards are called 'O Guards'. So it seems to be working. However, how would I get rid of the global variables and make them local instead?

Share this post


Link to post
Share on other sites


hint format ["Guards have been assigned group: %1", group this];

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

×