Jump to content
Sign in to follow this  

variable storing on drawIcon / ui event handler "draw"

Recommended Posts

Hey guys,

I'm currently working on a blufor tracking and enemy marking system based on drawIcon.

But I have some questions:

drawIcon seems to save the path to the array which defines the icon in question. I'm am able to to generate an unlimited amount of icons for on the map by saving icon-defining arrays in a big array and then looping this array. Kind of:

_iconArray = missionnamespace getVariable ["myGlobalIconArray",[]];
if (count _iconArray == 0) exitWith {};
_pos = _x select 2;
_pos = visibleposition _x;
_x set [2,_pos];
_map drawIcon _x;
} forEach _iconArray;

Let's assume that _x select 2 is an object. What I want is that I get the position of the object stored in _x select 2 and then store it privately in _x select 2 to draw the icon at that position. Which should be possible for _iconArray being a local variable.

But the result is following: _x select 2 will be set globaly visibleposition _pos, leading to the problem that for the next frame when the ui eventhandler "draw" is called, there is a position and no object as _x select 2. This is not so problematic in this case, there are easy workarounds but in some point I'm not able to generate a simple workaround for this problem.

What I'm wondering about the most is that BIS was able NOT to store variables globaly in their arrays for drawIcon which you can see in the file \a3\modules_f\strategicmap\functions\fn_moduleStrategicMapORBAT.sqf ... So there must be a way to store arrays for drawIcon localy.

I'd be glad if someone understands my problem, I hope it's not to "german" what i wrote.

And Karel Moricky, if you read this, I'd be very glad for a reply, even if you don't know, what I'm meaning... Maybe I could clarify it in any way.

Thanks for your time!

---------- Post added at 20:24 ---------- Previous post was at 19:14 ----------

To clarify my first post:

This was a protoype of code for my idea of a blufor tracking system, and it worked:

BFT_drawIcons = [[{position player},[],[ 'iconStaticMG', [1,0,0,1], [0,0,0], 24, 24, 0, 'Player Vehicle', 1, 0.03, 'PuristaLight', 'right' ]]];

(finddisplay 12 displayctrl 51) ctrladdeventhandler ["draw",{
_icons = missionnamespace getvariable "BFT_drawIcons";
	_posCode = _x select 0;
	_objs = _x select 2;
	_iconParams = _x select 1;
	_iconParams set [2,(call _posCode)];
	_this select 0 drawIcon _iconParams;
} forEach _icons;

_bool = (missionnamespace getvariable "BFT_drawIcons") isEqualTo _icons;
// _bool will be true

Why is _bool true?! It shouldn't!

---------- Post added at 21:43 ---------- Previous post was at 20:24 ----------

Problem solved!

The problem was that I didn't know how arrays are declared. I was not aware of the fact, that setting array1 = array2 makes array1 an address to array2. I solved my problem with _icons = +(missionnamespace getvariable "bft_drawicons");.

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