Custom Menu option

Okay, so I'm trying to add an option to the menu between "Formation" and "Option"


whenever I do this, it says "Window_Title undefined"


I want to be able to click the option and it open a New window displaying completed events in the game, for example, the boss's Icon and a description box below when you click on the Icon that says, "You defeated Boss!"


I know it's possible, But I'm overlooking something stupid, I know it.
I've moved this thread to Learning Javascript. Please be sure to post your threads in the correct forum next time. Thank you.



Please show us what you have done so far, we can't help you without information.
Window_MenuCommand.prototype.addOriginalCommands = function() {
if (this.needsCommand 'Achievement')) {
var enabled = this.isAchievementEnabled();
this.addCommand(TextManager.Achievement, 'Achievement' enabled);
};


So I have this,


and I get "Window_TitleCommand is not Defined" when I go to open the game
you have an extra ) in there at: 'Achievement'))


That is all I notice at the moment
It should be like this:


Window_MenuCommand.prototype.addOriginalCommands = function() {
if (this.needsCommand('Achievement')) {
this.addCommand(TextManager.Achievement, 'Achievement', true);
}
}


You missed a lot of () on your code.
Thanks! I'm trying that now!
Okay, So I put that in, and now nothing is comming up...

is there something I need to do to with the plugin to make it appear?
Correction. I put it in, now i'm getting a blank space between Option and Formation~


I just need to figure out how to make a window pop up when I click, and how to name it, and I'll be good~
Scene_Boot.prototype.start = function() {
Scene_Base.prototype.start.call(this);
SoundManager.preloadImportantSounds();
if (DataManager.isBattleTest()) {
DataManager.setupBattleTest();
SceneManager.goto(Scene_Battle);
} else if (DataManager.isEventTest()) {
DataManager.setupEventTest();
SceneManager.goto(Scene_Map);
} else {
this.checkPlayerLocation();
DataManager.setupNewGame();
SceneManager.goto(Scene_Title);
Window_TitleCommand.initCommandPosition();
}
this.updateDocumentTitle();
};

Window_MenuCommand.prototype.addOriginalCommands = function() {
if (this.needsCommand('Achievement')) {
this.addCommand(TextManager.Achievement, 'Achievement', true);
}
};


What I have so far~
For some reason, the name "Achievements" Doesn't appear, only a blank space does,
/*:
* @plugindesc This is the Achievements Plug-in!
*
*
* @author TagumonYatsuray
*
* @Param Achievements
* @Desc This is the Achievements Parameter
* @Default 0
* @help This is the help file!
* Heeeelp
*/

Scene_Boot.prototype.start = function() {
Scene_Base.prototype.start.call(this);
SoundManager.preloadImportantSounds();
if (DataManager.isBattleTest()) {
DataManager.setupBattleTest();
SceneManager.goto(Scene_Battle);
} else if (DataManager.isEventTest()) {
DataManager.setupEventTest();
SceneManager.goto(Scene_Map);
} else {
this.checkPlayerLocation();
DataManager.setupNewGame();
SceneManager.goto(Scene_Title);
Window_TitleCommand.initCommandPosition();
}
this.updateDocumentTitle();
};

Window_MenuCommand.prototype.addOriginalCommands = function() {
this.addCommand("Achievements", 'Achievements', true);
};

var xScene_Achievements_createCommandWindow = Scene_Achievements.prototype.createCommandWindow;
Scene_Achievements.prototype.createCommandWindow = function() {
xScene_Achievements_createCommandWindow.call(this);
this._commandWindow.setHandler('Achievements', this.commandAchievements.bind(this));
this.addWindow(this._commandWindow);
};

Scene_Achievements.prototype.commandAchievements = function() {
SceneManager.push(Scene_Achievements);
};

//-----------------------------------------------------------------------------
Window_Sample.prototype.windowHeight = function() {
return this.fittingHeight(1);
};

Window_Sample.prototype.refresh = function() {
var x = this.textPadding();
var width = this.contents.width - this.textPadding() * 2;
this.contents.clear();
this.drawIcon(2,0,0);
};

Window_Sample.prototype.open = function() {
this.refresh();
Window_Base.prototype.open.call(this);
};

function Scene_Achievements() {
this.initialize.apply(this, arguments);
}

Scene_Achievements.prototype = Object.create(Scene_AchievementsBase.prototype);
Scene_Achievements.prototype.constructor = Scene_Achievements;

Scene_Achievements.prototype.initialize = function() {
Sample_SceneBase.prototype.initialize.call(this);
};

Scene_Achievements.prototype.create = function() {
Sample_SceneBase.prototype.create.call(this);
// Create the Window here
this.sampleWindow = new Window_Sample(0,0)
this.sampleWindow.x = Graphics.width / 2 - 100;
this.sampleWindow.y = Graphics.height / 2 - 100;
// Add the Window here
this.addWindow(this._sampleWindow);
};

Scene_Achievements.prototype.start = function() {
Sample_SceneBase.prototype.start.call(this);
};


This is what I have so far, But for some reason, when i go to click, nothing shows up....
var xScene_Achievements_createCommandWindow = Scene_Achievements.prototype.createCommandWindow; Scene_Achievements.prototype.createCommandWindow = function() { xScene_Achievements_createCommandWindow.call(this); this._commandWindow.setHandler('Achievements', this.commandAchievements.bind(this)); this.addWindow(this._commandWindow); }; Scene_Achievements.prototype.commandAchievements = function() { SceneManager.push(Scene_Achievements); };



I'm pretty sure this entire section won't work because it's listed before the Scene_Achievements object is even defined. You might find that this:


this._commandWindow.setHandler('Achievements', this.commandAchievements.bind(this));


Doesn't ever execute. If I recall correctly, setHandler uses the input values, not the names of the commands. I'll check in later when I finish work.


If you open the js console (F8 when the game window is open) you'll see if there are any errors btw.
/*:
* @plugindesc This is the Achievements Plug-in!
*
*
* @author TagumonYatsuray
*
* @Param Achievements
* @Desc This is the Achievements Parameter
* @Default 0
* @help This is the help file!
* Squeeee!
*/


Scene_Boot.prototype.start = function() {
Scene_Base.prototype.start.call(this);
SoundManager.preloadImportantSounds();
if (DataManager.isBattleTest()) {
DataManager.setupBattleTest();
SceneManager.goto(Scene_Battle);
} else if (DataManager.isEventTest()) {
DataManager.setupEventTest();
SceneManager.goto(Scene_Map);
} else {
this.checkPlayerLocation();
DataManager.setupNewGame();
SceneManager.goto(Scene_Title);
Window_TitleCommand.initCommandPosition();
}
this.updateDocumentTitle();
};

Window_MenuCommand.prototype.addOriginalCommands = function() {
this.addCommand("Achievements", 'Achievements', true);
};

Scene_Achievements.prototype = Object.create(Scene_Achievements.prototype);

var xScene_Achievements_createCommandWindow = Scene_Achievements.prototype.createCommandWindow;
Scene_Achievements.prototype.createCommandWindow = function() {
xScene_Achievements_createCommandWindow.call(this);
this._commandWindow.setHandler('Achievements', this.commandAchievements.bind(this));
this.addWindow(this._commandWindow);
};

Scene_Achievements.prototype.commandAchievements = function() {
SceneManager.push(Scene_Achievements);
};

//-----------------------------------------------------------------------------
function Window_Sample() {
this.initialize.apply(this, arguments);
}

Window_Sample.prototype = Object.create(Window_Base.prototype);
Window_Sample.prototype.constructor = Window_Sample;

Window_Sample.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_Sample.prototype.windowWidth = function() {
return 810;
};

Window_Sample.prototype.windowHeight = function() {
return 600;
};

Window_Sample.prototype.refresh = function() {
var x = this.textPadding();
var width = this.contents.width - this.textPadding() * 2;
this.contents.clear();
};

Window_Sample.prototype.open = function() {
this.refresh();
Window_Base.prototype.open.call(this);
};

function Scene_Achievements() {
this.initialize.apply(this, arguments);
}

Scene_Achievements.prototype = Object.create(Scene_MenuBase.prototype);
Scene_Achievements.prototype.constructor = Scene_Achievements;

Scene_Achievements.prototype.initialize = function() {
Scene_MenuBase.prototype.initialize.call(this);
};

Scene_Achievements.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);
this.createSampleWindow();
};

Scene_Achievements.prototype.createSampleWindow = function() {
this._windowSample = new Window_Sample(0, 0);
this._windowSample.x = Graphics.width / 8 - 100;
this._windowSample.y = Graphics.height / 6 - 100;
this.addWindow(this._windowSample);
};

Scene_Achievements.prototype.update = function() {
Scene_MenuBase.prototype.update.call(this);
if (Input.isTriggered('cancel')) {
SceneManager.goto(Scene_Map);
}
};

Scene_Achievements.prototype.start = function() {
Scene_MenuBase.prototype.start.call(this);
this._windowSample.refresh();
};


