Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

String problem: how to make a number into a number between quotes?

Status
Not open for further replies.
String problem: how to make a number into a number between quotes?

The thing is a want to convert the value of a variable (a number), into that same value but within quotes...
 
what i want is something like this:

(1)i have a variable: @a = 5

(2)i have a character named: "5_stars"

(3)then: i want to use that @a variable in a string. Like this:

$game_player.character_name = @a + "_star"

#-------------------------------------------------------------------#
But the five(5) in the variable(@a) is without the quotes, so the string doesnt follow.

So how do I make the value of a variable(like the @a example) into quotes?

THANKS A LOT.

Specially you Seph, who are always willing to give a hand.
 
Yep. You can do it tons of different ways. But the most simple is

Code:
$game_player.character_name = "#{@a}_star"

And some side advice, when you are just creating a simple string (no special characters or anything), use single quote marks instead of double quotes. From what I have been told (and it makes sense), single quotes are easier on the interpreter than double quotes. So instead of "_star", '_star' That is just a bit picky, but its a good habbit to form.

So you got everything figured out?
 
Status
Not open for further replies.

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top