Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

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

Really thank you for the great post, sadly it came in a time when I was forced to a stop an overlooked it, I'll implement the bug fix and find a way to get the suggestions in!

Well I'm glad you ended up finding it. Let me know if there is anything unclear when you try to implement the suggestions.

I'm working on it, fixed the frames, thanks a lot!
As for the spaces, sadly the RMMZ header won't let me add " hours" or " and " but it trims the spaces, so you have to add them manually but it's doable. I don't use auto space because a dev might want to write it as 27h:30m

About the "Out of range value" are you talking about variables? Because there is already a "return 0" option as error handling, if it's about a switch, I didn't add an error handling as it's a true or false value, there isn't a default, but I could make the dev choose

The old save removal is a good suggestion and quite an easy one, I'll add it

And yeah, the pruning might be a little more trickier to implement but actually useful for saveData size

About the importing an imported data... mmhhh.. good question, this actually could be useful in a 3+ chapter game, now what is the answer? Simply clipping any older data (and leave up to the dev how to pass those informations) or enable a layers of old saves? I'll think about it!

Spaces
Ah right, didn't think about the system trimming spaces. 

Out of Range
I have "Variable null (never initialized) on Copy old variable" set to err2 (Pass a zero value).
I loaded a save that has 780 variables and then called the plugin function on variable 790 (intentionally going out of bounds). When I trigger the event that loaded the variable, an error is triggered and I get the error message "Error: WD_OlsSaveLoader: Searching for an old variable out of range." So I don't think the settings currently provide any error handling for this scenario.

Actor error handling also does not seem to handle the scenario either (and switches don't have any error handling).