This is my Current Code. But when I click the Achievements Button, it doesn't open the window...
var xScene_Achievements_createCommandWindow = Scene_Achievements.prototype.createCommandWindow; Scene_Achievements.prototype.createCommandWindow = function() { xScene_Achievements_createCommandWindow.call(this); this._commandWindow.setHandler('Achievements', this.commandAchievements.bind(this)); this.addWindow(this._commandWindow); }; Scene_Achievements.prototype.commandAchievements = function() { SceneManager.push(Scene_Achievements); };



Looks like this bit was you attempting to override the Scene_Menu function but instead you were overriding the Scene_Achievements function. This is what I have so far:


/*:
* @plugindesc This is the Achievements Plug-in!
*
*
* @author TagumonYatsuray
*
* @Param Achievements
* @Desc This is the Achievements Parameter
* @Default 0
* @help This is the help file!
* Squeeee!
*/


Scene_Boot.prototype.start = function() {
Scene_Base.prototype.start.call(this);
SoundManager.preloadImportantSounds();
if (DataManager.isBattleTest()) {
DataManager.setupBattleTest();
SceneManager.goto(Scene_Battle);
} else if (DataManager.isEventTest()) {
DataManager.setupEventTest();
SceneManager.goto(Scene_Map);
} else {
this.checkPlayerLocation();
DataManager.setupNewGame();
SceneManager.goto(Scene_Title);
Window_TitleCommand.initCommandPosition();
}
this.updateDocumentTitle();
};

Window_MenuCommand.prototype.addOriginalCommands = function() {
this.addCommand('Achievements', 'Achievements', true);
}

var xScene_Menu_createCommandWindow = Scene_Menu.prototype.createCommandWindow;
Scene_Menu.prototype.createCommandWindow = function() {
xScene_Menu_createCommandWindow.call(this);
this._commandWindow.setHandler('Achievements', this.commandAchievements.bind(this));
};

Scene_Menu.prototype.commandAchievements = function() {
SceneManager.push(Scene_Achievements);
};

//-----------------------------------------------------------------------------
function Window_Sample() {
this.initialize.apply(this, arguments);
}

Window_Sample.prototype = Object.create(Window_Base.prototype);
Window_Sample.prototype.constructor = Window_Sample;

Window_Sample.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_Sample.prototype.windowWidth = function() {
return 350;
};

Window_Sample.prototype.windowHeight = function() {
return 350;
};

Window_Sample.prototype.refresh = function() {
var x = this.textPadding();
var width = this.contents.width - this.textPadding() * 2;
this.contents.clear();
};

Window_Sample.prototype.open = function() {
this.refresh();
Window_Base.prototype.open.call(this);
};

function Scene_Achievements() {
this.initialize.apply(this, arguments);
}

Scene_Achievements.prototype = Object.create(Scene_MenuBase.prototype);
Scene_Achievements.prototype.constructor = Scene_Achievements;

Scene_Achievements.prototype.initialize = function() {
Scene_MenuBase.prototype.initialize.call(this);
};

Scene_Achievements.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);
this.createSampleWindow();
};

Scene_Achievements.prototype.createCommandWindow = function() {
Scene_MenuBase.prototype.createCommandWindow.call(this);
this._commandWindow.setHandler('Achievements', this.commandAchievements.bind(this));
};

Scene_Achievements.prototype.createSampleWindow = function() {
this._windowSample = new Window_Sample(0, 0);
this._windowSample.x = Graphics.width;
this._windowSample.y = Graphics.height;
this.addWindow(this._windowSample);
}

Scene_Achievements.prototype.update = function() {
Scene_MenuBase.prototype.update.call(this);
if (Input.isTriggered('cancel')) {
SceneManager.goto(SceneManager._previousClass);
}
}

Scene_Achievements.prototype.start = function() {
Scene_MenuBase.prototype.start.call(this);
this._windowSample.refresh();
};


It changes scene and clears the menu, but no window graphics appear, but at least you get the command working now. I'll let you have a bit more of a play with it, but don't hesitate to holla if you need more help.
thanks so much! Now I just gotta figure out how to add stuff to the box~

 
Hmm... I changed 


