Stoll

[SOLVED] Setting multiple markers with script

4 posts in this topic

Posted (edited)

Yo folks,

I'm still learning about scripting and many things are still confusing me.
But I started to keep the scripts cleanest as possible, so instead of using

	_dot = createMarker ["dot",_x];
	_dot setMarkerColor "ColorBlack";
	_dot setMarkerType "mil_dot";
	_dot setMarkerText "Landing Zone";

multiple times for spawning several markers I tried something like this:
 

	_dotpoints    = [
                    [4882.56,6054.45,0],
                    [4045.91,8544.21,0],
                    [6740.78,11156.83,0],
                    [7948.14,7596.10,0]
                    ];
	{
	_x1  = _x select 0;
	_x2  = _x select 1;
	_x3  = _x select 2;
	_x4  = _x select 3;
	
	_dot = createMarker ["dot",_x];
	_dot setMarkerColor "ColorBlack";
	_dot setMarkerType "mil_dot";
	_dot setMarkerText "Landing Zone";
	} forEach _dotpoints;

This spawns only one marker. I know there is something wrong and I'm sure it's a simple error.
Maybe this can be done even more easier.

Thanks for helping. :)

Edited by Stoll

Share this post


Link to post
Share on other sites
Advertisement
_markers =
[
    ["Marker1",[4882.56,6054.45,0]],
    ["Marker2",[4045.91,8544.21,0]]
];

{
    _name = (_x select 0);
    _pos = (_x select 1);
    _marker = createMarker [_name, _pos];
    _marker setMarkerColor "ColorBlack";
    _marker setMarkerType "mil_dot";
    _marker setMarkerText "Landing Zone";
} foreach _markers;

Should work. ^

Like Kobayashi says: Marker names must be unique.

If you don't want to add the names to the array you can count the foreachindex and format the marker name to be "Dot_" + Index.

1 person likes this

Share this post


Link to post
Share on other sites
2 hours ago, Taylor Swift said:

Should work. ^

Like Kobayashi says: Marker names must be unique.

If you don't want to add the names to the array you can count the foreachindex and format the marker name to be "Dot_" + Index.

Yo, totally forgot about the fact that marker names must be unique.
It's working now as it should. :) Thanks!
 

1 person likes this

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.