Jump to content
Sign in to follow this  
lato1982

Values and Variables in Dialog: RscText

Recommended Posts

Hi,

I'm starting to play around with dialogs scripting and already have a first issue. How can I add a dialog text that will return values?

I need a dialog box that shows me number of kills

Example:

class FRAME_01
{

idd = 1;
movingenable = false;

class Controls
{
	class FRAME_01: RscFrame
	{
		idc = 1800;
		text = "Platoon Stats";
		x = 0.352344 * safezoneW + safezoneX;
		y = 0.255 * safezoneH + safezoneY;
		w = 0.311719 * safezoneW;
		h = 0.455 * safezoneH;
	};
	class RscText_1000: RscText
	{
	idc = 1000;
	text = "Soldier1 kills: "+(str Soldier1kills);

	x = 0.423944 * safezoneW + safezoneX;
	y = 0.527789 * safezoneH + safezoneY;
	w = 0.158718 * safezoneW;
	h = 0.0257144 * safezoneH;
	};
};
};

this is really hard, because it crashes the game:

of course replacing the text line fixes the problem

text = "Soldier1 kills: ";

How can I use in this text a returned value?

Share this post


Link to post
Share on other sites

Doesnt work - it returns in dialog:

'Soldier1 kills: ' + str Soldier1kills

instead of value

Share this post


Link to post
Share on other sites

ok gimmie a minute

---------- Post added at 23:25 ---------- Previous post was at 23:20 ----------

use onload to modify text

class FRAME_01 
{ 

   idd = 1; 
   movingenable = false; 
onLoad = "_this call FRAME_01_Load";

   class Controls 
   { 
       class FRAME_01: RscFrame 
       { 
           idc = 1800; 
           text = "Platoon Stats"; 
           x = 0.352344 * safezoneW + safezoneX; 
           y = 0.255 * safezoneH + safezoneY; 
           w = 0.311719 * safezoneW; 
           h = 0.455 * safezoneH; 
       }; 
       class RscText_1000: RscText 
       { 
       idc = 1000; 
       text = ""; 

       x = 0.423944 * safezoneW + safezoneX; 
       y = 0.527789 * safezoneH + safezoneY; 
       w = 0.158718 * safezoneW; 
       h = 0.0257144 * safezoneH; 
       }; 
   }; 
}; 

add somewhere in the code

FRAME_01_Load = {((_this select 0) displayCtrl 1000) ctrlSetText format ["Soldier1 kills: %1", Soldier1kills]};

Share this post


Link to post
Share on other sites

Thanks!!

Could you please just explain in few words what is happening there?

what is "_this" in the onLoad line?

also why the text label is empty? how will it work?

what does this line?

(_this select 0) displayCtrl 1000

Thanks for your time!

Share this post


Link to post
Share on other sites

When your dialog is created, the onLoad-field is being executed, which in return will call the function named "FRAME_01_Load".

_this is an array in that context of the dialog which contains the reference to the dialog in the first element.

So what the function does is: Get the control you want to modify (displayCtrl gets you the child-control of a control, in this case your dialog), and using ctrlSetText you can modify the text your control holds at any time.

Everytime you create your dialog the text will be filled accordingly.

Share this post


Link to post
Share on other sites
(_this select 0) displayCtrl 1000

_this in onLoad contains display reference like this [display] so to get it you need to

_this select 0 inside your function. The rest you can find out by reading displayCtrl documentation on wiki.

Share this post


Link to post
Share on other sites

Thanks !

but how come, this field is left empty:

text = "";

how can this be filled correctly? also if I would have few more Text frames and I want to use different texts per frame?

Example:

        class RscText_1000: RscText 
       { 
       idc = 1001; 
       text = ""; 

       x = 0.423944 * safezoneW + safezoneX; 
       y = 0.527789 * safezoneH + safezoneY; 
       w = 0.158718 * safezoneW; 
       h = 0.0257144 * safezoneH; 
       }; 
       class RscText_1000: RscText 
       { 
       idc = 1002; 
       text = ""; 

       x = 0.423944 * safezoneW + safezoneX; 
       y = 0.527789 * safezoneH + safezoneY; 
       w = 0.158718 * safezoneW; 
       h = 0.0257144 * safezoneH; 
       }; 
       class RscText_1000: RscText 
       { 
       idc = 1003; 
       text = ""; 

       x = 0.423944 * safezoneW + safezoneX; 
       y = 0.527789 * safezoneH + safezoneY; 
       w = 0.158718 * safezoneW; 
       h = 0.0257144 * safezoneH; 
       }; 

Share this post


Link to post
Share on other sites

The field is empty because it doesnt matter what you put in it it will get overwritten with ctrlSetText anyway. As for different frames, I dont understand why you need 3 identical frames with different idcs

Share this post


Link to post
Share on other sites

I wanted to list like 8 soldiers, all with kill stats. It felt natural to me to make 8 text frames, to have a better align control.

Share this post


Link to post
Share on other sites

Well all 3 frames have the same alignment so I couldn't understand why you need to overimpose them. But if you are planning to have them in different places then I see no problem why you can't update them all at the same time considering you have different idcs, you can just run multiple ctrlSetText on load, one for each frame.

Share this post


Link to post
Share on other sites

I'm just starting with dialogs so my design idea is probably wrong. Thanks for all the help, I think I'll try this out (still a bit confused about the onLoad command) and get back to this topic when I have some more code.

Thanks Again!

btw. Cool blog ! :)

Share this post


Link to post
Share on other sites

See my design ideas in this post of mine:

http://forums.bistudio.com/showthread.php?153884-loadable-permanent-GUI&p=2384203&viewfull=1#post2384203

The onLoad command does a simple thing: it triggers, when the display is loaded. The part after that makes sure that the display ID where the control is, is saved to a UInamespace variable, so you don't have to search it all the time when you want to send data to it. (_this select 0 is the _this of onLoad, which has the control ID on index 1)

Actually this is not as bad as it seems. :) I used to pull my hair one by one some time ago when trying to make a working permanent gui, but if you get the point it will get really simple.

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  

×