As a basic question, I'm asking how to add data to text, like
$game_variables[3] = 5$game_variables[1] = ""$game_variables[1] += "Eagle number \$game_variables[3]"in hopes of having the variable equal
"Eagle number 5"
instead of "Eagle number $game_variables[3]".
For a longer explanation, I'm using a variable HUD script http://www.rpgmakervxace.net/topic/2302-xs-variable-hud/
(script not relevant), and say that I have a system for different things like time of day, month, day of week, or any other use I'd have for this function.
Let's say I have variable 35 "Day of Week Name", variable 36 "Month Name" variable 37 "Day", and variable 38 "Days in the Story",
which variable 35 = "Monday", variable 36 = "March", variable 37 = 8, and variable 38 = 36
Now let's do the process for variable 1 "Display #1" --
$game_variables[1] = ""$game_variables[1] += "\$game_variables[35], "$game_variables[1] += "\$game_variables[36] "if $game_variables[37] == 1 then $game_variables[1] += "\$game_variables[37]st" elsif $game_variables[37] == 2 then $game_variables[1] += "\$game_variables[37]nd"elsif $game_variables[37] == 3 then $game_variables[1] += "\$game_variables[37]rd"else $game_variables[1] += "\$game_variables[37]th" end$game_variables[1] += " (Day \$game_variables[38])" I'm wanting it to look like
Monday, March 8th (Day 36)
but instead it looks like
$game_variables[35], $game_variables[36] $game_variables[37]th (Day $game_variables[38])
(The same result also occurs if you do a test message: )
\V[1] Now, mind you, I know how to do this for final messages. I'm not asking about that.
If I wanted to do a finalized message, I could do
$game_message.add("Eagle number \\V[3]")and that would work, but I'm talking about editing a variable as a whole.
Edit-- Solved:
From reading http://learnrubythehardway.org/book/ex6.html
I have learned that in order to add data bits you do #{data}
So the solution would be
$game_variables[3] = 5$game_variables[1] = ""$game_variables[1] += "Eagle number #{$game_variables[3]}"
Which would translate to Eagle number 5.
Or if you did
$game_variables[3] = "Monday, the 3rd"$game_variables[1] = ""$game_variables[1] += "The final exam will be on #{$game_variables[3]}, at 2pm."That would translate to The final exam will be on Monday, the 3rd, at 2pm.
[ACE] Adding variable numbers to text variables? ($game_variables[1] = "Current time: \$game_variabl
● ARCHIVED · READ-ONLY
-
-
$game_variables[1].to_s += "It is #{$game_variables[35]} 3rd."This will probably end up being "0It is March 3rd.", so consider turning $game_variables[1] into a string first by using $game_variables[1] = ""
-
Well this has worked for me
$game_variables[35] = "Monday"$game_variables[36] = "March"$game_variables[37] = "8"$game_variables[38] = "36"$game_variables[1] = ""$game_variables[1] += "#{$game_variables[35]},"$game_variables[1] += " #{$game_variables[36]} "if $game_variables[37] == 1 then $game_variables[1] += "#{$game_variables[37]}st" elsif $game_variables[37] == 2 then $game_variables[1] += "#{$game_variables[37]}nd"elsif $game_variables[37] == 3 then $game_variables[1] += "#{$game_variables[37]}rd"else $game_variables[1] += "#{$game_variables[37]}th" end$game_variables[1] += " (Day #{$game_variables[38]})"When I put quotes, it already becomes a string, so I wouldn't know what would be the use of .to_s -
I don't have time to check, but I think this
$game_variables[1].to_sRETURNS a string that is NOT the same object as $game_variables[1] - so now you have two objects - $game_variables[1] and a string form of $game_variables[1], which is lost, because you're not allocating anything to it.
So the new string variable is getting changed, but then lost, and $game_variables[1] is not being changed at all.