Request: S&R with Variables in all .json Files

Hi!

I would like to request a little program that raises the common event IDs referred to from other places (other common events and maps).

The .json files in the data folder can be read with a text editor, and I found out what the event command for calling a common event looks like:

"{"code":117,"indent":0,"parameters":[x]}"With x being the ID of the common event called.

Now every so often you want to move common events in the database. The most common scenario for me is that I want to insert a common event, thus having to move all following common events down by a step.

Unfortunately, as you all know, RPG Maker MV does not change the references of the common events that were moved. So if I move down common event 10 to position 11, other events still falsely want to call 10. The solution to this is to go through all your other events and manually change which common event is called.

That is, of course, not a real solution. It takes a lot of time, and you may even miss some instances where a common event is called, resulting in bugs.

Therefore, I would like to request a program that does this for me. I wrote some pseudo code to explain what I would like to do. I would like to put the program into the "data" folder, and when I click it, it runs something like this:

User-Input: $min = ?   // Number of the first common event that is moved.User-Input: $max = ?   // Number of the second-to-last common event.cycle { search all .json files in directory for this: "{"code":117,"indent":0,"parameters":[$max]}" for each match { $new = $max + 1; replace matched text with this: "{"code":117,"indent":0,"parameters":[$new]}"; } $max = $max - 1; if ($max == $min) { break; }}end;I hope this is kind of understandable.

Does anyone here feel up to this task that could potentially save hours of frustration? 🙂
I am actually going to convert my Cross Reference script from Ace to MV, which should help you out, not just with common events, but with EVERYTHING in the database.
Oh, you are? 🙂 That's really good news! I'm SO looking forward to that! Any estimations yet when you'll tackle it?
I will see if I can get it done by next weekend. Is that soon enough for you, or do you really need it urgently?
Oh, I think I can go through the common events manually one more time or do some mapping. 🙂 So next weekend would be just awesome! Are you planning on doing a one-for-everything tool or split it up by database sections?
Sorry - I've only just seen this question.

It will be just like my Ace script - let you choose Actors, Enemies, Weapons, Switches, Variables, once you choose it will give you a list of all of them, and when you choose one of those it'll show you all the places it's used.

I'm currently working on a couple of more urgent things though, so this will take a bit longer to finish.  Plus, it's a huge script 🙂
Heh, so my subtle hint with liking your post did in fact work. 😀

So if I understand it correctly, your script does only LIST the occurences of, for instance, a common event. Unfortunately, that doesn't help THAT much in my scenario (while I'm sure it will come in handy at other times!). Most of the time, I have a pretty accurate idea of where the common event is being used, it's the work of manually changing the references that I would like to get rid of.

A small script/parser (in any programming language) that goes through the .json map data text in a given directory (or simply the directory the script is located in), checks for "{"code":117,"indent":0,"parameters":[x]}" and replaces matches with "{"code":117,"indent":0,"parameters":[x + 1]}" would do exactly what I need.

The most tricky part is the "variable" of the ID, I guess. Theoretically, I could copy the text of all maps into an editor and replace "{"code":117,"indent":0,"parameters":[10]}" with "{"code":117,"indent":0,"parameters":[11]}", then 9 with 10, then 8 with 9 if I wanted to increase common events 8 to 10 by 1. It's just a lot of work that a machine can take care of MUCH(!) faster. I don't know how a variable can be implemented, though, but I suppose one of the clever scripters in these forums know a way. 🙂
A small script/parser (in any programming language) that goes through the .json map data text in a given directory (or simply the directory the script is located in), checks for "{"code":117,"indent":0,"parameters":[x]}" and replaces matches with "{"code":117,"indent":0,"parameters":[x + 1]}" would do exactly what I need.
Why don't you use a text editor for that? There are several advanced text editors that can do a search-and-replace over any number of files.

You might try textpad for example - that's one that I used several times for such work, and it has a free trial

OK, it cannot perform calculations on the search and you'll have to seach for each version of X in a single step - but it would still have been faster than waiting for a plugin here...
Yeah, the problem is that I want to INSERT a common event. Let's say, I want to insert one between 10 and 11, but I have 100 common events. I would need to search and replace all 100 with 101, then 99 with 100 and so on until I reach 10. That takes a very, very long time and is tedious as well.
Yeah - in the grand purpose of things, the next step would be to allow you to re-order/reorganize the database and everything referencing what you're changing will be automatically updated.  But that's still in the design phase.  What the current script does, and the new plugin will do, is tell you which maps, which events, what page of the event, and what line and command has the reference, so you know exactly where you need to look to change it.
Ah, okay. So SOME DAY we'll have that. That's a little too far away for me, I'm afraid. :/ So, anyone else here with a smaller-scope short-term solution?

Original thread: https://forums.rpgmakerweb.com/threads/request-s-r-with-variables-in-all-json-files.52002/