Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*:
- * Toggle Page by Shaz
- * Ver 1.00 2018.01.14
- * Shaz_TogglePage.js
- *
- *
- * @plugindesc Disables/enables event pages on the current map.
- * @author Shaz
- *
- * @help This plugin allows you to temporarily disable a page on an event on
- * the current map, and to re-enable it again. You can affect the current
- * page on the current event, a specific page on the current event, or a
- * specific page on another event on the current map.
- *
- * Like the Erase Event command, this lasts only until you leave the map.
- * When you return, all pages will be enabled.
- *
- * Plugin Commands:
- * TogglePage - toggles the current page of the current event
- * TogglePage pageId - toggles the specified page of the current event
- * TogglePage eventId pageId - toggles the specified page of the specified event
- *
- * Example:
- * TogglePage enables/disables the current page
- * TogglePage 5 enables/disables page 5 on the current event
- * TogglePage 10 3 enables/disables page 3 of event 10 on the current map
- * TogglePage $gameVariables(1) $gameVariables(2) enables/disables the page
- * number contained in variable 2, of the event whose id is in
- * variable 1
- *
- *
- * NOTE:
- * pageId refers to the event tab as seen in the editor. The first event page
- * is pageId 1.
- *
- * eventId and pageId can be formulae, but there must be no spaces.
- *
- * This plugin OVERWRITES the Game_Event.findProperPageIndex function. There
- * may be compatibility issues with other plugins that also overwrite the same
- * function.
- *
- */
- var Imported = Imported || {};
- Imported.Shaz_TogglePage = true;
- var Shaz = Shaz || {};
- Shaz.TP = Shaz.TP || {};
- Shaz.TP.Version = 1.00;
- (function() {
- var _Shaz_TP_Game_Event_initialize = Game_Event.prototype.initialize;
- Game_Event.prototype.initialize = function(mapId, eventId) {
- this._activePages = Array($dataMap.events[eventId].pages.length);
- for (var i = 0; i < this._activePages.length; i++) {
- this._activePages[i] = true;
- }
- _Shaz_TP_Game_Event_initialize.call(this, mapId, eventId);
- };
- Game_Event.prototype.findProperPageIndex = function() {
- var pages = this.event().pages;
- for (var i = pages.length - 1; i >= 0; i--) {
- var page = pages[i];
- if (this._activePages[i] && this.meetsConditions(page)) {
- return i;
- }
- }
- return -1;
- };
- Game_Event.prototype.togglePage = function(id) {
- id = id ? id - 1 : this._pageIndex;
- if (id >= 0 && id < this._activePages.length) {
- this._activePages[id] = !(this._activePages[id]);
- this.refresh();
- }
- }
- var _Shaz_TP_Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
- Game_Interpreter.prototype.pluginCommand = function(command, args) {
- switch(command.toUpperCase()) {
- case 'TOGGLEPAGE':
- for (var i = 0; i < args.length; i++) {
- args[i] = eval(args[i]);
- }
- switch(args.length) {
- case 0:
- $gameMap.event(this._eventId).togglePage();
- break;
- case 1:
- $gameMap.event(this._eventId).togglePage(args[0]);
- break;
- case 2:
- $gameMap.event(args[0]).togglePage(args[1]);
- break;
- }
- break;
- default:
- _Shaz_TP_Game_Interpreter_pluginCommand.call(this, command, args);
- }
- };
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement