Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*:
- * More Page Conditions by Shaz
- * Ver 1.00 2018.01.23
- * Shaz_MorePageConditions.js
- *
- *
- * @plugindesc Adds more flexible page conditions via comments.
- * @author Shaz
- *
- * @help This plugin has no plugin commands.
- *
- * Add comments to the top of an event page to include them when checking if
- * the current page should be activated. The comment block should begin with
- * the word cond
- *
- * The following shortened formats are available:
- * \ss([1, 2, 'A']) - converts to $gameSelfSwitches.value([1, 2, 'A'])
- * \s(15) - converts to $gameSwitches.value(15)
- * \v(8) - converts to $gameVariables.value(8)
- *
- * Any other valid command can be included, including combinations with
- * && and || and ().
- *
- * Examples:
- * cond \s(15) && \s(16] && \s(17) - page will be active if all 3 switches are
- * on, and any other page conditions are met
- * cond \v(8) >= 10 && \v(8) <= 15 - page will be active if the variable is
- * between 10 and 15, inclusive
- *
- * Note - although you can add any script call that will evaluate to true/false
- * as a condition, it may not cause an immediate change of pages. The map
- * only evaluates page conditions when something has requested a refresh. By
- * default, this list only includes things shown under the Conditions section
- * of the event page - a change to switches, self switches, variables, party
- * members, and items (which means items, armor or weapons). If you want to
- * add a condtion based on something else (for example, amount of gold, hp of
- * party leader, etc), you will need to manually add a script call at the time
- * those things can change: $gameMap.requestRefresh()
- * Be careful not to do this too often - definitely not in a parallel process
- * event, as refreshing the page events is a CPU-hungry activity and will
- * cause lag if done too frequently.
- *
- */
- var Imported = Imported || {};
- Imported.Shaz_MorePageConditions = true;
- var Shaz = Shaz || {};
- Shaz.MPC = Shaz.MPC || {};
- Shaz.MPC.Version = 1.00;
- (function() {
- var _Shaz_Game_Event_meetsConditions = Game_Event.prototype.meetsConditions;
- Game_Event.prototype.meetsConditions = function(page) {
- var test1 = _Shaz_Game_Event_meetsConditions.call(this, page);
- var test2 = this.meetsExtraConditions(page);
- return test1 && test2;
- };
- Game_Event.prototype.meetsExtraConditions = function(page) {
- var l = page.list.filter(function(cmd) {
- return cmd.code === 108 || cmd.code === 408;
- });
- var building = false;
- var cond = '';
- l.forEach(function(cmd) {
- if (cmd.parameters[0].match(/^cond (.*)$/i)) {
- cond += ' ' + RegExp.$1;
- building = true;
- } else if (cmd.code === 408 && building) {
- cond += ' ' + RegExp.$1;
- } else {
- building = false;
- }
- }, this);
- if (cond) {
- cond = cond.replace(/\\ss/gi, '$gameSelfSwitches.value');
- cond = cond.replace(/\\s/gi, '$gameSwitches.value');
- cond = cond.replace(/\\v/gi, '$gameVariables.value');
- return eval(cond);
- } else {
- return true;
- }
- };
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement