LOGIN
SEARCH
PROFILE
keys: ↑ ↓
LOGOUT
INDEX
MEMBERS
keys: ↑ ↓
HOME
PORTAL
PLAY ALONG
PLAY with WORDS
PLAY with GRAPHICS
PLAY with SOUNDS
PLAY with CODES
PLAY with PROJECTS
keys: ← →
Guest Access
Register:
Members:



Go to page : 1, 2, 3  Next

View previous topic View next topic Go down Message [Page 1 of 3]

Active Member
Active Member
#1 default How do I use Alias in RGSSx?
Loading

handy333

handy333
Active Member
Active Member
Active Member
profile
How do you use alias? I've looked around google and found some stuff alias vs. alias_method.

You could win a free Theme Song.

Active Member
Show Signature
Active Member
http://projectrisingsun.weebly.com/ http://soundcloud.com/handyfox https://www.youtube.com/channel/UCkBX7ZxqoXslAtqsdrmsn_w
EVENTALIST
EVENTALIST
#2 default Re: How do I use Alias in RGSSx?
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
You alias via variable defining. Here is a sample class function i wish to alias.
Code:

Class_Name.prototype.functionName = function() {
 // Function processing.
};

To alias that i would simply do something similar to the following.
Code:

var alias_Class_Name_functionName = Class_Name.prototype.functionName;

Class_Name.prototype.functionName = function() {
 // Function processing.
 alias_Class_Name_functionName.call(this); // call alias before edit.
};
EVENTALIST
Show Signature
EVENTALIST
Active Member
Active Member
#3 default Re: How do I use Alias in RGSSx?
Loading

handy333

handy333
Active Member
Active Member
Active Member
profile
Thanks.
I guess I just don't get it.
I'll just try to start over with some
small, beginner tutorials one day.
Active Member
Show Signature
Active Member
http://projectrisingsun.weebly.com/ http://soundcloud.com/handyfox https://www.youtube.com/channel/UCkBX7ZxqoXslAtqsdrmsn_w
EVENTALIST
EVENTALIST
#4 default Re: How do I use Alias in RGSSx?
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
You'll get it in time, ever make any progress on that title edit?
EVENTALIST
Show Signature
EVENTALIST
Active Member
Active Member
#5 default Re: How do I use Alias in RGSSx?
Loading

handy333

handy333
Active Member
Active Member
Active Member
profile
I'm still working on it. I'll have to switch back to ace because my trial is running up. I've been actually working on this event GUI. It's not bad at all to look at but the event setup is a noodle factory.

I haven't seen any scripts for it but could you add like a new option at the title screen that will take you to a new scene? Something like a gallery or the like.
Active Member
Show Signature
Active Member
http://projectrisingsun.weebly.com/ http://soundcloud.com/handyfox https://www.youtube.com/channel/UCkBX7ZxqoXslAtqsdrmsn_w
EVENTALIST
EVENTALIST
#6 default Re: How do I use Alias in RGSSx?
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
A plugin buffer for a scene called from the title? Sure i can see how far i can get tonight.
EVENTALIST
Show Signature
EVENTALIST
EVENTALIST
EVENTALIST
#7 default Re: How do I use Alias in RGSSx?
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
Code:
//================================================================================
// TitleCall.js
//================================================================================
/*: @author Mr_Wiggles
 *   Date: 11/14/15
 *   Version: 0.5
 * ------------------------------------------------------------------------------
 * @plugindesc Adds extra option to call custom scene at title menu.
 *
 * @param SceneAdded
 * @desc  This is the name of your Scene Class to call.
 * @default null
 *
 * @param SceneMenuName
 * @desc  This is the name to show in the title options.
 * @default null
 *
 * @help This plugin allows you to add in an extra option into the game title
 * scene and be able to call it from said scene.
 * ------------------------------------------------------------------------------
 */ //============================================================================
