Problem with Game_Interpreter

phulicon1998

Warper
Member
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:

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: 




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:

Zalerinian

Jack of all Errors
Veteran
Joined
Dec 17, 2012
Messages
4,696
Reaction score
935
First Language
English
Primarily Uses
N/A
line 21 is "this.createRain()", however at that point 'this' refers to a Game_Interpreter object, not a Window_Rain object. There are several ways you could get around that, but the easiest, or at least first that I can think of, would be something like:


Game_Interpreter.prototype.createRain = function() {
SceneManager._scene.windowrain.createRain();
};




However, looking at your code, I can see several problems.

  1. You redefine Window_Rain.update but all it does is call the update function of Window_Base. If you don't add anything else to the function, you don't need to do this. Since Window_Rain inherits from Window_Base, it already has that function and it already does that.
  2. Your plugin command check includes a line to push another map scene on the stack. Why? What is the purpose of this?
  3. You create the window in the start function of Scene_Map, but it would be better placed in create. You should also load in the rain image during this stage because images do not instantly load, they can take time. In many cases it'll be less than a second to load, but it's a noticeable lag.
  4. Your plugin is not encapsulated (wrapped in, surrounded by) an anonymous function. This means that your variables param, RainGraphic, RainSpeed, and all your aliases are all global variables that anyone can access and change. Please look into how anonymous functions work, and what they're used for.



This may seem discouraging, but it's all to help you learn. The best way to learn how to do something, especially programming, to try and fail at it. You learn why what you did didn't work so that you're able to get around such issues in the future. It can take a long time to understand a lot of things, but putting in the effort is the best way to learn how to do it. Don't lose hope, just keep on trying. Use Google to try to find answers to some of your questions if you can't find or get answers on the forums, the internet is an enormous resource for helping developers out.
 

phulicon1998

Warper
Member
Joined
Aug 3, 2014
Messages
2
Reaction score
0
First Language
Vietnamese
Primarily Uses
I can't agree more that my code is such a mess. Thank you very much for helping me with my plugin and giving me some advices, i will try it.  
 
Last edited by a moderator:

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

Latest Threads

Latest Posts

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,035
Messages
1,018,455
Members
137,821
Latest member
Capterson
Top