How Many is Too Many?

So over the course of my time dabbling in RPG Maker engines, I've gained a lot of knowledge on how things work, as well as even been brave enough to delve into coding itself (it did not last long lol). I won't deny that I've never really pushed past ideas and gotten into an actual project, but I love games so much and enjoy the feeling of making something. While designing and trying things, I eventually learned how to use variables to a small degree.

However, one thing constantly plagued me while trying things out. I'd sit there and plan things out like "I could do this, but it might require its own variable" or "how can I utilize multiple things under the same variable condition?" It got me concerned if I was using too many variables, or trying to do too much. Eventually I struggled to understand if it was good to have tons of variables for random things.

The question I want to discuss is how many is too many? Is it reasonable, if not expected, to use literally hundreds of different variables? Is it possible to slim down a lot of things in game designing to not use so many variables? These are the questions I'd like to get more input and thoughts on from others.
there are really only two objective points when it is "too many"

  1. It affects the performance of the game. This will only happen if everything is loaded on one map, generally speaking
  2. You want to use more than the engine will allow you to add. I think in the case of MV specifically, that number is 2000?
It's important to remember that players generally won't see how "inefficiently" you built the game, and won't care so long as every part of it works. Use what you need to do what you want. I know my first big project used, like, 7 variables, but somewhere around 100 switches.

My general advice would be that the more things reference and/or change the same variable, the more likely you are to create a bug where variables are at unexpected values, so using a new variable for a new thing is unlikely to be a bad idea, in most cases.
there are really only two objective points when it is "too many"

  1. It affects the performance of the game. This will only happen if everything is loaded on one map, generally speaking
  2. You want to use more than the engine will allow you to add. I think in the case of MV specifically, that number is 2000?
It's important to remember that players generally won't see how "inefficiently" you built the game, and won't care so long as every part of it works. Use what you need to do what you want. I know my first big project used, like, 7 variables, but somewhere around 100 switches.
Yeah that makes sense. I guess I tend to think big and want to add loads of things to make the game feel fun and interactive, but not necessarily know how to do so. For example using a system to upgrade a weapon, but you need a specific amount of materials. The way I'd think to do that is using a variable to check if the right amount is there, but then I go into "I need a variable for EACH item that can be used to upgrade weapons", and then that leads into armor, and other accessories and the like. In my mind, if I were to try and do a variable for all that, it could become catastrophic, and overbearing.
My general advice would be that the more things reference and/or change the same variable, the more likely you are to create a bug where variables are at unexpected values, so using a new variable for a new thing is unlikely to be a bad idea, in most cases.
Oh yeah, this makes the most sense to me. I never doubted that relying on the same thing for too many tasks could result in bugs (potentially game breaking ones too). It seems like a fine balance between using multiples and using an instance of it. A concern I'd have with using the same variable for multiple things would be in a teleporting ability, with multiple locations.
Why would you need a separate variable for each amount of required material? I don’t know what crafting system your doing but if it’s just a checklist one..

You could just have a variable for the “craft item ID” of what your making and like 8 temp variables for the materials (4 for their “IDs” and 4 for the quantities of each) and a common event call with a list of conditional branches that would, based on what “Craft Item ID” set the other 8 variables to the item your choosing to make. You’d be using “set variable” because those requirements are constant and don’t need to be a dynamic variable.

But idk if that’s what kind of sys you meant.
I'm at 1500 variables in my project right now, but that has basically no significance in quality or scale of the game.

I always prefer clearly named variables with clear purposes, so I'd never recommend, to use "temp" or "trash" variables used for different occasions. You never know how your game will turn out, and your features might be available when you didn't expect it in the first place, so these "temp" things might be active at the same time. There's no benefit to it.

But, if you plan features that need a lot of values, you should consider to use variables for more than a single value.
For example, if you have 100 characters with 10 stats each, that would occupy 1000 variables. Instead, you can save these stats as arrays, so you need only one variable per character. This will need some scripting.

