Displaying values as 'Labels'

Started by error17, Tue 02/10/2007 04:29:49

Previous topic - Next topic

error17

I have 2 questions: I need to find a way around this, or add these to AGS 2.8

Q1. I am trying to find out how to display a few values through the 'Label' in GUI. for example, I want to display the amount of cash using the label (but not displaying as a score (@SCORE@).

Q2. Is there anyway to activate an 'IF' command if the player types in a set string into the text parser. for example, the player sets a username as a string, then wants to log in, how do I set it so the parser recognises that I have typed in a certain string?

monkey0506

Q1:

Code: ags
lblCash.Text = String.Format("%d dollars", cash);


Where lblCash is your Label's script o-name and cash is your "cash" variable.

Q2:

I guess you're just looking for Parser.Said.

Code: ags
String parsedText = txtParser.Text;
Parser.Parse(parsedText);
if (Parser.Said("username1")) {
  // do stuff
  }
else if (Parser.Said("username2")) {
  // do other stuff
  }
else {
  String unknown = Parser.SaidUnknownWord();
  if (unknown != null) Display("This parser does not recognize the word %s.", unknown);
  }

error17

#2
Yer, Q1 looks answered but how do I create a variable called "Cash"?, and for Q2, I want the player to set the username as to anything like "error17" or something;

monkey0506

What do you mean you want to set it as to anything?

If you want to set the username in one place you could just store it in a String in the global script:

Code: ags
String username;
export username;

// set username function -- maybe the activation function for text box txtUsername
username = txtUsername.Text;


Be sure to import the variable in the script header:

Code: ags
import String username;


Then from any script (global or room script) you can do like this:

Code: ags
String enteredName = txtUserprompt.Text;
if (enteredName == username) {
  // entered correct username
  }
else Display("you entered the wrong username");


That only allows for one username, but it might be useful to know what you're trying to achieve.

SMF spam blocked by CleanTalk