Hey, I've been doing some work with the plugin again, and I found another bug. And while I am thinking about, I have some suggestions that I thought I would mention.
Bug
While loading a test file, I kept getting playtimes on the files that looked wrong. I am not super familiar with JavaScript, but it appeared to me that the code was:
- e = system._framesOnSave from the old save
- o (hours) = Math.floor(e/3600)
- e (minutes this time) = Math.floor((e-3600*o)/60)
So unless I am overlooking something in the code, the intent appears to be to divide the number of frames by 60 to get minutes and then 60 again to get hours. Problem is that there are 60 frames per second. So you are actually getting minutes and seconds instead of hours and minutes.
I changed the formulas to:
- o= Math.floor(e/216000)
- e = Math.floor((e-216000*o)/3600)
And the numbers I am getting are looking more reasonable. Alternatively, this could be fixed by dividing the frames by 60 before using them to calculate the hours.
Minor Suggestion
Add spaces to the default Old Saves loading message parts. Currently by default, the message will appear as "Savefile:file1 Playtime:75hoursand50min." It looks better as: "Savefile: file1 Playtime: 75 hours and 50 min." While devs can certainly add spaces themselves, I think it just presents a better first impression.
Note: If you act on this, make sure you are changing the mainText default entry. I spent a good amount of time messing with the translation under ~struct~mainText for the default translations unable to figure out why it wasn't working. XD Although, I guess making the default English translation consistent with the default settings also wouldn't be a horrible idea.
Feature Suggestion - Additional Error Handling
While testing an import, I encountered a "Searching for an old value out of range." Reason for that was that I was intentionally testing a save that I knew would cause problems. But I checked all the variables that were being imported and I found one that could cause issues from a proper save. Basically, it is a variable for an entirely optional quest and everything with a variable number higher it is also optional.
I was able to just code around this by adding a length check and if the variable array isn't long enough, I just write a null value to extend it.
However, it might be useful to add in the ability to change the way the plugin handles out of range errors by treating them as 0s, the same way you can change how it handles nulls.
Feature Suggestion - Old Save Removal
So in the game I'm collaborating on, there are multiple potential valid conditions for the save being imported (e.g., variable 1 > 5 or variable 2 > 10). As a result, the game imports and then checks for both the conditions. If the player later realizes they don't have a save to import, the originally imported save could be left in their save forever. I handle this with "delete $gameSystem._currentOldSave;" as a script.
While my usage of deleting the old save might be an edge case, adding the functionality to the plugin could be useful for purposes of reducing save size if a developer has copied over all the data they want from the old save.
Feature Suggestion - Old Save Pruning
Speaking of reducing save size, there is a lot of unused data in the currentOldSave such as settings for plugins from the old game. This will needlessly balloon the save size. So maybe add an option to choose which data to import? By default have the pruning (if enabled) keep variables, actors, switches, selfSwitches, and CurrentOldSave(in case you import a save that already has imported data?) with the option to add or remove sections? Here is the script I used to handle pruning in the game I'm working on in case it is helpful. I did not keep self switches in this code. Also, I do not fully understand this code, just modified some code for removing properties that I found online.
const allowedProperties = ['variables', 'actors', 'switches'];
const allKeys1 = Object.keys($gameSystem._currentOldSave);
$gameSystem._currentOldSave = allKeys1.reduce((next, key) => { if (allowedProperties.includes(key)) { return { ...next, [key]: $gameSystem._currentOldSave[key] };
} else { return next; } }, {});
Random Musing - Importing Imported Data
This might be too niche to warrant acting on, but while working with the pruning stuff, it occurred to me that by default if you import a save that already has an import, all the data from the imported file will still be there, just unusable.
I think that covers everything I was thinking of. Hope this was helpful and not just the ramblings of a crazy person. :P