Jump to content
Sign in to follow this  
Tankbuster

brackets brackets everywhere!

Recommended Posts

{
diag_log "player is engineer!";
if ((_ability_array select 11) == 1) then
{
diag_log "has ability to see rsb";
diag_log format ["count iedarray = %1", count iedarray];
//show ieds to player

       {
	_trsbmarkername = format ["t_rsbmarker%1",_forEachIndex];
	[color="Red"]_markerpos = position (iedarray (select _forEachIndex));[/color]
	_trsbmarker = createMarkerLocal [_trsbmarkername, _markerpos];
	_trsbmarkername setMarkerTypeLocal "mil_warning";

       }forEach iedarray;
   };
};

Agh. I swear I dream about brackets, braces and parenthesis!

The line highlighted in red is giving missing bracket errors. Can a fresh pair of eyes have a look please?

Also, as markers need a unique name, is the line above the red one working as intended, ie creating markers called t_rsbmarker0, t_rsbmarker1, t_rsbmarker2 and so on? That's what I wanted it to do and it creates more than marker without errors, but have I done it right?

Share this post


Link to post
Share on other sites

"select _forEachIndex", which you have bracketed off in parenthesis, doesn't make sense by itself; you need an array to select from. Simply remove those parenthesis (you can keep the outer ones), and I think you should be good to go. Your method for dynamic marker names looks fine.

Share this post


Link to post
Share on other sites

indeed _markerpos = position (iedarray (select _forEachIndex));

should be:

_markerpos = position (iedarray select _forEachIndex);

Share this post


Link to post
Share on other sites

h00DYl.jpg

That's got it! Thanks guys. It's still making an error though. :)

Error in expression <r = createMarkerLocal [_trsbmarkername, _markerpos];
_trsbmarkername setMarkerTy>
 Error position: <_markerpos];
_trsbmarkername setMarkerTy>
 Error Undefined variable in expression: _markerpos
File C:\Users\Paul\Documents\ArmA 2 Other Profiles\Tanky\mpmissions\Takistan_Rhapsody.Takistan\x_client\t_engineerseersb.sqf, line 41

Line 41 being the one under the red one.

---------- Post added at 05:57 PM ---------- Previous post was at 05:48 PM ----------

OK, I diaglogged the two variables in question.

_trsbmarkername is indeed getting a number on the end of it, which is nice. :)

But _markerpos is coming back as "any"

Share this post


Link to post
Share on other sites

In the pastebin version of your script, you have two underscores before "markerpos" on line 42. That's why it's showing up as "any".

Share this post


Link to post
Share on other sites

Ah yes. That's a diag log line :) I'll try again.

---------- Post added at 07:57 PM ---------- Previous post was at 07:48 PM ----------

It seems to be failing at the pos of the first marker. Subsequent ones work fine.

"count iedarray = 7"
"_trsbmarkername t_rsbmarker0"
"_markerpos array"
Error in expression <name];
diag_log format ["_markerpos %1",_markerpos];
_trsbmarker = createMarkerL>
 Error position: <_markerpos];
_trsbmarker = createMarkerL>
 Error Undefined variable in expression: _markerpos
File C:\Users\Paul\Documents\ArmA 2 Other Profiles\Tanky\mpmissions\Takistan_Rhapsody.Takistan\x_client\t_engineerseersb.sqf, line 42
"_trsbmarkername t_rsbmarker1"
"_markerpos [1519.53,3678.91,0]"
"_trsbmarkername t_rsbmarker2"
"_markerpos [1524.22,3535.16,0]"
"_trsbmarkername t_rsbmarker3"
"_markerpos [1399.68,3495.29,0]"
"_trsbmarkername t_rsbmarker4"
"_markerpos [1388.65,3487.72,0]"
"_trsbmarkername t_rsbmarker5"
"_markerpos [1328.98,3729.82,0]"
"_trsbmarkername t_rsbmarker6"
"_markerpos [1387.76,3681.53,0]"

---------- Post added at 08:53 PM ---------- Previous post was at 07:57 PM ----------

OK, I think the problem is with the script that creates the iedarray. I'm pretty sure it's not creating the first record properly. I'll investigate.

Share this post


Link to post
Share on other sites

getMarkerPos is only for markers, so if the array contains objects, you'l need to use position or getPos.

Is the pastebin up2date? _markerPos undefined seems strange?

This is btw unnecessary when using forEach; (iedarray select _forEachIndex)

You can just use: _x, as you're iterating over the iedarray already.

Share this post


Link to post
Share on other sites

The pastebin isn't up to date, because I've found the error. As I suspected earlier, the script that creates the IED array was accidentally creating a spurious (and munged data filled) first record, which is why the marker script was correct in every way, but generated an error on the first iteration..

I've fixed that and it's good now.

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
Sign in to follow this  

×