Frictional Games Forum (read-only)

Full Version: Is it possible to set a message through a string variable?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Question says it all.
Yea.

SetMessage("Messages", GetLocalVarString("StringVar"), 0);

Like this?

if you wanted it the other way around, then no.
You cannot have the .lang file call something from the script.
Oh good. This solves so many of my issues. Thanks.
I thought of something else. nevermind.
Writing GetLocalVarString("") is just another way of writing a word, if the string is tied to a word.

I sometimes have Strings tied to other strings that then is tied to a word.
Are you sure this is working for you Flawless?: SetMessage( "Messages", "I have a cat", 0 );
cause it never did for me, unless the string it's the name of an entry in the language file.

language
PHP Code:
    <CATEGORY Name="Messages">
        <
Entry Name="I have a cat">I have a cat</Entry>
    </
CATEGORY
(08-30-2014, 03:27 PM)FlawlessHappiness Wrote: [ -> ]SetMessage("Messages", GetLocalVarString("StringVar"), 0);

Like what Daemian said, how is it possible? The argument is
PHP Code:
void SetMessage(stringasTextCategorystringasTextEntryfloat afTime); 

The second argument is the Entry in the .lang file. This obviously won't work because the second argument IS FOR the Entry in the Category, NOT FOR a StringVariable.
No, what this does is use a different entry.

PHP Code:
SetMessage("Messages"GetLocalVarString("StringVar"), 0); 

Let's say StringVar is currently "MessageStop"

If you have MessageStop as an entry in your lang file, it will call that one and display its text. For example "You need to stop."

If StringVar is "MessageGo" instead, then it will call the MessageGo entry instead of MessageStop.

So it will display that one's text, for example "You need to go."

@Daemian
Although I think it's possible to use entries with spaces, I don't think you should, just to be safe.
PHP Code:
// lang file
<CATEGORY Name="Messages">
        <
Entry Name="CatMessage">I have a cat</Entry>
</
CATEGORY>

// script
SetLocalVarString("StringVar""CatMessage")
SetMessage("Messages"GetLocalVarString("StringVar"), 0); 

...would work. As long as the 2nd parameter is a string that points to a lang file entry, not the content itself.


Edit - Mr Mudbill beat me to it, but we're pretty much saying the same thing.


Edit Edit:

There's nothing stopping you from doing something like this:
PHP Code:
// lang file
<CATEGORY Name="Messages">
        <
Entry Name="CatYes">I have a cat</Entry>
        <
Entry Name="CatNo">I dont have a cat</Entry>
</
CATEGORY>

// script
string GotCat "No";
SetMessage("Messages""Cat"+GotCat0); 
So eh... yes, I'm sure it'll work ^_^

Yay, people learn!

(08-30-2014, 05:31 PM)First Captain Wrote: [ -> ]
(08-30-2014, 03:27 PM)FlawlessHappiness Wrote: [ -> ]SetMessage("Messages", GetLocalVarString("StringVar"), 0);

Like what Daemian said, how is it possible? The argument is
PHP Code:
void SetMessage(stringasTextCategorystringasTextEntryfloat afTime); 

The second argument is the Entry in the .lang file. This obviously won't work because the second argument IS FOR the Entry in the Category, NOT FOR a StringVariable.

Also this:
Did you notice the SetMessage has string& asTextEntry for the entry?
That little "string&" is the exact reason I can do it. Because it's just a string. A string is a word. It'll just change the LocalVarString to the word it's supposed to be.

I can also confirm that it works, since I'm using it in my Mod.