- Joined
- Aug 3, 2014
- Messages
- 2
- Reaction score
- 0
- First Language
- Vietnamese
- Primarily Uses
I have some problem with my script, umh i want to make a plugin command to switch off and on the image on the map. Here is my plugin:
I have just begin with creating MV plugin, i really don't know where i was wrong or maybe, i missed something. Sorry for bad english (i am an asian), i will be very appreciate if anyone can help me with my plugin, thanks in advance.
var param = PluginManager.parameters("KAX_RealisticRain.js");
var RainGraphic = String(param['RainGraphic'] || "rainc6");
var RainSpeed = Number(param['RainSpeed'] || 3);
//=======================================================================
var alias_GI_plugincommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
alias_GI_plugincommand.call(this, command, args);
if (command === 'startRain') {
switch (args[0]) {
case '1':
RainSpeed = 1;
this.image.origin.y -= RainSpeed;
break;
case '2':
RainSpeed = 2;
this.image.origin.y -= RainSpeed;
break;
case '3':
RainSpeed = 3;
this.createRain();
break;
case '4':
RainSpeed = 4;
this.image.origin.y -= RainSpeed;
break;
case '5':
RainSpeed = 5;
this.image.origin.y -= RainSpeed;
break;
case '0':
SceneManager.push(Scene_Map);
break;
};
};
};
//===========================================================
function Window_Rain() {
this.initialize.apply(this, arguments);
}
Window_Rain.prototype = Object.create(Window_Base.prototype);
Window_Rain.prototype.constructor = Window_Rain;
Window_Rain.prototype.initialize = function(x, y) {
var width = this.windowWidth();
var height = this.windowHeight();
Window_Base.prototype.initialize.call(this, x, y, width, height);
this.refresh();
};
Window_Rain.prototype.windowWidth = function() {
return 816;
};
Window_Rain.prototype.windowHeight = function() {
return 624
};
Window_Rain.prototype.refresh = function() {
var x = this.textPadding();
var width = this.contents.width - this.textPadding() * 2;
this.contents.clear();
};
Window_Rain.prototype.createRain = function() {
this.image = new TilingSprite();
this.image.bitmap = ImageManager.loadPicture(RainGraphic);
this.image._onBitmapLoad();
this.image.move(0, 0, Graphics.width, Graphics.height);
this.image.opacity = 70;
this.addChild(this.image);
this.updateRain();
};
Window_Rain.prototype.updateRain = function() {
this.image.origin.y -= 3;
};
Window_Rain.prototype.update = function() {
Window_Base.prototype.update.call(this);
};
Window_Rain.prototype.open = function() {
this.refresh();
Window_Base.prototype.open.call(this);
};
//====================================================================
var ailias_SC_start = Scene_Map.prototype.start;
Scene_Map.prototype.start = function() {
ailias_SC_start.call(this);
this.windowrain = new Window_Rain(0, 0);
this.windowrain.opacity = 0;
this.addChild(this.windowrain);
};
//=====================================================================
I run my code with Plugin Command is startRain 3 and it gets errors below:
var RainGraphic = String(param['RainGraphic'] || "rainc6");
var RainSpeed = Number(param['RainSpeed'] || 3);
//=======================================================================
var alias_GI_plugincommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
alias_GI_plugincommand.call(this, command, args);
if (command === 'startRain') {
switch (args[0]) {
case '1':
RainSpeed = 1;
this.image.origin.y -= RainSpeed;
break;
case '2':
RainSpeed = 2;
this.image.origin.y -= RainSpeed;
break;
case '3':
RainSpeed = 3;
this.createRain();
break;
case '4':
RainSpeed = 4;
this.image.origin.y -= RainSpeed;
break;
case '5':
RainSpeed = 5;
this.image.origin.y -= RainSpeed;
break;
case '0':
SceneManager.push(Scene_Map);
break;
};
};
};
//===========================================================
function Window_Rain() {
this.initialize.apply(this, arguments);
}
Window_Rain.prototype = Object.create(Window_Base.prototype);
Window_Rain.prototype.constructor = Window_Rain;
Window_Rain.prototype.initialize = function(x, y) {
var width = this.windowWidth();
var height = this.windowHeight();
Window_Base.prototype.initialize.call(this, x, y, width, height);
this.refresh();
};
Window_Rain.prototype.windowWidth = function() {
return 816;
};
Window_Rain.prototype.windowHeight = function() {
return 624
};
Window_Rain.prototype.refresh = function() {
var x = this.textPadding();
var width = this.contents.width - this.textPadding() * 2;
this.contents.clear();
};
Window_Rain.prototype.createRain = function() {
this.image = new TilingSprite();
this.image.bitmap = ImageManager.loadPicture(RainGraphic);
this.image._onBitmapLoad();
this.image.move(0, 0, Graphics.width, Graphics.height);
this.image.opacity = 70;
this.addChild(this.image);
this.updateRain();
};
Window_Rain.prototype.updateRain = function() {
this.image.origin.y -= 3;
};
Window_Rain.prototype.update = function() {
Window_Base.prototype.update.call(this);
};
Window_Rain.prototype.open = function() {
this.refresh();
Window_Base.prototype.open.call(this);
};
//====================================================================
var ailias_SC_start = Scene_Map.prototype.start;
Scene_Map.prototype.start = function() {
ailias_SC_start.call(this);
this.windowrain = new Window_Rain(0, 0);
this.windowrain.opacity = 0;
this.addChild(this.windowrain);
};
//=====================================================================
I run my code with Plugin Command is startRain 3 and it gets errors below:
I have just begin with creating MV plugin, i really don't know where i was wrong or maybe, i missed something. Sorry for bad english (i am an asian), i will be very appreciate if anyone can help me with my plugin, thanks in advance.
Last edited by a moderator:

