Jump to content
Sign in to follow this  
vincentz

getting hint left aligned and without "" and []

Recommended Posts

I made this script which shows the unit number and class as many of the uniticons look the same, and I have randomized the units given when recruiting.

However it doesnt really show as I would like it to be :(

Here is a screenie : http://i.imgur.com/j8QGsXX.png (1286 kB)

I cant get it to left align, and I would love for it to be the number (3) of the soldier and not the whole group ID B 1-1-A:3.

Also all the "" and [] is no good :(

Best way would be :

2 - Pilot

3 - Assault Rifleman

4 - Assault Rifleman

5 - Engineer

etc.

Help needed please :D

script :

_fullsquad = [];
_ugp = units group player;
_cugp = count units group player;
for "_i" from 1 to _cugp-1 do {
_type = _ugp select _i;
_dispname = getText (configFile >> "cfgVehicles" >> typeof _type >> "displayName");
_fullsquad = _fullsquad + [_type, _dispname, "\n"]; 
};
hint format ["%1", _fullsquad];

Share this post


Link to post
Share on other sites

There :)

_typeToNr = {
private["_start","_typeAsArray","_nr"];
_typeAsArray = toArray str _this;
_start = (_typeAsArray find 58) + 1;
_nr = [];
for "_i" from _start to (count _typeAsArray)-1 do {
	_nr = _nr + [_typeAsArray select _i];
};
toString _nr
};

_squadHint = {
private["_squadstring","_ugp","_cugp","_type"];
_squadstring = "";
_ugp = units group player;
_cugp = count units group player;
for "_i" from 1 to _cugp-1 do {
	_type = _ugp select _i;
	_squadstring = format["%1<t align='left'>%2 - %3</t><br/>",
		_squadstring,
		_type call _typeToNr,
		getText (configFile >> "cfgVehicles" >> typeof _type >> "displayName")
	];
};
hint parseText _squadstring;
};

  • Left align is achieved by using align attribute of structured text.
  • Getting rid of " and [] by using actual strings for format arguments (you used an array).
  • Isolating the number from the type-string is done manually by help of toArray and toString.

Even though the various icons along the face-profiles of the units at the bottom of the screen already tell you pretty much everything.

Share this post


Link to post
Share on other sites

Thanks :D

I cant get it to work though. I can see there is a Call, should I put the _typeToNr in separate file and compile it from init?

The reason why I needed it, was especially the Force Recons : Demolition/FAC/Saboteur. With a max (at full rank) of 40 AI, it can be quite difficult to quickly find the demo guy and sent him to the factory, or when the A10 is flying overhead the FAC guy should be ready with the laser. Also I like to take the inf with SD weapons and send them ahead. :D

Share this post


Link to post
Share on other sites

It works for me if I just put the definitions (the script above) in a spawn and start calling _squadHint in a loop every second (in the same spawn naturally, unless you've modified it and made it global; also in a loop, you would likely prefer hintSilent there). However using this method I can only seem to display up to ~45 units (hitting hint string-length limit?, even though I know I've displayed stuff off the screen even with hint, so I'm not sure), so alternatively you could display the info on a dialog control using cutRsc.

Or if you feel like putting more time into it, you could go a step further and make an interface to select a specific unit type (some leads to topics related to the various ways of doing that - addAction, showCommandingMenu, dialog control, groupSelectUnit).

EDIT: The reason for the hint cutting off was format's output limit, so you'd need to replace the respective part in the above code with -

...
       _squadstring = _squadstring + format["<t align='left'>%1 - %2</t><br/>",
           _type call _typeToNr,
           getText (configFile >> "cfgVehicles" >> typeof _type >> "displayName")
       ];
...

Edited by geqqo

Share this post


Link to post
Share on other sites

mmm. its very strange. I'm obviously doing something very wrong, but I tried to put it in both a Radio Channel (Juliet) and as an addAction on the player, and I'm still not getting anything.

Can you maybe try to look at my mission to see what I'm doing wrong? (I know its a bit much to ask :D)

(the radiochannel : Request Reinforcements, will supply you with plenty of "material" ;))

I put it as an addaction in init, and as a radio trigger (on top) in scripts/triggers.

<<removed file as it had a very bugged afterburner>>

edit. lol, I have no idea what a spawn is and how to make loops. I've just started scripting 14 days ago, and the whole Calling thing is above my paygrade.

I have figured it out now :D

Thanks alot for the help, it looks AMAZING ;)

Edited by vincentz

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  

×