Also, you could save stats like these directly into the save file. This will require a plugin or scripting aswell. For example, in my game every character can be friends with everyone. That will make up to 20000+ combinations. I don't use variables for that.
Why would you need a separate variable for each amount of required material? I don’t know what crafting system your doing but if it’s just a checklist one..

You could just have a variable for the “craft item ID” of what your making and like 8 temp variables for the materials (4 for their “IDs” and 4 for the quantities of each) and a common event call with a list of conditional branches that would, based on what “Craft Item ID” set the other 8 variables to the item your choosing to make. You’d be using “set variable” because those requirements are constant and don’t need to be a dynamic variable.

But idk if that’s what kind of sys you meant.
Well this is just a bit of theory talk I wanted to go with. I honestly have no idea how to do a crafting system, as much as I'd like to learn. There's a lot I don't know, and a lot I need to learn if I wanna add features to a game. Hell, I tend to struggle with basic stuff from time to time, and it becomes offputting for me to wanna make something. It's also why I wanted to have a nice discussion with the forum people on this, cause sometimes I just get intimidated and afraid that I'm doing things wrong or improperly.
An example of the kind of system I'd like to learn to make is the one Epic Battle Fantasy 3-5 do, where there are specific items you need, and a specific quantity to upgrade them (for example, 3 Dragon Fangs, 10 Wood, 50 Ash Piles to upgrade a Flame Sword from rank 1 to rank 2).

I'm at 1500 variables in my project right now, but that has basically no significance in quality or scale of the game.
That's a lot of variables, but I guess in the grand scheme of things not really a lot if it doesn't hinder the game.
I always prefer clearly named variables with clear purposes, so I'd never recommend, to use "temp" or "trash" variables used for different occasions. You never know how your game will turn out, and your features might be available when you didn't expect it in the first place, so these "temp" things might be active at the same time. There's no benefit to it.
I like to do the same. I tend to be very specific with variables and switches so I know what they are used for. Naming them things like "Chest 1" or "Key 5" would be horrible for me to keep track of x.x But going "Forest Chest 1/5" and "Desert Dungeon Key" is much better for me.
But, if you plan features that need a lot of values, you should consider to use variables for more than a single value.
For example, if you have 100 characters with 10 stats each, that would occupy 1000 variables. Instead, you can save these stats as arrays, so you need only one variable per character. This will need some scripting.
This is where my very limited knowledge hinders me. I don't know how to use arrays, or even what they are. I try to research things before asking anything as I don't like to waste time posting the same question that's been asked a thousand times lol I also don't want to look really incompetent that I couldn't figure out or understand basic things
I always prefer clearly named variables with clear purposes, so I'd never recommend, to use "temp" or "trash" variables used for different occasions. You never know how your game will turn out, and your features might be available when you didn't expect it in the first place, so these "temp" things might be active at the same time. There's no benefit to it.
Ah sorry I see I didn’t write it well (which happens when I write on my phone 😛), I write them like:

(Material Item IDs)
CraftMatID:01.TEMP
CraftMatID:02.TEMP
and so on…

(Material item amounts)
CraftMat#:01.TEMP
CraftMat#:02.TEMP
And so on…

It’s like a “questionnaire sheet” type setup, I tend to put .TEMP on the end of any variable name that I should reset the values to 0 before I use it again, and I always put comments on the events to say what’s for what to keep track too cause I forget sometimes.

Well this is just a bit of theory talk I wanted to go with. I honestly have no idea how to do a crafting system, as much as I'd like to learn. There's a lot I don't know, and a lot I need to learn if I wanna add features to a game. Hell, I tend to struggle with basic stuff from time to time, and it becomes offputting for me to wanna make something. It's also why I wanted to have a nice discussion with the forum people on this, cause sometimes I just get intimidated and afraid that I'm doing things wrong or improperly.
An example of the kind of system I'd like to learn to make is the one Epic Battle Fantasy 3-5 do, where there are specific items you need, and a specific quantity to upgrade them (for example, 3 Dragon Fangs, 10 Wood, 50 Ash Piles to upgrade a Flame Sword from rank 1 to rank 2).


That's a lot of variables, but I guess in the grand scheme of things not really a lot if it doesn't hinder the game.

