How many variables is too much?

Discussion in 'RPG Maker MV' started by Rink27, Sep 6, 2016.

  1. Rink27

    Rink27 Veteran Veteran

    Messages:
    222
    Likes Received:
    12
    Location:
    Caribbean
    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: Sep 6, 2016
    #1
    consolcwby likes this.
  2. Allinardo

    Allinardo Dungeon Crawler Veteran

    Messages:
    60
    Likes Received:
    23
    Location:
    Los Angeles, California
    First Language:
    English
    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.
     
    #2
    Rink27 likes this.
  3. Wavelength

    Wavelength Pre-Merge Boot Veteran

    Messages:
    3,687
    Likes Received:
    2,968
    Location:
    Florida, USA
    First Language:
    English
    Primarily Uses:
    RMVXA
    No.

    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.

    No difference in performance whatsoever.

    No difference in performance whatsoever.
     
    #3
    Rink27 likes this.
  4. Alexander Amnell

    Alexander Amnell Jaded Optimist Veteran

    Messages:
    3,405
    Likes Received:
    1,728
    Location:
    Zaječí
    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: Sep 6, 2016
    #4
    Rink27 likes this.
  5. Rink27

    Rink27 Veteran Veteran

    Messages:
    222
    Likes Received:
    12
    Location:
    Caribbean
    First Language:
    English
    Primarily Uses:
    RMMV
    Thank you everyone for the answers <3
     
    #5
  6. mrcopra

    mrcopra Veteran Veteran

    Messages:
    447
    Likes Received:
    140
    Location:
    Your Heart
    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: Sep 6, 2016
    #6
  7. Squirrelzone

    Squirrelzone Expert at being lazy Veteran

    Messages:
    51
    Likes Received:
    2
    First Language:
    English
    IT DOESNT MATTER GUYS WHO CARES ABOUT SAVE TIME USE AS MANY VARIABLES AS NEEDED
     
    #7

Share This Page