//--------------------------------------------------------------------------------
// Auto run: Sets plugin items that are user defined in RMMV.
//--------------------------------------------------------------------------------
(function() {
//============================================================================
// Scene Title
//============================================================================
  var parameters = PluginManager.parameters('TitleCall');
  var sceneToCall = String(parameters['SceneAdded'] || 'null');
  var sceneName = String(parameters['SceneMenuName'] || 'null');
 //------------------------------------------
  Scene_Title.prototype.createCommandWindow = function() {
    this._commandWindow = new Window_TitleCommand();
    this._commandWindow.setHandler('newGame',  this.commandNewGame.bind(this));
    this._commandWindow.setHandler('continue', this.commandContinue.bind(this));
    this._commandWindow.setHandler('options',  this.commandOptions.bind(this));
    this._commandWindow.setHandler(sceneName, this.commandCallScene.bind(this));
    this.addWindow(this._commandWindow);
  };
  //------------------------------------------
  Window_TitleCommand.prototype.makeCommandList = function() {
    this.addCommand(TextManager.newGame,   'newGame');
    this.addCommand(TextManager.continue_, 'continue', this.isContinueEnabled());
    this.addCommand(TextManager.options,   'options');
    this.addCommand(sceneName, sceneName);
  };
  //------------------------------------------
  Scene_Title.prototype.commandCallScene = function() {
    this._commandWindow.close();
    return eval("SceneManager.goto(" + sceneToCall + ")");
  };
})(); // End of plugin block.

Here is what i threw together so far. Only problem is it wont call any scene other the then the default. I thought it had something to do with the plugin scenes not being created until i tried using "PluginManager.setup($plugins);" from main.js and still nothing. It works, how ever I'm just not sure as to why it wont work with plugin script scene names. It calls all of the built in scenes just fine though.

"Scene_Save, Scene_Battle, Scene_Item,.. ect." Head scratcher as to why it doesn't count the new scripts into the list of loaded object classes.
EVENTALIST
Show Signature
EVENTALIST
Active Member
Active Member
#8 default Re: How do I use Alias in RGSSx?
Loading

handy333

handy333
Active Member
Active Member
Active Member
profile
I'm still using ace. I'm not sure but my trial ran out.
Active Member
Show Signature
Active Member
http://projectrisingsun.weebly.com/ http://soundcloud.com/handyfox https://www.youtube.com/channel/UCkBX7ZxqoXslAtqsdrmsn_w
EVENTALIST
EVENTALIST
#9 default Re: How do I use Alias in RGSSx?
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
I made minor edits to it, and some part where i did some testing:
Code:
//================================================================================
// TitleCall.js
//================================================================================
/*: @author Mr_Wiggles
 *   Date: 11/14/15
 *   Version: 0.5
 * ------------------------------------------------------------------------------
 * @plugindesc Adds extra option to call custom scene at title menu.
 *
 * @param SceneAdded
 * @desc  This is the name of your Scene Class to call.
 * @default null
 *
 * @param SceneMenuName
 * @desc  This is the name to show in the title options.
 * @default null
 *
 * @help This plugin allows you to add in an extra option into the game title
 * scene and be able to call it from said scene.
 * ------------------------------------------------------------------------------
 */ //============================================================================
