Jump to content
Sign in to follow this  
Bamse

OnLoad ctrlSetText problem, update control in mod from mission script.

Recommended Posts

Hi!

Let me just open up by I'm way out of my depth here and are primarily asking for pointers, since I want to learn ... but I could go for a solution if I had no other choice ;)

So, I'm making this small addon to TFAR that adds a tape strip to the radio battery where frequencies are written. So far I've just replaced the base texture with a static one and now I'm trying to do it dynamic instead.

To clarify, my main goal with this mod is to make the radio tape frequencies dynamic, as in I want them to be set by the mission maker, either via init.sqf or description.ext (and in the future I'd love to do an editor module).

Screenshot so far: https://dl.dropboxusercontent.com/u/4170539/arma3/mods/source/alpha1.jpg

To do this I'm making a few new controls (one per "label" ... as in Alpha, Bravo etc) as below, and to get some values showing I cheated(?) abit by doing a #define LABEL 999.9 and just set the Alpha control text to LABEL. My first thought that I somehow could update that define via description.ext. No success so far and it seems like the totally wrong way to do it.

So, I've started to figure out how to do a OnLoad= on the actual control, but I really can't get it to work.

To get things kicking, here's a snippet of the config I have in my config.cpp for the moment. Please let me know if you need more.

	class anprc152_radio_dialog {
	onLoad = "if(sunOrMoon < 0.2)then{((_this select 0) displayCtrl TF_BACKGROUND_ID) ctrlSetText '\jtf16_tfar_mod\img\152_n.paa';};";
	controls[] += {Alpha, Bravo, Charlie, LR, JTAC, Air};

	class background: RscBackPicture {
		text = "\jtf16_tfar_mod\img\152.paa";
	};
	class Freqs : RscBackPicture {
		moving = 1;
		style = 0;
		colorBackground[] = {0,0,0,0};
		colorText[] = {0,0,0,1};
		font = "newfuncustomfont";
		w = 0.0599875 * safezoneW;
		h = 0.043175 * safezoneH;
		//shadow = 0.5;
		canModify = 0;
		size = "0.2 * (0.7 / (getResolution select 5))"; //need to adapt this to a proper size
		sizeEx = "(((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 0.80) * (0.7 / (getResolution select 5))"; //used TFARs original code and just changed some numbers to get the size right.
	};	
	class Alpha : Freqs {
		idc = IDC_ANPRC152_ALPHA;
		x = 0.1595 * safezoneW + safezoneX;
		y = 0.811 * safezoneH + safezoneY;
		onLoad = "((_this select 0) displayCtrl IDC_ANPRC152_ALPHA) ctrlSetText ACTUAL_ALPHA_FREQUENCY_VARIABLE_HERE;";
		text = "";
               };
       };
etc ... etc ...

Am I on the right track? Am I doing this totally wrong? As you see I've tried adjusting the OnLoad found on the main display where ctrlSetText is used, but 1. not sure I'm doing it right. 2. Don't actually know how to set that variable properly for MP-use from a mission based script.

Thinking ahead;

If/when I get this working through init or description.ext, will I need to change the anything of what is done here to get an editor module to be able to do the same thing?

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  

×