MV - JSON error when playtesting (unexpected token)

Hello everyone !

I didn't know where to post this thread, wondering where support for game files on RPG Maker MV was. Don't hesitate to change this thread's position on the forum if I have mistaken.

I have a problem right now when I try to playtest my game on the editor. I need to say that I had a problem just days ago about the data files being corrupted, because of a crash of my computer, but as I did a backup, I didn't lose anything.

However, I didn't see until now that I run an error when playtesting on the editor, and here is a picture of that :

Spoiler: image
2019-05-03_11h42_13.png

I wonder what has happened, and I tried to replace the index and rpg files as if I was updating the game, but it didn't change anything. I wonder what is the problem here, and I hope you can help me 🙂

Thank you in advance !


Nantas
Yeah, Tech Support is for when you have problems with the editor, not when playing the game.

So you created a new project, took the index.html file from that and put it into your existing project, and it didn't make a difference? What if you create a brand new project, test play to ensure no errors, then copy everything over except the js folder? You might have to re-add your plugins. I'm wondering how long it's been since you started your project and how many updates you might have taken in that time - the files from a new game might not be compatible with your old scripts.

Other than that I really have no idea without any more information.

You could try opening your rpg_managers.js file and inserting the following line just below 83:
Code:
console.log(name)

so it will at least print what it's trying to load when it gives the error.

I've moved this thread to MV Support. Thank you.

there are several different possibilities what could have caused this, and we need more info to see what it might be.

1) if you make a new project, does the playtest work there?
2) what is the full filepath to the project with the problem? Please state the entire path from drive letter to the index.html
3) have you include any plugin that creates additional datafiles (only a few do and you'll see that mentioned in their descriptions)
4) do you get the same error if you don't use the playtest button but start the index.html directly with firefox or another browser?
5) is there a folder WWW inside your project folder?
Is there a possibility that you have a poorly written notetag?
Spoiler: What I said
I have used the piece of code you wanted me to put on the rpg_managers.js file, @Shaz , and I have solved the problem for two files : MapHUD.js and notes.js in the data folder of the project.

However, it says the same error again, and here is a screenshot of the line that is said to be wrong, line 86 :
Spoiler: image
2019-05-03_14h42_42.png

It seems to be the JSON.parse piece that is wrong ? I don't know why though.

Now I will answer to your questions, @Andar :

1) Yes, the new project runs well. No problem there. I have overwritten the files of my project with these ones to be sure, but it didn't change a thing. Maybe should I see in the plugins ?
2) Sorry, I don't understand the question :/
3) I have the SuperToolsEngine from SRDude and his HUD Maker that create new data files if I am not mistaken.
4) I don't have the same error, it says on browser that it can't read the actors.json file, but I have checked, normally no problem with that file.
5) No folder www ( it's the kind of folder made by doing the deployment, right ? )


I don't think I have a wrong notetag @Poryg , as I didn't do any change in them after the crash.

EDIT :

I have solved the problem ! Actually, three data files were corrupted and needed to be changed with the backup I made :
- MapHUD.json
- Notes.json
- DataEx.json

So the following would be my recommendations to everyone :
Do a backup
When your files get corrupted, replace everything with the files from your backup


Thank you @Andar , @Shaz , and @Poryg !
This error gets thrown when the function JSON.parse doesn't parse something correctly due to some error in the formatting. Which is why I suggested wrong notetag, because I've enjoyed a lot of pain with them.

Bear in mind if you're going to launch the game in a browser, it needs to be either MS Edge or Firefox. Otherwise it gets messed up.
Sorry for the trouble @Poryg, I just solved the problem 🙂 With your help of course 🙂
When your files get corrupted
you forgot one step here:
find out WHY your files got corrupted to prevent a repeat

that is why I asked for the filepath - if you store your projects in either cloudsync'ed folders or the steam folders or several other places with special functions, the chance of corruption is at least ten to twenty times greater than normal.
Or it could be a sign that your hard drive is approaching "end-of-life": Due to the way they handle files, all databasing programs (from the RPG-Makers to Microsoft Access) will react first to impending drive failure, months before other programs get crashed.
My files got corrupted because I lost electricity when using my computer. I wasn't using the editor though, I had it already closed before. It happens a lot with me : sometimes, files get corrupted even when I shut down normally my computer.
And I store my files in a folder inside the desk.

My computer is three years old now and the battery is now bad. Maybe that's the reason ? I can't anyway change my computer, so I prefer to do backups.
If you have Windows 10 with the Microsoft OneDrive active, then that system does cloudspace the desktop (I asked for the filepath because that would have revealed whether that is the case or not) and increases the chance of corruption.

three years is no age for a computer (unless it is very hot in your area or very instable power net)
corruption by power loss is basically normal, but by regular shutdown is NOT.
Battery also has nothing to do with harddrive

Borderline - there is a reason for the file corruption, but I don't think we can find it if that doesn't help.
I am deleting OneDrive from my computer, thank you for the advice.

There is certainly a reason. It only happens three times a year, and 8 times now that I have begun my project. I have had quite a lot of problems with that but now that I am very careful with backups, I am less anxious.
as I said - all programs that use a database-type of file access (MS Access, Filemaker and all RPG-Makers) react faster to a lot of drive access problems, but it can't be done otherwise as the data is too much to be handled with regular file access.
So it is not surprising that you have file corruption more often with the RMs than with regular programs, but that does not mean that the RM is responsible, just that something on your computer is causing the corruption.
Oh, I don't blame at all the engines at all, they are great ! I know that it is because of my computer, I simply think that I won't ever find a solution as I don't see why it is happening.
But I do backups as a counterpart, so don't worry for that.

Thank you @Andar for your help and advices.
If it's due to OneDrive, just create a new folder somewhere on your C drive for your projects to go. That won't be backed up by OneDrive.

Original thread: https://forums.rpgmakerweb.com/threads/mv-json-error-when-playtesting-unexpected-token.108634/