Increase maximum number of variables in the database?

I tried searching through the forum before asking this, and there were a few cases where people asked something similar to this, but it seems like I'm the first one to actually just want that "Change Max" button to let me have more than 5000 variables in the database. I'm sure most people turn to scripting long before they ever get to this point, but I'm going out of my way to use RPGMaker's event commands as I just want to focus on the logic of a game as opposed to creating one in any given programming language. If I have nothing but "change variable" and "show picture" all over the place, it's a lot easier to turn that into whatever language I eventually end up learning. 😛

Other than the New Game/Continue screen when you start a game and the save system which I can't seem to change through event commands, I'm not using any other default RPGMaker systems. My database entries for items/enemies/etc. are completely empty as I deleted them myself. Everything exists solely as variables I've created that are read in systems that I'm creating. The "game" is nothing but numbers and pictures in (common) events.

For example, variables 2001-4000 are used for a 100 slot inventory where I've allocated 20 variables to define all kinds of information. As I have it now, the first of the 20 variables(2001,2021,2041...) is the item type. I determine which slot I'm on using a menu system I've created(common event), then I read that variable in my item type database(common event) which determines how I read and use the following 19 variables(2002-2020,2022-2040...). I'm really making everything from scratch here.

When I was still using the default systems I hated how TP was used, so I poked around in the script editor and managed to change how it worked. However, no matter what I search for, there doesn't seem to be a way to increase the number of variables(or switches) above 5000.

I never expected to be able to make a whole game like this so it's ok if there's no way to do what I want. I'm really just playing around with making a game from scratch using easy to read event commands. I'm still at the beginning of what I want to do, yet I'm already running out of variables so I figure I'm barking up the wrong tree here. But I thought I'd ask since no one else had, just in case I missed how to increase that number.
This is indeed doable and if no one has responded to this by the time I get home from work tonight, I'll post the script I use to do this.  You can also increase the number of switches, items, etc.  Basically anything that starts with $data_ (except system).

Or you could use the stuff in this link.  My stuff was basically just a recoding of the link below, so meh, either works.

http://forums.rpgmakerweb.com/index.php?/topic/1375-database-limit-breaker-11-event-port/
Look for something called Database Extender script... it allows you to increase the max in the database by running that script once... I'm not sure if that could apply to variables and switches too though...
Wouldn't you still be limited to the 5000 when you do a Control Variables/Switches or use them in conditions?
well, probably yes... assuming that is something hardcoded into the GUI of the editor...


but really, you should probably just use custom variables...


also, huge arrays tend to be slow especially when accessing higher indices...
I would be asking why you have such a large number of variables allocated to the one thing, and see if you can work a little scripting magic to do it without variables.
DarkwingGT, I downloaded the project that's mentioned in your link, and that was exactly what I was looking for. Thank you for mentioning that, as I can now continue making my game unhindered by that evil 5000 number. lol

But as for the method in that fourth common event, I didn't actually use it. Maybe if I was using the default RPGMaker systems, I would be tempted to increase everything at once. I don't know anything about scripting, but it seemed like it was doing a whole lot of unnecessary stuff, and I definitely didn't want to touch anything but variables. If I was reading that code right, I think I could have changed those settings to 0 and it would have skipped the other items, but just to be safe, I also decided to make my own solution.

In the past, I've looked around the scripting pages in the built in help document, but that stuff really was not for me so I didn't even bother trying to make anything. However, I did remember seeing pages that mentioned what seemed like the important parts of that script, so after a few hours of reading the help document, searching the forums, and irreversibly breaking a few projects(freshly created), I came up with the following:

AddVar = load_data("Data/System.rvdata2")
AddVar.variables.push(Array.new(5000))
AddVar.variables.flatten!
save_data(AddVar, "Data/System.rvdata2")

For some reason it didn't like when I tried to add ".variables" at the end of the first line and skipping it in the second and third lines, nor did it work without the "flatten!" line, but that's probably because I know nothing about scripting. 😛 I'm sure it also looks ugly, but it does work, you just need to reopen the project file to see the new variables.