//--------------------------------------------------------------------------------
// Auto run: Sets plugin items that are user defined in RMMV.
//--------------------------------------------------------------------------------
(function() {
//============================================================================
// Scene Title
//============================================================================
  var parameters = PluginManager.parameters('TitleCall');
  var sceneToCall = String(parameters['SceneAdded'] || 'null');
  var sceneName = String(parameters['SceneMenuName'] || 'null');
  var fileName = String(parameters['FileName'] || 'null');
 //------------------------------------------
  Scene_Title.prototype.createCommandWindow = function() {
    this._commandWindow = new Window_TitleCommand();
    this._commandWindow.setHandler('newGame',  this.commandNewGame.bind(this));
    this._commandWindow.setHandler('continue', this.commandContinue.bind(this));
    this._commandWindow.setHandler('options',  this.commandOptions.bind(this));
    this._commandWindow.setHandler(sceneName, this.commandCallScene.bind(this));
    this.addWindow(this._commandWindow);
  };
  //------------------------------------------
  Window_TitleCommand.prototype.makeCommandList = function() {
    this.addCommand(TextManager.newGame,   'newGame');
    this.addCommand(TextManager.continue_, 'continue', this.isContinueEnabled());
    this.addCommand(TextManager.options,   'options');
    this.addCommand(sceneName, sceneName);
  };
  //------------------------------------------
  Scene_Title.prototype.commandCallScene = function() {
    if (PluginManager._scripts.contains(sceneToCall)) {
      this._commandWindow.close();
      this.fadeOutAll();
      var testScene = 'Scene_Options'; // Built in RGGS scene name to test call
      //SceneManager.goto(eval(testScene)); // Works - shutsdown when called scene exited
      //SceneManager.goto(eval(sceneToCall)); // No work at all, not found
      SceneManager.push(eval(testScene)); // Works - returns to prevous scene when exited
      //SceneManager.push(eval(sceneToCall)); // No work at all, not found
    }
  };
  //------------------------------------------
  //eval('function ' + sceneToCall + '() {return Scene_Base; }');
  //eval(sceneToCall + '.prototype = Object.create(Scene_Base.prototype)');
  //eval(sceneToCall + '.prototype.constructor = ' + sceneToCall);
})(); // End of plugin block.

The plugin name in the data base must be the same as the scene's name you are calling.

It works when you call a built in RGGS scene but not when its a plugin. There is a spot line numbers 54 - 58 you can see where i tested the call method i was using and took notes.
EVENTALIST
Show Signature
EVENTALIST
EVENTALIST
EVENTALIST
#10 default Re: How do I use Alias in RGSSx?
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
Are you asking about aliasing in Ruby? Sorry read this section as RMMV for some reason, to alias in Ruby you just need to do something similar to the following:

Code:

# un-altered ORIGINAL script:
class Sample
  def initialize
    # Do some code here in original un-aliased class.
  end
end

You want to make additions to that definition "initialize" for example, say tacking on code before or after the definition block in the class? Or even bypassing the function and replacing it with a new one but still occasionally calling the original?

You can do all of that above by using one of these three methods:
Code:

class Sample
  alias :new_initialize :initialize
  def initialize # Unaltered name from the original function block defined.
     # ----------------------------------------
     # Do code BEFORE alias to original HERE:
     # ----------------------------------------
     new_initialize # call original UN-altered function NOW.
     # ----------------------------------------
     # Do code AFTER alias to original script HERE:
     # ----------------------------------------
     # Bellow is how you would by pass the original but still be able to call it if needed:
     if condition == true
       new_initialize # call original UN-altered function NOW.
     end
     # ----------------------------------------
  end
end


Say you have a class function you want to alias but its got arguments, and you wanna change those:
Code:

class Sample
  def refresh(x, y, z, alpha, color, name)
    # some code
  end
end

You can do something like this and grab the arguments and pass em along.
Code:

class Sample
  alias :new_refresh :refresh
  def refresh(*args)
    args = *args
    args = [args] unless args.is_a?(Array)
    # This way you can add/subtract args to the original function as well.
    x, y, z, alpha, color, name = args
    # You can make changes to the argument variables now.
    new_refresh(x, y, z, alpha, color, name)# call original UN-altered function NOW.
  end
end


Sorry about the confusion talking about Java in a Ruby thread, lol. Any questions?
EVENTALIST
Show Signature
EVENTALIST

Sponsored content

profile

View previous topic View next topic Back to top Message [Page 1 of 3]

Go to page : 1, 2, 3  Next

 

Chatbox system disabled
Personal messaging disabled