Random variable to text.

Hello forum dweller of Rpg maker 🙂


I've started making my own project recently, and it's going pretty well but now I've encountered a problem wich seems too hard for me to solve.


I checked the forums to see if there was a another thread about this problem but I couldn't find one, so if this problem has been solved already would you mind putting a link to the thread? :x


First off, I'm using RPG Maker XP ^^


Now the problem I'm stuck with is that I need to create a random variable and soon after I need to specify the random variable..


For Example: 

Spoiler
I killed a goblin, the goblin dropped an item called Small Pouch.


When the players opens the pouch he gets an random amount of gold between 5 and 25.


Now after the players get his hard earned money I want to select a text that specifies how much gold has been gained.


example::


.>Change Gold: + Variable [0001:Goldsmall]


.>Control Variables: [0001:Goldsmall] += Random No. (5...25)


.>Text: System: You've found ["x" Gold] in the pouch!


Where x should be the exact amount of gold gained.

Anyone has an idea how to solve this problem? Would be very much appreciated 😀  


Ps: I'm new here, and I'm wondering if there's a way to preview a post.
I think you should be able to do that by using \V[n], so in your example it would be 


"You've found \V[1] gold in the pouch."


There's a few other errors with your example event setup, but I'm assuming you just put it up as a quick example?


If not, the change gold command should come after the control variable, or it won't add the gold at all. I also wouldn't use "add" for the variable, but "set". Otherwise, after the third or fourth pouch, you'll get messages that they've found 200+ gold in the pouch.


PS: There's no preview button.
I think you should be able to do that by using \V[n], so in your example it would be 


"You've found \V[1] gold in the pouch."


There's a few other errors with your example event setup, but I'm assuming you just put it up as a quick example?


If not, the change gold command should come after the control variable, or it won't add the gold at all. I also wouldn't use "add" for the variable, but "set". Otherwise, after the third or fourth pouch, you'll get messages that they've found 200+ gold in the pouch.


PS: There's no preview button.

Thank you very much for your quick reply 😀


Yeah I did flip those two by mistake but I appreciate the additional support <3
 


Didn't know the \v[] command existed, and after adding it to the text it started working flawlessly, thanks again!
Straight from the Help file on Events:


Showing Text



To display messages on the game screen, use the [Show Text] event command. This is usually the most frequently used of all event commands.


The following control characters are available for use in text mesages:


\V[n]


Will be replaced by the value in variable number n.


\N[n]


Will be replaced by the name of actor number n.


\C[n]


Displays the characters that follow in color number n.

0


1


2


3


4


5


6


7



\G


Opens the money reserves window.


\\


Will be replaced by the '\' character.


Press [F2] while entering text to preview how the message window will look in the actual game.


---


Additional scripts add additional options.  I worked on a message system that allows using Text Variables to display Variable Text by first setting $game_system.mmw_text[0] = "Hello World!", then display that Text (not just a number) with \v[Tn] or \v[T1] or \v[T33].  Once you have the hang of that, you can use a bunch of other features specific to that message system to display Item Icons, Item Name, etc.  Since it is a custom message system, a lot of things had been added.  The messages appear as white bubbles over characters heads and can be repositioned with \v \^ \< \>, show Gold Windows in specific positions with \g+ or \g-, and those message bubbles can even reposition themselves automagically with \$ and \%.


NOTE: Previewing doesnt work with Variable Texts as it shows the default message window.


Take a look-see here for a demo of everything added with scripts to the Message System (core by Wachunga)


http://forum.chaos-project.com/index.php/topic,13682.0.html


The above link will allow you to display Messages using these types of visuals:


MMW.jpg



MMW2.jpg



Every message system is different.  For the default message system, see the quote from the Help file at the top of the post.  Customized message systems will each have their own set of different options and commands, depending on how robust they are.

Original thread: https://forums.rpgmakerweb.com/threads/random-variable-to-text.60300/