Need help displaying stats.

Started by Diji1, Thu 17/01/2008 15:42:11

Previous topic - Next topic

Diji1

Hey.
I have a problem with displaying my magic points in the GUI.
Here is the code I have -

function repeatedly_execute() {

String magic;
String.Format(magic, "%d", GetGlobalInt(2));
lbla.Text=String.Format(0, 4,  magic));

}

The error message I am given says -
Type Mismatch : cannot convert 'int' to 'const string'

Help a noobie plz?

Ubel

This is what you'll want to do:

Code: ags

function repeatedly_execute() {
    lbla.Text = String.Format("Magic: %d", GetGlobalInt(2));
}

Diji1

thank you so much!
thats sorted the problem out.

Radiant

Quote from: Diji1 on Thu 17/01/2008 15:42:11
lbla.Text=String.Format(0, 4,  magic));

While the solution has already been given by Pablo, the problem is in the line above. The first and second arguments to String.Format need to be strings, not integers.

Khris

If by the "0, 4" stuff you wanted to display leading zeros, here's the proper way (with the corrected intermediate step):
Code: ags
function repeatedly_execute() {

  String magic;
  magic = String.Format("%04d", GetGlobalInt(2));
  lbla.Text= magic;

}

But, as was shown, using a variable isn't necessary here.

SMF spam blocked by CleanTalk