Window_Sample.prototype.refresh = function() {
var x = this.textPadding();
var width = this.contents.width - this.textPadding() * 2;
this.contents.clear();






to this


Window_Sample.prototype.refresh = function() {
var x = this.textPadding();
var width = this.contents.width - this.textPadding() * 2;
this.contents.clear();
this.drawTextEx("Achievements!")




But still no message... I wonder why...?
Ok, actually had a look through what the code is trying to do, when I noticed this:


Scene_Achievements.prototype.createSampleWindow = function() {
this._windowSample = new Window_Sample(0, 0);
this._windowSample.x = Graphics.width;
this._windowSample.y = Graphics.height;
this.addWindow(this._windowSample);
}


You're setting the position of the window to be the bottom left of the screen, so it's being "drawn" from the bottom left of the screen to beyond the screen bounds. Removing those lines fixes:


Scene_Achievements.prototype.createSampleWindow = function() {
this._windowSample = new Window_Sample(0, 0);
this.addWindow(this._windowSample);
};


You've also got some redundant code hanging around. Scene_MenuBase doesn't have a function called createCommandWindow, so Scene_Achievements.prototype.createCommandWindow won't actually get called. There are a few others in there too.
Hm... I tried that, and now the option doesn't pop up in the menu

EDIT: No wait, it does, but it doesn't open a window when I click on it,
Also the code is supposed to be wrapped in:


(function() {
})();


So like this:


/*:
* @plugindesc This is the Achievements Plug-in!
*
*
* @author TagumonYatsuray
*
* @Param Achievements
* @Desc This is the Achievements Parameter
* @Default 0
* @help This is the help file!
*
*/

(function() {

Scene_Boot.prototype.start = function() {
Scene_Base.prototype.start.call(this);
SoundManager.preloadImportantSounds();
if (DataManager.isBattleTest()) {
DataManager.setupBattleTest();
SceneManager.goto(Scene_Battle);
} else if (DataManager.isEventTest()) {
DataManager.setupEventTest();
SceneManager.goto(Scene_Map);
} else {
this.checkPlayerLocation();
DataManager.setupNewGame();
SceneManager.goto(Scene_Title);
Window_TitleCommand.initCommandPosition();
}
this.updateDocumentTitle();
};

Window_MenuCommand.prototype.addOriginalCommands = function() {
this.addCommand('Achievements', 'Achievements', true);
}

var xScene_Menu_createCommandWindow = Scene_Menu.prototype.createCommandWindow;
Scene_Menu.prototype.createCommandWindow = function() {
xScene_Menu_createCommandWindow.call(this);
this._commandWindow.setHandler('Achievements', this.commandAchievements.bind(this));
};

Scene_Menu.prototype.commandAchievements = function() {
SceneManager.push(Scene_Achievements);
};

//-----------------------------------------------------------------------------
function Window_Sample() {
this.initialize.apply(this, arguments);
}

Window_Sample.prototype = Object.create(Window_Base.prototype);
Window_Sample.prototype.constructor = Window_Sample;

Window_Sample.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_Sample.prototype.windowWidth = function() {
return 350;
};

Window_Sample.prototype.windowHeight = function() {
return 350;
};

Window_Sample.prototype.refresh = function() {
var x = this.textPadding();
var width = this.contents.width - this.textPadding() * 2;
this.contents.clear();
};

Window_Sample.prototype.open = function() {
this.refresh();
Window_Base.prototype.open.call(this);
};

function Scene_Achievements() {
this.initialize.apply(this, arguments);
}

Scene_Achievements.prototype = Object.create(Scene_MenuBase.prototype);
Scene_Achievements.prototype.constructor = Scene_Achievements;

Scene_Achievements.prototype.initialize = function() {
Scene_MenuBase.prototype.initialize.call(this);
};

Scene_Achievements.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);
this.createSampleWindow();
};

Scene_Achievements.prototype.createCommandWindow = function() {
Scene_MenuBase.prototype.createCommandWindow.call(this);
this._commandWindow.setHandler('Achievements', this.commandAchievements.bind(this));
};

Scene_Achievements.prototype.createSampleWindow = function() {
this._windowSample = new Window_Sample(0, 0);
this._windowSample.x = Graphics.width;
this._windowSample.y = Graphics.height;
this.addWindow(this._windowSample);
}

Scene_Achievements.prototype.update = function() {
Scene_MenuBase.prototype.update.call(this);
if (Input.isTriggered('cancel')) {
SceneManager.goto(SceneManager._previousClass);
}
}

Scene_Achievements.prototype.start = function() {
Scene_MenuBase.prototype.start.call(this);
this._windowSample.refresh();
};

})(); // dont touch this.






Now this here next part is my achievement code, which I know works. I modified it to work with yours. I had it do some other stuff so I quickly stripped it. Let me know if anything's wrong.

