Guest Access
Go to page : 1, 2, 3
Active Member
Active Member
Active Member
profile
handy333
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.
You could win a free Theme Song.
Active Member
Show Signature
EVENTALIST
EVENTALIST
EVENTALIST
profile
mr_wiggles
profile
You alias via variable defining. Here is a sample class function i wish to alias.
To alias that i would simply do something similar to the following.
- 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
Active Member
profile
handy333
profile
Thanks.
I guess I just don't get it.
I'll just try to start over with some
small, beginner tutorials one day.
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
EVENTALIST
EVENTALIST
EVENTALIST
profile
mr_wiggles
profile
You'll get it in time, ever make any progress on that title edit?
EVENTALIST
Show Signature
EVENTALIST
Active Member
Active Member
Active Member
profile
handy333
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.
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
EVENTALIST
EVENTALIST
EVENTALIST
profile
mr_wiggles
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
EVENTALIST
profile
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.
mr_wiggles
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
Active Member
profile
handy333
profile
I'm still using ace. I'm not sure but my trial ran out.
Active Member
Show Signature
EVENTALIST
EVENTALIST
EVENTALIST
profile
mr_wiggles
profile
I made minor edits to it, and some part where i did some testing:
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.
- 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
EVENTALIST
profile
mr_wiggles
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:
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:
Say you have a class function you want to alias but its got arguments, and you wanna change those:
You can do something like this and grab the arguments and pass em along.
Sorry about the confusion talking about Java in a Ruby thread, lol. Any questions?
- 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
Go to page : 1, 2, 3