Jump to content
Sign in to follow this  
Somerville

CtrlSetText in Description.ext

Recommended Posts

Hi,

I'm trying to create a dialog with ctrlSetText so that it can show a variable in the dialog, if anybody gets what I'm trying to convey?

I have several variables in other scripts that need to be shown in the dialog.

How would I go about doing that?

Thanks!

Share this post


Link to post
Share on other sites
Quote[/b] ] I'm trying to create a dialog with ctrlSetText

Controls are part(-s) of a dialog, but not the dialog per se. Amongst other things, the dialog serves as a named container for controls such as text-fields and the like associated with it (cf. wiki: Dialog control). Hence, you need (to create) a dialog that contains unique controls (via their idc), get access to the controls (e.g. via displayCtrl: wiki) and then use the ctrlSetText on an adequate control (text control) in order to set the text in an appropriate statement.

There are some tutorials out there for creating dialogs, including the wiki-page above, but you might also want to check out dialogs with text-elements that others have already made available to the public.

Share this post


Link to post
Share on other sites

<ot>weedo, is that you in your avatar?</ot>

Somerville, in case you didn't know: hint format[ "%1",varName ] is a good way to display something :=)

Share this post


Link to post
Share on other sites

Okay, I think I might not have been clear enough (I was tired!wink_o.gif

Anywho. I've got a dialog. And where it says "Player Name" next to that on the dialog, I need it to display a player's name, by using the syntax of:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"%1",name _unit

Okay, so if I get the dialog a minute..

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">//Text who is the Account Holder.

class TU_PLAYERTXT : RscTextMedium

{

idc = -1;

style = ST_LEFT;

x = 0.3;

y = 0.3;

w = 0.2;

h = 0.05;

text = "Player:";

This text is the static text to the left.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> class TU_HOLDERTXTC : RscTextMedium

{

idc = 105;

style = ST_LEFT;

x = 0.45;

y = 0.3;

w = 0.5;

h = 0.05;

text = "PLAYER NAME";

Next to this, I need to have the name obviously. However, I can't put the %1 thing into where it says player name, which is a pain ><

Share this post


Link to post
Share on other sites

Didn't you read what weedo wrote? huh.gif MayB I'm just getting your question wrong but he already described what you have to do. Roughly speaking:

myDisplay = findDisplay <span style='color:red'>-The IDD of your Dialog here-</span>;

myPlayerText = myDisplay displayCtrl 105;

myPlayerText ctrlSetText format[ "%1",player ];

Share this post


Link to post
Share on other sites

Ehm, pardon me, I don't have a clue about dialogs, but what if you put

format["%1", name _unit]

there?

[edit]I was typing this too slow, ManDay got ahead of me smile_o.gif

Look at the post times ya all. 2 mins.

Didn't mean to "correct" ManDay at all, especially since I don't have a clue about these things.

[/edit]

Share this post


Link to post
Share on other sites

Okay, so I've got that now, but where do I put what you've just posted? And how to I find the IDD of the dialog itself?

(Sorry for all this by the way!wink_o.gif

Share this post


Link to post
Share on other sites

You don' have to say sorry mate - you didn't kill anybody with your questions yet.

Thanks, Taurus. Of course its "name player" and not just "player" because this will return the editor-ident if it's set.

So sommerville, this requires a script. There will be some point in your mission where you call up your dialog like

myDiagOpen = createDialog "myDialog";

Right after this like (statement) you put what I just posted (just use what taurus said instead of [ ...,player ] you got [ ...,name player ].

The idd of your dialog you have to dfine yourself.

In the description.ext you supposedly have got something like

class myDialog

{

idd = 12432314;

controls[ ]={};

etc... This is the idd you need.

Share this post


Link to post
Share on other sites

as >ctrl< settext is a control command, you can change the value in a control (e.g. your textfield with idc 105) inside a RUNNING & VISIBLE dialog by:

ctrlsettext [105,"Your Text"];

regards,

zap

Share this post


Link to post
Share on other sites
... inside a RUNNING &  VISIBLE dialog

Not really, if you mean visible as in showing it. AFAIR you can set and update text while the ui-element is not displayed ( i.e. ctrlShown _theControl == false), and show it at a later stage. The control certainly has to be enabled and active, though, no doubt.

@Manday: Are there really such things as Transformers in space? J/K, nm. B]

Share this post


Link to post
Share on other sites

@catweazle: yes showing ...

english isn't my mother language ... i just play with it like i do with arma scripting language ... but i hope enough that people get the content.

Share this post


Link to post
Share on other sites

huh? Never mind, I just meant it does not necessarily have to be shown in order to change it.

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  

×