Changing Variable Value to Word

I'm not the best at explaining things, so I'll do the best I can, and thanks in advance.


So, I was wondering if there was a way to make it so that instead of making text show a specific value, it would instead show a word.


For example:


I know if you put; Hunger: \V[0001], it'll show something like Hunger: 80.


However, is there a way to make it display in a way like "Hunger: Very Hungry" instead of displaying a numerical value?
Not that I'm aware, though that doesn't mean it's impossible. You could set dummy actors with the names of what you wanted displayed and call the actor name, I suppose.


I think what I would do though would be to create some conditional branches, without else statements. So, for example, If Variable = 1, show text "Hunger: Very Hungry"; If Variable = 2, show text "Hunger: Hungry", etc.
yes and no - you can store strings, but they need to come from somewhere, and you can't calculate with them anymore.


You have to keep the variable as a number to be able to work with that ingame, but you can use a second variable - one that won't be needed for calculations - to store a string inside, and then use a short conversion code somewhere to give different strings based on original numbers.
Alright, I think I gotcha. Thanks again.
Like this:
VeryHungry.jpg
But like Andar said, you can't calculate with them. You're gonna have to manipulate the string with another command.
No, that is not what is meant by "Script" there - that is a place to input RGSS3 code, not display text.
Um setting a string to a variable is valid code? Which I think is what @TheAlexG was asking.
Okay, I misunderstood what it was saying.


No, actually I don't think I did. OP wanted to know how to display a certain text based on the value of the variable. So, even if it could set the value of a variable equal to the number of letters in a string of text, it's not what they are asking.


However, I don't think just typing the string into the Script section would work. You would need to add a line of code in the Script section, not just a string of text.
Hum. Variables are fully capable of holding strings.


Using the method @x3Darkie showed and a few conditional branches you could very well do a system to have an automated message.


Well I mean it would be almost  the same as using conditionnals and placing a show text command after each hunger text possibilty, just less maintenance if you want to change the message.


You can store anything in a variable using the script command really, whole objects (like windows, actors,...) if you wanted. You have to make the following calculations using the script command after but in that case it's not needed. It's very useful to modify the display without creating a whole plugin for example.


Using control variable script: "very hungry" and then using \V[your_number] will display very hungry. 100% certain, I use it all the time. And unless I completely misunderstood the OP it's indeed what was asked here.
Okay, wow, well, I just learned something.


I wanted to test out inputting the string of text into the Script line, to see if it would return a value. It actually returned the string of text. So, apparently you can use \V[n] to directly display text. My apologies. Perhaps this is what Andar was saying and I just wasn't getting that?


I had thought you would need a script call or something there, as opposed to just text. Thanks for teaching me something new.
They pretty much have the right of it. I got the basis down, which was a great jumping point. I just need to fix the code, since I'm getting a bit of an error. It'll display Hunger: Very Hungry, and then numerals after as when you move from each area, I have an event in each area adding or decreasing stats. So it's displaying Hunger: Not Hungry5555etc. I just have to figure out what it's doing to stop it. XP
As previously mentioned, you can't do calculations with strings. What you can do instead is to hold the string in a different variable. Say variable 2. So you'd have variable 1 to hold the hunger value, and variable 2 to hold the string and use that to display your text. And make a common event with conditional branches for each stage of hunger. At >80 variable 1, set variable 2 to "Very Hungry," and so on and so forth.

I have no idea what you're trying to do with this as I don't have the context, but if you don't want to use a second variable to hold the text, you may as well just simply use conditional branches to read the hunger stage. This method is only really useful when you're working with multiple conditions dialogues or texts. I managed to shaved off an entire nest of conditional branches of texts using this method.

Oh, and for the record, I found out you can hold a string in a variable in one of the older threads in the VX Ace subforums, so I wasn't the one who figured this out in the first place.
Basically, I'm trying to make a journal that reads off various stats. I tried doing this as a whole page, with Yanfly's Message Core plugin, but each time I use an if statement, it counts as a new page. So I have to get them to read stats on a whole page, while also counting it as one page. Numbers work fine, but when you're trying to use anything else, it starts to get wonky.


None the less, I think I have it working, so thanks.

Original thread: https://forums.rpgmakerweb.com/threads/changing-variable-value-to-word.69819/