I get ya, I still struggle with tilesets a lot 🙂
I wouldn’t worry about messing it up though, the best thing to do is try to make just a starting mock up with what you know, and then set it aside and make it again. It gets clearer. There’s no game over when using RPG maker.

There’s different ways you could do that example, Its basically a checklist asking if you have 3 Dragon Fangs, 10 Wood, 50 Ash Piles and a Flame Sword rank 1 in your inventory, if you do you remove all those items/weapon and add a Flame Sword rank 2. (I would in weapons make individually each Flame sword rank 1, flame sword rank 2, flame sword rank 3, and so on)

(I’m on my phone so I can’t send a screenshot, sorry if this is confusing to read)

This just a basic way that uses conditional branches to ask each “have item/have amount” question one step at a time, with the next conditional branch question in the “if yes” section. This way only uses 1 variable.

•make a conditional branch that checks if you have the “dragon fangs” item in inventory
•if yes, then set a variable (name it “MatAmount” or something) to the amount of “dragon fangs” (in game data operand in variable operations)
•put another conditional branch under that which asks if variable “MatAmount” is equal to or greater than 3
•copy this whole thing and paste it inside that “yes if variable “MatAmount” is 3 or more section, and in this copied one edit it to check for wood item, wood item amount, and if variable “MatAmount” is 10 or more
•repeat this for 50 ash piles and 1 Flame Sword rank 1
•in the last conditional branch “if yes” part, use the “change items/change weapons” to remove the amounts of each item and weapon
•add Flame Sword rank 2 with “change weapons”

hope this kinda helps…?
That's a lot of variables, but I guess in the grand scheme of things not really a lot if it doesn't hinder the game.
There's not much of a hinderance to worry about. Variables store values for you, so don't hesitate to store what you need. Having 5 or 5000 variables in use* isn't much of a difference.

*while "in use" is also relative. Variables won't do anything if you don't interact with them codewise. Most of the time, they are just sitting in their shelf, holding their number and doing nothing but waiting for a call to add +1 or display the value in a textmessage.

What you might be concerned about are parallel process events. Too many of those, and if performed poorly, can affect the performance of the game by a lot.
And in many cases, parallel events can be avoided, if you have a good concept of what they are doing.
For example: You have a time feature in your game and display some kind of clock in your HUD. You could set up a parallel process, that always checks the current time and shows the correct information. But you could also call this check when your ingame time actually changes. There has to be some event that adds +1 to the ingame timer. That would be the right spot to check necessary HUD updates aswell.

Ah sorry I see I didn’t write it well (which happens when I write on my phone 😛), I write them like:

(Material Item IDs)
CraftMatID:01.TEMP
CraftMatID:02.TEMP
and so on…

(Material item amounts)
CraftMat#:01.TEMP
CraftMat#:02.TEMP
And so on…

All good, I didn't refer to you post in particular!

Your given example is a good usecase of variables, and not what I meant with "bad reusage of variables". Yours seem to be focussing on occasional Crafting purposes and loading the needed resources dynamically. So they are used for crafting and nothing else.

What I meant was something like counting wood for a fetch quest in them and later use them to count fish or killed goblins. I wouldn't recommend that just for the sake of reducing variables in use.

This is where my very limited knowledge hinders me. I don't know how to use arrays, or even what they are. I try to research things before asking anything as I don't like to waste time posting the same question that's been asked a thousand times lol I also don't want to look really incompetent that I couldn't figure out or understand basic things
No worries. It's actually nothing the RPG Maker would teach us on it's own. Not sure if there's a clean Tutorial about it. I learned about arrays in variables in this forum between the lines, and it was eye opening. I think @AquaEcho was talking about it somewhere.

I can give you a few examples how I use arrays in my game. But I'm not the best to explain the scripting, as I just figured out the situations I needed in particular. But others with more coding experience will help with specific questions, I'm sure.

Basically, an Array is a set of information, like:
[1, 5, 14, 17]
or
["Apple", "Herbs", "Potion"]
or
["Apple",2,"Herbs",10] ...