I put that in a map event in that "script" event command all the way at the end of the third page. Now I can just press it to get another 5000 variables added to the database over whatever number I already had it as. For example, on a new project, there will be 100 variables already in the database, so if I press that without touching the "change max" button then I will end up with 5100 variables. But in the project I was working on I already had it at the 5000 maximum, so it gave me 10000 variables. I think I saw something that would let me just "set" variables to a fixed number, but I didn't know if it would first erase the ones I already had, so I didn't try it.

I tested it several times, both just pressing it once per multiple playtests and actually pressing it a few times in just one playtest, and the numbers added up correctly. I can see the new variables in the database as if I had pressed the change max button and set it to the appropriate number. I also did a few tests to make sure it really works. I set one of the >5000 variables manually in a map event, then I put a conditional branch to see if that variable is equal to the value I set before with a text message with the variable in the text(\V[x]) and everything worked as it should have so the engine can apparently read the number.

Obviously not taking credit for this method, let alone the idea, but given how simple of a change this is to that file, I have no idea why the "change max" button has an arbitrary limitation in the first place. A warning that high numbers might slow down a project when you enter a number over xxxx would have been a much better idea than taking away the option. Not that I saw any slowdowns, but I have to assume that eventually I could reach a point where there are simply too many variables for the engine to handle. I probably won't need anymore than 15000-20000 to make an entire game unless I want a really big inventory with multiple external storage places. Think something like how you can store items in random containers in the Elder Scrolls games, except my game won't randomly delete all your stuff. 😛

As for reducing what I have, I actually could, but it would break the kind of systems that I want to make. Like I said before I'm using 2000 variables for an inventory system I created. Let's assume for a second that I'm making a game like a PS2 Gust RPG. For those that haven't played one, they have fixed inventories, meaning that there is one and only one slot for any "type" of item. Imagine not "a health potion" sitting in an inventory slot but "the health potion slot." Sure you can have 99 of them, but they will always and forever have the same stats and be located in the same exact spot in the inventory. In this kind of system, once you create a menu, you can just select that specific slot and then add a fixed value to the player's HP. There really doesn't need to be any other variables associated with the health potion, either there is one and it does something, or there isn't and it doesn't.

Now let's assume that I'm making a game like Diablo. You not only have a sortable inventory, meaning you can't cheat with something like "if menu cursor y position = 5, add 50 HP," but you also have items with randomly generated stats. An item could have +1 to any stat or it could have +5 to ten different stats. In this situation, you need to store those values when the item is created. These stats were calculated, not pulled from somewhere that I can reread as many times as I need.

I'm not actually trying to make my inventory system for either type of game that I just mentioned, or for any other type of game in particular, so that's why I'm leaving 20 variables per item for anything that might arise. Even though I'm just getting started, I have the first variable as item type, which I use solely to call my "item database" to process the remaining 19 variables. I also have quantity, max quantity(for the stack), remaining capacity(calculated from the previous 2 for inventory manipulation), and then I have 10 variables dedicated to traditional stats. Five of those are "stat types" and the other 5 are the stat values. I read the stat types in a "stat database" so I can use 10 variables to affect any 5 stats I want, whereas if I wanted a fixed location for each and every one in the game, depending on how complex the game is, I might need 100 variables per item. But as long as I have my stat type variables, I could even make one of the types represent "all stats," and then with just 2 variables I could control 100 stats, say Stat1Type=999 and Stat1Value=5. Sorry for writing the word stat so many times. 😛

Again, I'm sure that all of this would be a lot cleaner with scripts but it certainly wouldn't be easier for me to read what I made and that's bad news if I decide to write my game in another language. I haven't found anything that I haven't been able to create just using the event commands so I'm perfectly content with using them, I just needed a way to work around the database limitations. Which I now have, so thank you again for mentioning it DarkwingGT.
Is this all resolved, then?
It's clear for lockage. 😛
One additional script that might be helpfull:


http://forums.rpgmakerweb.com/index.php?/topic/1567-the-self-data-suite-self-switches-variables-and-metadata-for-everything/


This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/increase-maximum-number-of-variables-in-the-database.23009/