Aliasing Functions that Return (RMMV)

Joined
Apr 25, 2018
Messages
1
Reaction score
0
First Language
English
Primarily Uses
RMMV
Hello everyone,

I'm working on a script and I'm a bit stuck when it comes to aliasing. If I wanted to alias a function that already has a return command, how would I go about doing so? Unless I'm misunderstanding something (likely) calling the aliased function inside the new function definition triggers the return command before any of my other commands can be called. I know there's a way around this, but I'm not sure what it is.

I want to alias DataManager.makeSaveContents. Can anyone point me in the right direction for how to make this alias?

I have tried a few things, and none of it worked. I can't post the code/error messages right now because I don't have it with me.

Thanks
 

mlogan

Global Moderators
Global Mod
Joined
Mar 18, 2012
Messages
15,351
Reaction score
8,532
First Language
English
Primarily Uses
RMMV

I've moved this thread to Learning Javascript. Please be sure to post your threads in the correct forum next time. Thank you.

 

ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
954
Reaction score
520
First Language
Javascript
Primarily Uses
RMMZ
alias a function that already has a return command, how would I go about doing so?
I want to alias DataManager.makeSaveContents. Can anyone point me in the right direction for how to make this alias?
Basically it's like this...
  1. store the returned value in a variable
  2. do whatever you want with/to that variable
  3. return that variable
Code:
$saveExpansionData = {demoData:'hello world'};
var $ = {}:
$['DataManagar_makeSaveContents'] = DataManager.makeSaveContents;
DataManager.makeSaveContents = function() {
  var contents = $['DataManagar_makeSaveContents'].apply(this, arguments);
  contents.saveExpansionData  = $saveExpansionData;
  return contents;
};
$['DataManager.extractSaveContents'] = DataManager.extractSaveContents;
DataManager.extractSaveContents = function(contents) {
  $['DataManager.extractSaveContents'].apply(this, arguments);
  $saveExpansionData = contents.saveExpansionData;
};
Test Demo: Click Here to Download
 
Last edited:

ozubon

surströmming?
Veteran
Joined
Oct 16, 2018
Messages
178
Reaction score
168
First Language
English
Primarily Uses
RMMV
Wouldn't just aliasing it with a function work?
JavaScript:
function newAlias(){return DataManager.makeSaveContents()};
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,975
Members
137,563
Latest member
cexojow
Top