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 would I properly Alias DataManager.extractSaveContents?

TheUnproPro

Boondoggle
Staff member
Resource Team
Partner
I'm having troubles aliasing the Datamanger properly. I'm currently writing a plugin that I want to save new values to the save file. How would I properly alias this function, because I've tried both call and apply.

JavaScript:
var fp_dmexc = DataManager.extractSaveContents
DataManager.extractSaveContents = function(contents) {
    fp_dmexc.call(this);
    FS_VARS = contents.fpData;
    FP = contents.fpAmount;
};
this results in an error... not sure why.

EDIT: I've left the makeSaveContents part default for now (besides adding in my 2 variables at the bottom properly, this works fine as long as I don't alias extractSaveContents)
 

LTN Games

Master Mind
Resource Team
Xy$
0.01
Try this, I'm on my phone so I can't test.
JavaScript:
var fp_dmexc = DataManager.extractSaveContents
DataManager.extractSaveContents = function(contents) {
// you forgot the argument contents
    fp_dmexc.call(this, contents);
    FS_VARS = contents.fpData;
    FP = contents.fpAmount;
};
Basically you forgot to add the argument for the main function inside your alias. If you were to use .apply instead you can simply do
.apply (this, arguments);
 

TheUnproPro

Boondoggle
Staff member
Resource Team
Partner
Thanks so much! It worked, thought I had tried that earlier but I guess I was wrong lol
basically I'm making a Faith Shrine script, pretty neat.
upload_2016-7-22_19-46-17.png
 
Top