How many variables is too much?

Rink27

Veteran
Veteran
Joined
Jul 18, 2014
Messages
222
Reaction score
13
First Language
English
Primarily Uses
RMMV
Is there a recommended limit to not exceed with the number of variables (and let's include switches as well) in your game? I've once read a user comment on someone else's game having 100+ variables as inefficient. I've been trying to be efficient with the number I use, but should I really try?

30 variables vs 300 variables for example. Would there be any difference in performance?

EDIT: Bonus question. Say I create 200 variables, but variables 100-130 are unused... can there be any impact on performance? Are those empty slots taking up any memory?
 
Last edited by a moderator:

Allinardo

Dungeon Crawler
Veteran
Joined
Jan 2, 2013
Messages
60
Reaction score
23
First Language
English
Primarily Uses
In my current project there are 500 variables. There really shouldn't be limits to these sorts of things. Having a lot of variables won't harm anything, and if there's any impact on performance...well, there just won't be really.

It all has to do with what you want to do with your game. Use as many as you see fit.
 

Wavelength

Edge of Eternity
Global Mod
Joined
Jul 22, 2014
Messages
4,983
Reaction score
4,168
First Language
English
Primarily Uses
RMVXA
Is there a recommended limit to not exceed with the number of variables (and let's include switches as well) in your game?
No.

I've once read a user comment on someone else's game having 100+ variables as inefficient. I've been trying to be efficient with the number I use, but should I really try?
No.  In fact, trying to re-use variables in order to "conserve" them is really risky, because you might have two different events trying to work with them at the same time, or you may fail to reset them properly.

30 variables vs 300 variables for example. Would there be any difference in performance?
No difference in performance whatsoever.

EDIT: Bonus question. Say I create 200 variables, but variables 100-130 are unused... can there be any impact on performance? Are those empty slots taking up any memory?
No difference in performance whatsoever.
 

Alexander Amnell

Jaded Optimist
Veteran
Joined
Mar 17, 2012
Messages
3,405
Reaction score
1,732
First Language
English
Primarily Uses
N/A
   I mean, obviously you want to do things as efficiently as you can, but in this case efficiency is fairly subjective. For instance, say you use variables to create a custom encounter system or some such, where different events draw a random number as a variable and match it with a troop found on that map. Since only one of these instances will ever play out at once it would be silly to add a new variable to every new area/troops pool when you could just start each event by disposing of any previous data and continue to use a single variable for that function. On the other hand, say you have a camp/home base/fortress system in play and you want your party members to chat with you at said base and you use variables to progress those conversations, obviously each party member needs to have their own variable only controlled while advancing that characters conversations, far to easy to make mistakes and break things otherwise.


   Short answer- The question is too subjective to answer as is, and depends on what you are using said variables for. You can use 500 variables efficiently to the point you need every single one, but you could also use 5 variables very inefficiently and run into problems because of it, it's impossible to tell you which without knowing exactly what you are using them for and how you are using them.


   Generally speaking though you aren't going to lose performance by just declaring extra variables, so having a few redundant variables is probably a better alternative to accidentally using the same variable in two events that could be triggered at the same time as that's more where you're likely to run into problems.
 
Last edited by a moderator:

Rink27

Veteran
Veteran
Joined
Jul 18, 2014
Messages
222
Reaction score
13
First Language
English
Primarily Uses
RMMV
Thank you everyone for the answers <3
 

mrcopra

Veteran
Veteran
Joined
Jul 21, 2015
Messages
449
Reaction score
150
First Language
Not English
Primarily Uses
N/A
The problem i faced when i make a lot of variables is when you want save it will take longer time, more variables you have longer time to save 
 
Last edited by a moderator:

Squirrelzone

Expert at being lazy
Veteran
Joined
Aug 13, 2016
Messages
51
Reaction score
2
First Language
English
Primarily Uses
IT DOESNT MATTER GUYS WHO CARES ABOUT SAVE TIME USE AS MANY VARIABLES AS NEEDED
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Here it is in all its leggy glory! I apologize in advance.
Suggestion for the name for the new RM, RPG Maker Re-MV (Re-Mastered Version)
A guide on Furry Potatoes.

I apparently need to send photo ID to Blizzard to change my phone number. I don't even need to do this to change my number with my bank or PayPal

Forum statistics

Threads
98,175
Messages
950,072
Members
129,472
Latest member
Strigoi
Top