I have an array in a variable that holds all ActorIDs of actors, you have unlocked so far. So I can always use this to check, whichs actors are available for cutscenes, events or other stuff.
I can pick random numbers from the Array for randomized events.

A different array holds stat resistances and weaknesses like:
[1,0,-1,0,0,0,-1,1]
for every character. By script I can tell the game, which position belongs to which element, so it knows "resistant to fire, but weak to ice".

And you can also put text in it to be displayed in textmessages etc. E.g., you have something like:
["Chapter 1", "Chapter 2", "Chapter 3"]
And display these in a menu to click through the given options you want to read about.
You can tell the game by script "if you click right, take the next entry in the array. If you click left, take the previous. If you reach the end of array, go to the start/end and continue."

I could go on, but I hope, this gives a basic impression.
I get ya, I still struggle with tilesets a lot 🙂
I wouldn’t worry about messing it up though, the best thing to do is try to make just a starting mock up with what you know, and then set it aside and make it again. It gets clearer. There’s no game over when using RPG maker.
That's pretty much the current state of RPG Maker with me. I'm just messing around with things, trying to test things out. Things I want to learn or need assistance with I ask for a bit of help, but I also don't wanna spam the forums with help all the time. Might get old seeing me post a new thread for help so often XD
There’s different ways you could do that example, Its basically a checklist asking if you have 3 Dragon Fangs, 10 Wood, 50 Ash Piles and a Flame Sword rank 1 in your inventory, if you do you remove all those items/weapon and add a Flame Sword rank 2. (I would in weapons make individually each Flame sword rank 1, flame sword rank 2, flame sword rank 3, and so on)

(I’m on my phone so I can’t send a screenshot, sorry if this is confusing to read)

This just a basic way that uses conditional branches to ask each “have item/have amount” question one step at a time, with the next conditional branch question in the “if yes” section. This way only uses 1 variable.

•make a conditional branch that checks if you have the “dragon fangs” item in inventory
•if yes, then set a variable (name it “MatAmount” or something) to the amount of “dragon fangs” (in game data operand in variable operations)
•put another conditional branch under that which asks if variable “MatAmount” is equal to or greater than 3
•copy this whole thing and paste it inside that “yes if variable “MatAmount” is 3 or more section, and in this copied one edit it to check for wood item, wood item amount, and if variable “MatAmount” is 10 or more
•repeat this for 50 ash piles and 1 Flame Sword rank 1
•in the last conditional branch “if yes” part, use the “change items/change weapons” to remove the amounts of each item and weapon
•add Flame Sword rank 2 with “change weapons”

hope this kinda helps…?
Yeah I actually discovered something similar to this through RPG Maker 2003. I tested the idea of using items as currency (so having an item be money for a certain NPC). I had a variable set to the amount of an item in the player's inventory (ItemSell), then have them input a number. That number was tied to a variable labeled "ItemBuy". If the chosen number equaled or was less than what the player owned, it would remove that much of the item, and you'd buy that much of the item the NPC sold you. That's actually how the original question of this post came about. I came to realize if I did this for EVERY item in the game, that might become too much.
What you might be concerned about are parallel process events. Too many of those, and if performed poorly, can affect the performance of the game by a lot.
And in many cases, parallel events can be avoided, if you have a good concept of what they are doing.
For example: You have a time feature in your game and display some kind of clock in your HUD. You could set up a parallel process, that always checks the current time and shows the correct information. But you could also call this check when your ingame time actually changes. There has to be some event that adds +1 to the ingame timer. That would be the right spot to check necessary HUD updates aswell.
For some reason I don't worry too much with parallel processes, though that does make sense. Too many things running at the same time causes lag, and can crash games.
No worries. It's actually nothing the RPG Maker would teach us on it's own. Not sure if there's a clean Tutorial about it. I learned about arrays in variables in this forum between the lines, and it was eye opening. I think @AquaEcho was talking about it somewhere.

I can give you a few examples how I use arrays in my game. But I'm not the best to explain the scripting, as I just figured out the situations I needed in particular. But others with more coding experience will help with specific questions, I'm sure.

