Trying to recreate the Message-Window

Hi, to understand how the interface in MV works I tried to recreate my own Game_Message but although I think I make everything right I only got the ReferenceError "$klrgMessage is not defined".

Here is a step by step what I did in the plugin:

1. Set up the PlugIn:

var Imported = Imported || {};Imported.FRO_Windows = true;var KLRG = KLRG || {};KLRG.FRO_Windows = KLRG.FRO_Windows || {};KLRG.Parameters = PluginManager.parameters('FRO_Windows');KLRG.Param = KLRG.Param || {};2. Set up $klrgMessage:

var $klrgMessage = null;DataManager.createGameObjects = function() { $gameTemp = new Game_Temp(); $gameSystem = new Game_System(); $gameScreen = new Game_Screen(); $gameTimer = new Game_Timer(); $gameMessage = new Game_Message(); $gameSwitches = new Game_Switches(); $gameVariables = new Game_Variables(); $gameSelfSwitches = new Game_SelfSwitches(); $gameActors = new Game_Actors(); $gameParty = new Game_Party(); $gameTroop = new Game_Troop(); $gameMap = new Game_Map(); $gamePlayer = new Game_Player(); $klrgMessage = new KLRGAME_Message(); };3. SetUp KLRG_message

  1. I copy/pasted the Window_Message-Code and replaced (Window_Message -> KLRG_Message) and ($gameMessage -> $klrgMessage).
4. I copy/pasted parts of Game_Message and changed them accordingly:

function KLRGAME_Message() { this.initialize.apply(this, arguments);}KLRGAME_Message.prototype.initialize = function() { this.clear();};KLRGAME_Message.prototype.clear = function() { this._texts = []; //this._choices = []; this._faceName = ''; this._faceIndex = 0; this._background = 0; this._positionType = 2; //this._choiceDefaultType = 0; //this._choiceCancelType = 0; //this._choiceBackground = 0; //this._choicePositionType = 2; //this._numInputVariableId = 0; //this._numInputMaxDigits = 0; //this._itemChoiceVariableId = 0; //this._itemChoiceItypeId = 0; //this._scrollMode = false; //this._scrollSpeed = 2; //this._scrollNoFast = false; //this._choiceCallback = null;};KLRGAME_Message.prototype.add = function(text) { this._texts.push(text);};KLRGAME_Message.prototype.setFaceImage = function(faceName, faceIndex) { this._faceName = faceName; this._faceIndex = faceIndex;};KLRGAME_Message.prototype.setBackground = function(background) { this._background = background;};KLRGAME_Message.prototype.setPositionType = function(positionType) { this._positionType = positionType;5. Making an event with Script-Command:

$klrgMessage.setFaceImage('Actor1',0)$klrgMessage.setBackground(1)$klrgMessage.setPositionType(1)$klrgMessage.add("Show Text Script Call")6. Getting this damned Error ...

So why is this stuff not defined??? o,O
you forgotten to define your variable properly

var $var_name = null;it's initialize your variable 

I highly advise you to study JS before jumping in MV coding

because it's show you don't know the basic of JS 

all variable with the global scope need at least to be initialized via "var"
But I did exactly that or not? o,O

Code:
var $klrgMessage = null;DataManager.createGameObjects = function() {    $gameTemp          = new Game_Temp();    $gameSystem        = new Game_System();    $gameScreen        = new Game_Screen();    $gameTimer         = new Game_Timer();    $gameMessage       = new Game_Message();    $gameSwitches      = new Game_Switches();    $gameVariables     = new Game_Variables();    $gameSelfSwitches  = new Game_SelfSwitches();    $gameActors        = new Game_Actors();    $gameParty         = new Game_Party();    $gameTroop         = new Game_Troop();    $gameMap           = new Game_Map();    $gamePlayer        = new Game_Player();	$klrgMessage       = new KLRGAME_Message();	};
Can anybody help me with this? Somebody who knows the basic of reading and can explain why the variable doesn't seem to be initialised although I clearly initialised it?
Can you give a print screen of the console errors?
[IMG]http://fs5.directupload.net/images/151102/mmwkqf37.jpg[/IMG]

I hope that helps ... I just don't get why he isn't accepting this variable. I only know C# so there might be something I am missing, but Yanfly overwrites the scripts the same way and doesn't caught any errors ...
FOUND IT!!!I missed an ); at the bottom of the script ... Can't believe it ... Thanks for the console-tipp.

But now I have a new problem ... Instead of an error message I know get nothing ...

It is as if he doesn't accept my new message-window ...

This does nothing:

$klrgMessage.setFaceImage('Actor1',0)$klrgMessage.setBackground(1)$klrgMessage.setPositionType(1)$klrgMessage.add("Show Text Script Call")while this

$gameMessage.setFaceImage('Actor1',0)$gameMessage.setBackground(1)$gameMessage.setPositionType(1)$gameMessage.add("Show Text Script Call")works fine ...

Original thread: https://forums.rpgmakerweb.com/threads/trying-to-recreate-the-message-window.48978/