Why won't this properly save the array called BISH.respawnEvents?
Logging the value during save returns the correct information:
Upon extracting, it logs:
Is it that the array is not indexed with integers? It's the only thing I can think of. Or is there another reason?
Is it because it is an object?
Regardless of the cause, can I somehow save the array and its contents?
And can someone tell me what an array that doesn't have index numbers is called?
Best regards,
Bishiba
EDIT:
Did a test by doing:
And the extract log gave me:
So it seems that the issue lies with the integers.
So... My alternative, that I can come up with, given my current experience is that instead of using a string "x, y" I can use z = Math.round("x" + "y"). This will give me an integer. However. The integer might get a value of upwards to 500000. And, I am relatively sure that having an array of that size that only utilizes maybe 1-2% of the size is rather pointless. But at least it works, however, before I do that, does anyone have another idea? 🙂
This only reaches 10000, but that's because the mapId is 104 and the eventId is 46, if the eventId was also above 100, then it would be 100000. But, perhaps there is no downside to having a big array as long as the contents are null?
Logging the value during save returns the correct information:
Upon extracting, it logs:
Is it that the array is not indexed with integers? It's the only thing I can think of. Or is there another reason?
JavaScript:
//Saving contents
BISH.DataManager_makeSaveContents = DataManager.makeSaveContents;
DataManager.makeSaveContents = function() {
var contents = BISH.DataManager_makeSaveContents.call(this);
var difficulty = {};
difficulty._heroDamage = Difficulty._heroDamage;
difficulty._enemyDamage = Difficulty._enemyDamage;
contents.bishEvents = BISH.respawnEvents;
console.log(contents.bishEvents);
contents.difficulty = difficulty;
return contents;
};
BISH.DataManager_extractSaveContents = DataManager.extractSaveContents;
DataManager.extractSaveContents = function(contents) {
BISH.DataManager_extractSaveContents.call(this, contents);
BISH.respawnEvents = contents.bishEvents;
var difficulty = contents.difficulty;
Difficulty.setDifficulty(difficulty._heroDamage, difficulty._enemyDamage);
};
JavaScript:
BISH.respawnEvents = [];
BISH.setLastKilledEventEnemy = function(killedEvent) {
var mapEventString = BISH.getMapEventString(killedEvent);
var deathDate = new Date;
BISH.respawnEvents[mapEventString] = {};
killedEvent = BISH.respawnEvents[mapEventString];
killedEvent.deathDate = deathDate.getTime();
killedEvent.respawnDate = false;
};
BISH.getMapEventString = function(mapEvent) {
return mapEvent._mapId + ", " + mapEvent._eventId;
};
Game_Event.prototype.eventRespawn = function (minutes) {
minutes = minutes || 15; //Base time is 15 minutes.
var time = minutes * 60 * 1000; //Convert time into milliseconds.
var compareDate = new Date;
mapEvent = BISH.respawnEvents[BISH.getMapEventString(this)];
if (mapEvent.respawnDate == false) mapEvent.respawnDate = mapEvent.deathDate + time;
compareDate = mapEvent.respawnDate - compareDate.getTime();
//console.log("Respawn in: " + (compareDate / 1000 / 60).toFixed(0));
if (compareDate <= 0) return true;
};
Is it because it is an object?
JavaScript:
Line 6: BISH.respawnEvents[mapEventString] = {};
Regardless of the cause, can I somehow save the array and its contents?
And can someone tell me what an array that doesn't have index numbers is called?
Best regards,
Bishiba
EDIT:
Did a test by doing:
And the extract log gave me:
So it seems that the issue lies with the integers.
So... My alternative, that I can come up with, given my current experience is that instead of using a string "x, y" I can use z = Math.round("x" + "y"). This will give me an integer. However. The integer might get a value of upwards to 500000. And, I am relatively sure that having an array of that size that only utilizes maybe 1-2% of the size is rather pointless. But at least it works, however, before I do that, does anyone have another idea? 🙂
This only reaches 10000, but that's because the mapId is 104 and the eventId is 46, if the eventId was also above 100, then it would be 100000. But, perhaps there is no downside to having a big array as long as the contents are null?