Code:
/*:
 * @plugindesc This is the Achievements Plug-in!
 *
 *
 * @author TagumonYatsuray
 *
 * @Param Achievements
 * @Desc This is the Achievements Parameter
 * @Default 0
 * @help This is the help file!
 * 
 */
 
 (function() { // Do not touch RMMV uses this to wrap the code
	var parameters = PluginManager.parameters('Achievements Plugin');
	
	var _Scene_Menu_createCustomMenuWindow = Scene_Menu.prototype.createCommandWindow;
  
	Window_MenuCommand.prototype.addOriginalCommands = function() {
		this.addCommand("Achievements", 'achievements', true);
	};
	
	Scene_Menu.prototype.createCommandWindow = function() {
		_Scene_Menu_createCustomMenuWindow.call(this);
		this._commandWindow.setHandler('achievements',      this.commandAchievements.bind(this));
		this.addWindow(this._commandWindow);
	};
	
	Scene_Menu.prototype.commandAchievements = function() {
		SceneManager.push(Scene_Achievements);
	};
	
	
	//-----------------------------------------------------------------------------
	// Window_Achievements
	//
	// The window for displaying achievements.

	function Window_Achievements() {
		this.initialize.apply(this, arguments);
	}

	Window_Achievements.prototype = Object.create(Window_Base.prototype);
	Window_Achievements.prototype.constructor = Window_Achievements;

	Window_Achievements.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_Achievements.prototype.windowWidth = function() {
		return 350;
	};

	Window_Achievements.prototype.windowHeight = function() {
		return 350;
	};

	Window_Achievements.prototype.refresh = function() {
		var x = this.textPadding();
		var width = this.contents.width - this.textPadding() * 2;
		this.contents.clear();
		this.drawIcon(2,0,0);
	};

	Window_Achievements.prototype.open = function() {
		this.refresh();
		Window_Base.prototype.open.call(this);
	};
	
	Scene_Achievements.prototype.create = function() {
		Scene_MenuBase.prototype.create.call(this);
		this.createCommandWindow();
		this.createAchievementsWindow();
		this.createStatusWindow();
	};
	
	Scene_Achievements.prototype.createAchievementsWindow = function() {
		this._achievementsWindow = new Window_Achievements(0, 0);
		this._achievementsWindow.y = Graphics.boxHeight - this._achievementsWindow.height;
		this.addWindow(this._achievementsWindow);
	};
	
	//-----------------------------------------------------------------------------
	// Scene_Achievements
	//
	// The scene class of the menu screen.

	function Scene_Achievements() {
		this.initialize.apply(this, arguments);
	}

	Scene_Achievements.prototype = Object.create(Scene_MenuBase.prototype);
	Scene_Achievements.prototype.constructor = Scene_Achievements;

	Scene_Achievements.prototype.initialize = function() {
		Scene_MenuBase.prototype.initialize.call(this);
	};

	Scene_Achievements.prototype.create = function() {
		Scene_MenuBase.prototype.create.call(this);
		this._achievementsWindow = new Window_Achievements(0,0);
		this._achievementsWindow.x = 0;
		this._achievementsWindow.y = 0;
		this.addWindow(this._achievementsWindow);
	};

	Scene_Achievements.prototype.start = function() {
		Scene_MenuBase.prototype.start.call(this);
	};
	
	Scene_Achievements.prototype.update = function() {
		Scene_MenuBase.prototype.update.call(this);
		
		if(Input.isTriggered('cancel')) {
			SoundManager.playCancel();
			SceneManager.goto(Scene_Menu);
		}
	}
  
  
  
  
  
  })();  // dont touch this.
Hm... I tried that, and now the option doesn't pop up in the menu

EDIT: No wait, it does, but it doesn't open a window when I click on it,



I assume this is in response to removing:  Scene_Achievements.prototype.createCommandWindow ? In your code you have two methods called "createCommandWindow" - one in Scene_Menu which you override open the achievements scene, and the other one on Scene_Achievements - so you may have deleted the wrong one.

Also the code is supposed to be wrapped in:



(function() {
})();



This is not required, it just makes it so the plugin classes can't be interacted with/overridden by the base code or other plugins with out explicit hooks put in place.


Also, some more redundant code:


Scene_Achievements.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);
this._achievementsWindow = new Window_Achievements(0,0);
this._achievementsWindow.x = 0;
this._achievementsWindow.y = 0;
this.addWindow(this._achievementsWindow);
};


The (0, 0) passed in to the window are the x and y positions for the window, setting them to 0 afterwards is pointless.


Window_Achievements.prototype.refresh = function() {
var x = this.textPadding();
var width = this.contents.width - this.textPadding() * 2;
this.contents.clear();
this.drawIcon(2,0,0);
};


The variables 'x' and 'width' aren't used in this function, so you can get rid of those.

Original thread: https://forums.rpgmakerweb.com/threads/custom-menu-option.56215/