Jump to content
Liberty Bull

Help with printing variables inside of structured text?

Recommended Posts

**** Figured out the solution through trial and error, if anyone is curious, here is the working code.

nametagALayer = "nametagA" call BIS_fnc_rscLayer;

	_textnametaga = parseText format ["<t font ='RobotoCondensedBold' align = 'left' size='0.6' color='#ffb742' shadow='2'>%1</t>", name cursorObject];
	[_textnametaga, 1.0,0.0,/*durata*/ 30,/* fade in?*/ 0,0,nametagALayer] spawn BIS_fnc_dynamicText;

 

 

 

I am trying to get text to pop up with the name of the AI you are looking at. This following code is executed from an SQF file and works to deliver text I fill in, but instead of making a custom sqf for each AI name, I'd rather make it work so it grabs the characters name from the game.

nametagALayer = "nametagA" call BIS_fnc_rscLayer;

	_textnametaga = "<t font ='RobotoCondensedBold' align = 'left' size='0.6' color='#ffb742' shadow='2'>" + "Easy Pete"+"</t>";
	[_textnametaga, 1.0,0.0,/*durata*/ 30,/* fade in?*/ 0,0,nametagALayer] spawn BIS_fnc_dynamicText;

Now, when I put this into a hint, the hint does what I want.

hint format ["%1", name cursorObject]

But I am having trouble figuring out how to mesh the two concepts. I am pretty new to scripting so I am sure I am making obvious mistakes that I don't realize.

 

So trying to put it this way below only results in the "format ["%1", name cursorObject]" literally being the text that appears.

nametagALayer = "nametagA" call BIS_fnc_rscLayer;

	_textnametaga = "<t font ='RobotoCondensedBold' align = 'left' size='0.6' color='#ffb742' shadow='2'>" + "format ["%1", name cursorObject]"+"</t>";
	[_textnametaga, 1.0,0.0,/*durata*/ 30,/* fade in?*/ 0,0,nametagALayer] spawn BIS_fnc_dynamicText;

 

Any messing around I'm doing isn't resulting in what I'm going for, could someone help me with this?

 

***Edit***

After more research I tried this which seems like it is the proper way, but it is still giving me an error.

nametagALayer = "nametagA" call BIS_fnc_rscLayer;

	_textnametaga = parsetText format ["<t font ='RobotoCondensedBold' align = 'left' size='0.6' color='#ffb742' shadow='2'>%1</t>", name cursorObject];
	[_textnametaga, 1.0,0.0,/*durata*/ 30,/* fade in?*/ 0,0,nametagALayer] spawn BIS_fnc_dynamicText;

 

Share this post


Link to post
Share on other sites

 

oh jesus, *facepalm* and I thought I figured something out different with the solution I put up top in an edit, not even realizing I had gotten it right in the end but made a typo. Thanks a million!

Share this post


Link to post
Share on other sites

Im gonna piggyback ride here as ive never been any good with this kinda structured text but really like it

 

Anyways id like to be able to place more text as well as a variable that determines a units concealment level

 

nametagALayer = "nametagA" call BIS_fnc_rscLayer; 
 _c= cursortarget getunitTrait "camouflageCoef"; t = hint str format ["This soldier's concealment level is %1",_c];
 _textnametaga = parseText format ["<t font ='RobotoCondensedBold' align = 'left' size='0.6' color='#ffb742' shadow='2'>%1</t>", t  ]; 
 [_textnametaga, 1.0,0.0, 30,0,0,nametagALayer] spawn BIS_fnc_dynamicText;

 

where im using '_c' as local variable to determine concealment level and then a global variable 'T' to hopefully carry that variable and text down to the next level but it always returns onscreen as "ANY"

Share this post


Link to post
Share on other sites

@froggyluv did you try this by removing the "hint" and just use t = str format ["This soldier's concealment level is %1",_c];?

Share this post


Link to post
Share on other sites
24 minutes ago, panther42 said:

@froggyluv did you try this by removing the "hint" and just use t = str format ["This soldier's concealment level is %1",_c];?

 

BINGO!!!

 

Thanks mate -works like a button

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

×