Author Topic: A couple questions.  (Read 778 times)

I want to make a GUI display a variable in a text control, where the GUI equals the player name.

How can I display a variable in a text control?

How do I make said variable equal a string, where the string equals $Pref::Player::NetName?

textCtrlID.setText("Stuff" @ %var/$var);

Examples:
textCtrl.setText("Welcome, " @ $Pref::Player::NetName @ "!");
  Prints "Welcome, <your name>!"
textCtrl.setText("my text control name: " @ textCtrl.getName());
  Prints "my text control name: textCtrl"

in a function
%someStringHere = "hello";
textCtrl.setText("my text: " @ %someStringHere);
  Prints "my text: hello"

%x = 3;
%y = 2;
%z = 5;
textCtrl.setText("my coords: " @ %x SPC %y SPC %z);
  Prints "my coords: 3 2 5"

textCtrlID.setText("Stuff" @ %var/$var);

Examples:
textCtrl.setText("Welcome, " @ $Pref::Player::NetName @ "!");
  Prints "Welcome, <your name>!"
textCtrl.setText("my text control name: " @ textCtrl.getName());
  Prints "my text control name: textCtrl"

in a function
%someStringHere = "hello";
textCtrl.setText("my text: " @ %someStringHere);
  Prints "my text: hello"

%x = 3;
%y = 2;
%z = 5;
textCtrl.setText("my coords: " @ %x SPC %y SPC %z);
  Prints "my coords: 3 2 5"

It's THAT easy? There's no catch?

There's no catch at all, TorqueScript is a very easy language to learn

Of course if you change the local/global vars you will have to call it again so it displays the new text with the updated vars