GUIButtonLocation.Text = "talk to ".Append(locationname);
give me a error
why i cant do it? ???
o/
It's in the manual, but it can be a bit confusing.
First of all....
SetText (button)
(Formerly known as SetButtonText, which is now obsolete)
Button.SetText(string newtext)
Changes the text displayed in the specified button to NEWTEXT.
Example:
btnController.SetText("Enable jibble");
will change button btnController to read 'Enable jibble'.
See Also: Button.GetText, Button.NormalGraphic, Label.SetText
and you'll also want to use
StrCat
StrCat (string str1, string str2)
Appends STR2 to the end of STR1.
Example:
string name;
StrCopy(name,"My name is ");
StrCat (name,"Chris");
will result a string name which will be "My name is Chris".
so for your problem you'd do
string text;
StrCat(text, "talk to ");
StrCat(text, locationname);
GUIButtonLocation.SetText(text);
I know, but you used string type, I want to do it with String type
I resolved the problem in another way
but the problem is that
I can do this:
String lookat;
lookat = "look at "
lookat.Append(locationname);
and can't do this:
"look at ".Append(locationname);
o/
That's because anything between quotation marks (") is defined (internally) as a const string, not a String. You could, however, do:
GUIButtonLocation.Text = String.Format("%s%s", "talk to ", locationname);
Also, Worm III, this is 2.71 code, not 2.7, so it's a wee bit different. ;)
thanks for the help
o/
You're welcome...but I noticed that I did something kind of silly. You could have just put:
GUIButtonLocation.Text = String.Format("talk to %s", locationname);
Instead of doing the "%s%s" thing...not much of a difference...but it's a bit simpler that way. It will still do the same thing.