[SCRIPT] Is it possible to set a message through a string variable? - Printable Version +- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum) +-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html) +--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html) +---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html) +---- Thread: [SCRIPT] Is it possible to set a message through a string variable? (/thread-26002.html) |
Is it possible to set a message through a string variable? - Neelke - 08-30-2014 Question says it all. RE: Is it possible to set a message through a string variable? - FlawlessHappiness - 08-30-2014 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. RE: Is it possible to set a message through a string variable? - Neelke - 08-30-2014 Oh good. This solves so many of my issues. Thanks. RE: Is it possible to set a message through a string variable? - Daemian - 08-30-2014 I thought of something else. nevermind. RE: Is it possible to set a message through a string variable? - FlawlessHappiness - 08-30-2014 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. RE: Is it possible to set a message through a string variable? - Daemian - 08-30-2014 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"> RE: Is it possible to set a message through a string variable? - PutraenusAlivius - 08-30-2014 (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(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. RE: Is it possible to set a message through a string variable? - Mudbill - 08-30-2014 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. RE: Is it possible to set a message through a string variable? - MrBehemoth - 08-30-2014 PHP Code: // lang file ...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 RE: Is it possible to set a message through a string variable? - FlawlessHappiness - 08-30-2014 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); 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. |