Hey everyone! I have a simple question, I've been working on a game for a while now and as expected, I have been using variables and switches.
When I had started the project I had pre-sorted them so that for example, 1-100 would be plot related, 150-200 would be for a certain mini game, 200-220 was for player inventory stats and such.
The planning ahead has worked pretty well with keeping things organized, but there have been times where I wish I could add some more variables to the "mini game section", so my question is:
Is there any way to "shift" or reorganize variables? Could I change all references to variable 001, to variable 002 in events or something?
Weeeeeeell....kinda-sorta, but not really.
What you can do is open all of your json files in like Notepad++ or something and replace all occurrences of $gameVariables.value(x) with $gameVariables.value(y). And you could also do a global replace on the event command for manipulating variables to do the same replacement. But this won't change the references in plugin parameters which use that variable for something, or anywhere you've just referenced it as an ID.
Some of those event commands sometimes use variables though, so you'd have to include a test there to say "if parameter 2 is 1, then parameter 3 is a variable id and might need to change, otherwise it's a constant and should be left alone".
Yeah, it might be possible with some crafty regexp replacements. But if you have 500 variables defined and you want to insert an extra few before #100, that means you'd have to run your manual replacer up to 400 times.
I'd rather have a slightly messy database, especially as nobody is ever going to see it when they play 😀 The order of items, weapons, armors, etc is a much more visible thing.
This topic's actually whet my appetite a bit, I might write a tutorial for doing this and cover every possible match/regex you'd need for it.
You're right though: the payoff in most cases wouldn't be worth the expenditure of effort. This would mainly be if you're *really*, *really* keen on having your data that organised.
I've written a process for RMXP that does this (along with all database items as well), which is a bit more difficult as files are Marshalled instead of human-readable like MV's json. I'll be releasing the RMXP version in the next few days.
I was planning to add MV support, but it's a Ruby script requiring Ruby to be installed on the user's machine due to XP's quirks, which isn't a good prerequisite for MV users. XP users on the other hand can deal with it 😎
Maybe I'll release it as its own thing, separately. We'll see. The code only took like a day or two to write, its just grindy, not difficult. I don't use MV so the motivation isn't quite there for me yet, but keep an eye out for it. Considering the notes system exists in MV, it'd have a better chance of compatibility with scripts as you can track items using an identifier in there (unlike XP 🙁)