I'm not sure the best way to explain this but I'm trying to create a function that can be called through a script call in an event. I'm trying to allow the contents of my window be changed via a script call, basically allowing me to set the icon and the text through a function I create. Here is the function I made with the best of my knowledge on how they work.
So what I'm trying to do here is create a function called setWindowPop with the parameters being icon and text.
I then put the parameters in variables ( if that's allowed I still have ruby in my brain when scripting) and then I call the drawText and draw Icon methods to output the variables . The next thing I do is I go to an event and do a script call for ( I've tried a few different ways)
I would keep getting errors though and the console log won't point to my script only to game_interperter but it would throw undefined not a function, and I don't quite remember the other ones.
Here is the full script without the parameters at the top.
P.S this is just some code that I am having fun with, I been testing different methods and trying to get the hang of the whole window and scene cores, so if this current script looks a bit off, it's because I been testing a lot.
Thanks
JavaScript:
Window_Pop.prototype.setWindowPop = function(icon, text) {
this._icon = icon;
this._text = text;
var x = this.textPadding();
var width = this.contents.width - this.textPadding() * 2;
this.fontSize = 18;
this.drawTextEx(this._text, 0, 0);
this.drawIcon(this._icon, 0, 0);
}
I then put the parameters in variables ( if that's allowed I still have ruby in my brain when scripting) and then I call the drawText and draw Icon methods to output the variables . The next thing I do is I go to an event and do a script call for ( I've tried a few different ways)
Code:
this.Window_Pop.setWindowPop(5, 'Hello'); //One way I tried
this.setWindowPop(5, 'Hello'); // Another way
Window_Pop.setWindowPop(5, 'Hello'); // and another way lol
Here is the full script without the parameters at the top.
JavaScript:
// =============================================================================
// Alias Nethod: Scene_Map Start
// =============================================================================
LTN.WindowPop_oldMapSceneStart = Scene_Map.prototype.start
// =============================================================================
Scene_Map.prototype.start = function() {
this.createWindowPop();
LTN.WindowPop_oldMapSceneStart.call(this);
};
// =============================================================================
// New Method:Scene Map Create Window Pop
// =============================================================================
Scene_Map.prototype.createWindowPop = function() {
this._WindowPop = new Window_Pop();
this.addChild(this._WindowPop);
};
//=============================================================================
// New Window* Window Pop
//=============================================================================
function Window_Pop() {
this.initialize.apply(this, arguments);
}
Window_Pop.prototype = Object.create(Window_Base.prototype);
Window_Pop.prototype.constructor = Window_Pop;
//-------=====---------
//Initialize
//-------=====---------
Window_Pop.prototype.initialize = function(x, y) {
var width = 350;
var height = this.fittingHeight(1);
var x = LTN.Param.windowX;
var y = LTN.Param.windowY;
Window_Base.prototype.initialize.call(this, x, y, width, height);
this.refresh();
};
//-------=====---------
// hide
//-------=====---------
Window_Pop.prototype.hide = function(){
this.visible = false;
}
//-------=====---------
//Width
//-------=====---------
Window_Pop.prototype.windowWidth = function() {
return 350;
}
//-------=====---------
//Refresh
//-------=====---------
Window_Pop.prototype.refresh = function() {
this.contents.clear();
this.setWindowPop(this.popIcon, this.popString);
};
//-------=====---------
// Draw contents
//-------=====---------
Window_Pop.prototype.setWindowPop = function(popIcon, popString) {
var _icon = this.popIcon;
var _text = this.popString;
var x = this.textPadding();
var width = this.contents.width - this.textPadding() * 2;
this.drawTextEx(this._text, 0, 0);
this.drawIcon(this._icon, 0, 0);
}
Thanks