• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

[solved]Carry a number between rooms

N

Noobc0re

Guest
I have a number that happens in one room, then in the next room I need to show it.

How do I bring it over?
 
M

MishMash

Guest
Global variables are the easiest way to do this. If you are using gml, you can simply put

global.

infront of your variable name. For example:

Code:
global.value = 10;
This will maintain its value throughout the life of your game.
 
Last edited by a moderator:
N

Noobc0re

Guest
Global variables are the easiest way to do this. If you are using gml, you can simply put

global.

infront of your variable name. For example:

[ROOM]global.value = 10; [/ROOM]

This will maintain its value throughout the life of your game.
That doesn't work though.
 
M

Mishtiff

Guest
It is also possible to create an object that is persistant, and store all of your variables that you need throughout your game in this object.

ex name
obj_gameVars
 
M

Mholmes3038

Guest
My recomendation would be create a properties class to store all your global variables. I'm a c# dev so I'm not sure if GML supports it but I think it does support properties. Anyway, a global variable is a variable you can access anywhere in game. Common global would be a player lives count or player score. Any value that you need to access through out your entire game. If you need a better explanation of global variables, I recomend researching how properties work in the .Net framework on the MSDN forums. I hope that helps.
 
S

Super_Alchemist1

Guest
I have a number that happens in one room, then in the next room I need to show it.

How do I bring it over?
I am having the same issue. However despite following the information on this page, I can't use gml tips as this is a DnD game. I have tried using global variables and whenever i need to use them it comes up with, ERROR, global. has not been set before reading it, despite me setting and checking the global variable.
 
Top