Neelke
Senior Member
Posts: 668
Threads: 82
Joined: Apr 2013
Reputation:
26
|
Is it possible to set a message through a string variable?
Question says it all.
Derp.
|
|
08-30-2014, 03:19 PM |
|
FlawlessHappiness
Posting Freak
Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation:
171
|
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.
|
|
08-30-2014, 03:27 PM |
|
Neelke
Senior Member
Posts: 668
Threads: 82
Joined: Apr 2013
Reputation:
26
|
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 |
|
Daemian
Posting Freak
Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation:
49
|
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 |
|
FlawlessHappiness
Posting Freak
Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation:
171
|
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 |
|
Daemian
Posting Freak
Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation:
49
|
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 <CATEGORY Name="Messages"> <Entry Name="I have a cat">I have a cat</Entry> </CATEGORY>
|
|
08-30-2014, 05:28 PM |
|
PutraenusAlivius
Posting Freak
Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation:
119
|
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
void SetMessage(string& asTextCategory, string& asTextEntry, float 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 |
|
Mudbill
Muderator
Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation:
179
|
RE: Is it possible to set a message through a string variable?
No, what this does is use a different entry.
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 |
|
MrBehemoth
Senior Member
Posts: 408
Threads: 19
Joined: Feb 2014
Reputation:
40
|
RE: Is it possible to set a message through a string variable?
// 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:
// 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"+GotCat, 0);
(This post was last modified: 08-30-2014, 06:09 PM by MrBehemoth.)
|
|
08-30-2014, 06:02 PM |
|
FlawlessHappiness
Posting Freak
Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation:
171
|
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
void SetMessage(string& asTextCategory, string& asTextEntry, float 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.
|
|
08-30-2014, 06:29 PM |
|
|