Jump to content
Sign in to follow this  
Jona33

Line Break in text

Recommended Posts

As a follow up to the redress functions I released a little while ago I've been tidying up the script I use to extract the loadout from game but am running into a problem. Basically it works fine but I'm trying to tidy it up a bit and include line breaks.

I've tried two different methods, one from https://community.bistudio.com/wiki/lineBreak there so my code looks like

_text=composeText [_TextArray select 0,lineBreak,_TextArray select 1,linebreak,str (_ClothingArray)];

(I've shortened it a bit but you get the idea)

and the other one from here

https://community.bistudio.com/wiki/Structured_Text so my code looks like

_separator1= parseText "<br />------------------------<br />";
_text=composeText [_TextArray select 0,_separator1,_TextArray select 1,_separator1,str (_ClothingArray)];

In both cases everything is outputted fine but the line breaks are completely ignored, it's like it just skips over them. Has anyone got any ideas?

Share this post


Link to post
Share on other sites

[color="#FF8040"][color="#191970"][b]hint[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#191970"][b]composeText[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"Ah"[/color][color="#8B3E2F"][b],[/b][/color][color="#191970"][b]lineBreak[/b][/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"Ahah"[/color][color="#8B3E2F"][b],[/b][/color][color="#191970"][b]lineBreak[/b][/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"Ahaha"[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b])[/b][/color][/color]

Made with KK's SQF to BBCode Converter

no problem here

Edited by Killzone_Kid

Share this post


Link to post
Share on other sites
[url="http://killzonekid.com/sqf-to-bbcode-converter/"][color="#FF8040"][color="#191970"][b]hint[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#191970"][b]composeText[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"Ah"[/color][color="#8B3E2F"][b],[/b][/color][color="#191970"][b]lineBreak[/b][/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"Ahah"[/color][color="#8B3E2F"][b],[/b][/color][color="#191970"][b]lineBreak[/b][/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"Ahaha"[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b])[/b][/color][/color][/url]

no problem here

Ok I realised, I was using hint format and copyToClipboard (str (_text)); which obviously destroys the formatting. However it appears that copyToClipboard only works with a string, otherwise you get an "Error type Text expected String" message. Is there a way to copy structured text to clipboard (I'm sure there is, since BI have managed to use formatting when exporting loadouts from the virtual arsenal).

Share this post


Link to post
Share on other sites

Thanks, I'll try experimenting with that in a bit.

Share this post


Link to post
Share on other sites

_AOstr = parseText format ["<t align='center' size='2.0'>Mission Status</t><br/>
	______________<br/><br/>
	Good work squad.<br/>
	The AO has been cleared!<br/>
	<br/>
	Stand by for further orders."];

		GlobalHint = _AOstr;
		publicVariable "GlobalHint";

I have used this in the past to let players know when a mission AO had been cleared. Can't remember where I picked that trick up but I loved since the first time I realized I could format a hint any way I wanted. Text size, color, whatever.

Share this post


Link to post
Share on other sites
_AOstr = parseText format ["<t align='center' size='2.0'>Mission Status</t><br/>
	______________<br/><br/>
	Good work squad.<br/>
	The AO has been cleared!<br/>
	<br/>
	Stand by for further orders."];

		GlobalHint = _AOstr;
		publicVariable "GlobalHint";

I have used this in the past to let players know when a mission AO had been cleared. Can't remember where I picked that trick up but I loved since the first time I realized I could format a hint any way I wanted. Text size, color, whatever.

Cheers, I'll try and get that to work.

Share this post


Link to post
Share on other sites

Don't know if you got that to work, but since I had typed that off the top of my head, I forgot that you have to do the parseText format on the client side, just before the hint. So for getting it formatted server side then having it look good client side:

serverside

_AOstr = "<t align='center' size='2.0'>Mission Status</t><br/>
	______________<br/><br/>
	Good work squad.<br/>
	The AO has been cleared!<br/>
	<br/>
	Stand by for further orders.";

		GlobalHint = _AOstr;
		publicVariable "GlobalHint";

client side

"GlobalHint" addPublicVariableEventHandler
{
private ["_GHint"];
_GHint = _this select 1;
hint parseText format["%1", _GHint];
};

Hope that helps!

Share this post


Link to post
Share on other sites
Don't know if you got that to work, but since I had typed that off the top of my head, I forgot that you have to do the parseText format on the client side, just before the hint. So for getting it formatted server side then having it look good client side:

serverside

_AOstr = "<t align='center' size='2.0'>Mission Status</t><br/>
	______________<br/><br/>
	Good work squad.<br/>
	The AO has been cleared!<br/>
	<br/>
	Stand by for further orders.";

		GlobalHint = _AOstr;
		publicVariable "GlobalHint";

client side

"GlobalHint" addPublicVariableEventHandler
{
private ["_GHint"];
_GHint = _this select 1;
hint parseText format["%1", _GHint];
};

Hope that helps!

Thanks for the advice, I haven't got around to trying it yet (but got some free time today). Fortunately this is SP as the whole locality stuff boggles my mind, it's used to export loadouts so would be used during development and deleted at the end.

Share this post


Link to post
Share on other sites

I went back and while my code works perfectly for hints, I couldn't make it work for copytoclipboard. I remembered a script I used for exporting all of a designated config file to clipboard and was able to modify it.

_CRLF = toString [0x0D, 0x0A];
_array1=["hello","nothing","to","see","here"];
_uid=getPlayerUID player;
_cursorTarget=cursorTarget;
_typeOfCursorTarget = typeOf _cursorTarget;
_hint= format["_cursorTarget=%1%2_typeOfCursorTarget=%3%2%4%2%5%2%6%2%7%2%8" ,_cursorTarget,_CRLF,_typeOfCursorTarget,_array1 select 0,_array1 select 1,_array1 select 2,_array1 select 3,_array1 select 4];
copyToClipboard _hint;

while looking at an MRAP in game this is the output to clipboard directly from in game:

_cursorTarget=460e2b00# 2357184: mrap_01_gmg_f.p3d

_typeOfCursorTarget=B_MRAP_01_gmg_F

hello

nothing

to

see

here

So just place

_CRLF = toString [0x0D, 0x0A];

in your script and use that in whatever string you are formatting to force a line break in the copytoclipboard

Share this post


Link to post
Share on other sites
I went back and while my code works perfectly for hints, I couldn't make it work for copytoclipboard. I remembered a script I used for exporting all of a designated config file to clipboard and was able to modify it.

_CRLF = toString [0x0D, 0x0A];
_array1=["hello","nothing","to","see","here"];
_uid=getPlayerUID player;
_cursorTarget=cursorTarget;
_typeOfCursorTarget = typeOf _cursorTarget;
_hint= format["_cursorTarget=%1%2_typeOfCursorTarget=%3%2%4%2%5%2%6%2%7%2%8" ,_cursorTarget,_CRLF,_typeOfCursorTarget,_array1 select 0,_array1 select 1,_array1 select 2,_array1 select 3,_array1 select 4];
copyToClipboard _hint;

while looking at an MRAP in game this is the output to clipboard directly from in game:

_cursorTarget=460e2b00# 2357184: mrap_01_gmg_f.p3d

_typeOfCursorTarget=B_MRAP_01_gmg_F

hello

nothing

to

see

here

So just place

_CRLF = toString [0x0D, 0x0A];

in your script and use that in whatever string you are formatting to force a line break in the copytoclipboard

Now that is very useful, huge thank you for all your help.

EDIT: That works perfectly, precisely what I needed. Thank you very much.

Edited by Jona33

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  

×