Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Is it possible to set a message through a string variable?
Neelke Offline
Senior Member

Posts: 668
Threads: 82
Joined: Apr 2013
Reputation: 26
#1
Is it possible to set a message through a string variable?

Question says it all.

Derp.
08-30-2014, 03:19 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#2
RE: Is it possible to set a message through a string variable?

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.

Trying is the first step to success.
(This post was last modified: 08-30-2014, 03:27 PM by FlawlessHappiness.)
08-30-2014, 03:27 PM
Find
Neelke Offline
Senior Member

Posts: 668
Threads: 82
Joined: Apr 2013
Reputation: 26
#3
RE: Is it possible to set a message through a string variable?

Oh good. This solves so many of my issues. Thanks.

Derp.
08-30-2014, 03:31 PM
Find
Daemian Offline
Posting Freak

Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation: 49
#4
RE: Is it possible to set a message through a string variable?

I thought of something else. nevermind.

(This post was last modified: 08-30-2014, 03:36 PM by Daemian.)
08-30-2014, 03:34 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#5
RE: Is it possible to set a message through a string variable?

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.

Trying is the first step to success.
08-30-2014, 03:39 PM
Find
Daemian Offline
Posting Freak

Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation: 49
#6
RE: Is it possible to set a message through a string variable?

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: (Select All)
    <CATEGORY Name="Messages">
        <
Entry Name="I have a cat">I have a cat</Entry>
    </
CATEGORY

08-30-2014, 05:28 PM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#7
RE: Is it possible to set a message through a string variable?

(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: (Select All)
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.
08-30-2014, 05:31 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#8
RE: Is it possible to set a message through a string variable?

No, what this does is use a different entry.

PHP Code: (Select All)
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.

(This post was last modified: 08-30-2014, 06:08 PM by Mudbill.)
08-30-2014, 05:59 PM
Find
MrBehemoth Offline
Senior Member

Posts: 408
Threads: 19
Joined: Feb 2014
Reputation: 40
#9
RE: Is it possible to set a message through a string variable?

PHP Code: (Select All)
// 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: (Select All)
// 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); 

(This post was last modified: 08-30-2014, 06:09 PM by MrBehemoth.)
08-30-2014, 06:02 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#10
RE: Is it possible to set a message through a string variable?

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: (Select All)
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.

Trying is the first step to success.
(This post was last modified: 08-30-2014, 06:32 PM by FlawlessHappiness.)
08-30-2014, 06:29 PM
Find




Users browsing this thread: 1 Guest(s)