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.

Setting Game Variables

How would you script a variable, lets say

$game_variable[1] = 15

so that it works. I know it has something to do with using
$game_variable[1] == 15

just unsure of how.


This thread rules.
 
I'm not sure what you want. $game_variables[1] = 15 (with an extra s) does in fact set the first game variable to 15, so if you just want to set a game variable with a script, it's all you need to use. $game_variables[1] == 15 on the other hand is used to test if that variable is equal to 15, which is like using a conditional branch where a variable is tested to be 'Equal to' some constant number.

If that doesn't answer your question, please elaborate on what you're trying to do.
 
To set a variable:

Code:
$game_variables[x] = y

To test a conditional branch with a variable:

Code:
if $game_variables[x] == y

That's where you need two = signs.

You can do things such as addition:

Code:
$game_variables[x] += y

Or subtraction:

Code:
$game_variables[x] -= y
 

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