Basically, an Array is a set of information, like:
[1, 5, 14, 17]
or
["Apple", "Herbs", "Potion"]
or
["Apple",2,"Herbs",10] ...

I have an array in a variable that holds all ActorIDs of actors, you have unlocked so far. So I can always use this to check, whichs actors are available for cutscenes, events or other stuff.
I can pick random numbers from the Array for randomized events.

A different array holds stat resistances and weaknesses like:
[1,0,-1,0,0,0,-1,1]
for every character. By script I can tell the game, which position belongs to which element, so it knows "resistant to fire, but weak to ice".

And you can also put text in it to be displayed in textmessages etc. E.g., you have something like:
["Chapter 1", "Chapter 2", "Chapter 3"]
And display these in a menu to click through the given options you want to read about.
You can tell the game by script "if you click right, take the next entry in the array. If you click left, take the previous. If you reach the end of array, go to the start/end and continue."

I could go on, but I hope, this gives a basic impression.
So if I wanted to set up a list of locations to teleport to, an Array set up would be very helpful in that. I could do something like this?
[Forest, Desert, Aquarium, Ruins]
And then the player pressing right or left could cycle through these choices, and whatever option is selected when the player confirms would teleport to that place.
So if I wanted to set up a list of locations to teleport to, an Array set up would be very helpful in that. I could do something like this?
[Forest, Desert, Aquarium, Ruins]
And then the player pressing right or left could cycle through these choices, and whatever option is selected when the player confirms would teleport to that place.
Yes, that would be possible. It depends on your specific event, if an Array is even necessary in this case, but it would work. You can also let the script check the amount of unlocked areas, so it will only use the first 2 entries of your array, if the rest of the places isn't available yet.
So if I wanted to set up a list of locations to teleport to, an Array set up would be very helpful in that. I could do something like this?
[Forest, Desert, Aquarium, Ruins]
And then the player pressing right or left could cycle through these choices, and whatever option is selected when the player confirms would teleport to that place.

I would just use switches for that, one switch for each place you had unlocked. I wanna make an example for the left/right select controls part, But I’m stuck on my phone till the end of the week 🙁 sorry!
Yes, that would be possible. It depends on your specific event, if an Array is even necessary in this case, but it would work. You can also let the script check the amount of unlocked areas, so it will only use the first 2 entries of your array, if the rest of the places isn't available yet.
Currently I have nothing really set up to use an array, as I don't have much to it. This project I have is just to toy with ideas and test stuff, so I don't have a lot of "solid" design done.
Scripts are very scary to me. Coding is a beast of a monster, and extremely intimidating. While I do wanna learn, and understand how it works, it'd be way too much work and effort to request help from the forums. I did try looking into it, and there is something I want to try, but without knowing much I don't think I can just make it work. It also doesn't help that if I can't understand how something works, I just kinda give up on it. I don't wanna use this thread as a learning post, as it was originally just created to discuss how people decide the amount of appropriate variables for a game, so if I decide to delve more into this, I might make another post asking for help.
I would just use switches for that, one switch for each place you had unlocked. I wanna make an example for the left/right select controls part, But I’m stuck on my phone till the end of the week 🙁 sorry!
That's something I was looking into. How to have the options available, but selecting a place that wasn't unlocked would be greyed out and just make an "unavailable" sound until unlocked. No need to apologize, as this thread was originally made for discussion vs gaming assistance haha. There's so much to learn and do and understand, it's sometimes very mind warping x.x
Just gonna pop in real quick and say you could also just try one of the plenty crafting plugins instead of worrying about a billion zillion variables.

Of course you can event the whole thing and have fun doing so. You could also just code your own plugin to do just that, if that's what you want to accomplish.
omg are you me? I was in the same situation before I started writing my own plugin.

My out from that situation is to not think too much and just do an attempt, no matter how spaghetti the result may be. Because from there, you can do testruns (and I mean, A LOT OF) while also optimizing your code little by little until you satisfied with the result, just like drawing.

Original thread: https://forums.rpgmakerweb.com/threads/how-many-is-too-many.175717/