Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

How should i make an event for erasing a save file?

Desro

Villager
Xy$
0.00
Well, I see:

StorageManager.remove = function(savefileId) {
if (this.isLocalMode()) {
this.removeLocalFile(savefileId);
} else {
this.removeWebStorage(savefileId);
}
};

so... wherever you want this to happen in the logic of your game, put in a script command:
StorageManager.remove(savefileId);
It worked like a charm for me, I saved a file on slot 1, put the command as:
StorageManager.remove(0);
and the save file was deleted. You may want to set up some way to determine savefileId, of course.
 

Desro

Villager
Xy$
0.00
var latestSave = DataManager.lastAccessedSavefileId();
var randNum = function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}

var deleteSaveId = randNum(1,3);

while (deleteSaveId == latestSave) {
deleteSaveId = randNum(1,3);
}
StorageManager.remove(deleteSaveId);

_______________

That can be added as a script call and it will do this for you:
It will find out the last accessed save file id - which, in my testing, seems to be the last save file the player created, not necessarily the last save file that they loaded from - then it will get a random number between 1 and 3 (inclusive and specific to your case). This number will be the number that is deleted as long as it doesn't match the last accessed save file id. It will then delete that save file even if the file doesn't exist.
 
Top