| 赞 | 76 |
| VIP | |
| 好人卡 | |
| 积分 | 99 |
| 经验 | |
| 最后登录 | 2026-11-4 |
| 在线时间 | 582 小时 |
- 梦石
- 0
- 星屑
- 9917
- 在线时间
- 582 小时
- 注册时间
- 2017-9-28
- 回帖
- 207
|
发表于 2019-6-1 17:55:12
|
显示全部楼层
本帖最后由 hyrious 于 2019-6-1 17:56 编辑
练习了一下写 js 插件。。。比事件存位置的好处是能多次返回(
用法是在场所移动前执行插件指令 TransferingStack push(如果打开了插件选项“自动保存位置”则不要执行),然后返回的时候执行插件指令 TransferingStack pop 。
- //=============================================================================
- // TransferingStack.js
- //=============================================================================
- /*:
- * @plugindesc Storing location before transfering.
- * @author hyrious
- *
- * @param Auto Push Location
- * @desc Run 'TransferingStack push' automatically before any transfering.
- * @type boolean
- * @default true
- *
- * @param Fade Type
- * @desc The fade effect type of transfering.
- * 0 - black. 1 - white. any other number - none.
- * @type number
- * @default 0
- *
- * @help This plugin provides the following plugin commands.
- *
- * TransferingStack push # Save current location (push to stack)
- * TransferingStack pop # Remove and transfer to the last location
- * TransferingStack pop! # Remove the last location without transfering
- * TransferingStack clear # Remove all things in the stack
- * TransferingStack debug # Log the stack to console
- */
- /*:zh
- * @plugindesc “回到上一个位置”。
- * @author hyrious
- *
- * @param Auto Push Location
- * @text 自动保存位置
- * @desc 在场所移动前自动执行一次 TransferingStack push 。
- * @type boolean
- * @default true
- *
- * @param Fade Type
- * @text 渐变样式
- * @desc 场所移动时的渐变(变黑、变白等)。
- * 0 - 变黑. 1 - 变白. 任何其他数字 - 无渐变.
- * @type number
- * @default 0
- *
- * @help 这个插件提供了以下事件指令:
- *
- * TransferingStack push # 保存当前位置(入栈)
- * TransferingStack pop # 返回到上一个位置(出栈)
- * TransferingStack pop! # 出栈,但不执行场所移动
- * TransferingStack clear # 清空位置栈
- * TransferingStack debug # Log the stack to console
- */
- (function() {
- var parameters = PluginManager.parameters('TransferingStack');
- var autoPushLocation = Boolean(parameters['Auto Push Location'] || 'true');
- var fadeType = Number(parameters['Fade Type'] || '0');
- var transferingStack = [];
- function pushLocation() {
- var mapId = $gameMap.mapId(),
- x = $gamePlayer._realX,
- y = $gamePlayer._realY,
- d = $gamePlayer._direction;
- transferingStack.push([mapId, x, y, d, fadeType]);
- }
- var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
- var _Game_Player_reserveTransfer = Game_Player.prototype.reserveTransfer;
- Game_Interpreter.prototype.pluginCommand = function(command, args) {
- _Game_Interpreter_pluginCommand.call(this, command, args);
- if (command === 'TransferingStack') {
- switch (args[0]) {
- case 'push':
- pushLocation();
- break;
- case 'pop':
- if (transferingStack.length) {
- var last = transferingStack.length - 1;
- var payload = transferingStack[last];
- _Game_Player_reserveTransfer.apply($gamePlayer, payload);
- }
- case 'pop!':
- transferingStack.pop();
- break;
- case 'clear':
- transferingStack = [];
- break;
- case 'debug':
- console.log("transferingStack: [(mapId, x, y, d, fadeType)]");
- console.log(transferingStack);
- break;
- }
- }
- };
- Game_Player.prototype.reserveTransfer = function(mapId, x, y, d, fadeType) {
- if (!this._transferring && autoPushLocation) {
- pushLocation();
- }
- _Game_Player_reserveTransfer.call(this, mapId, x, y, d, fadeType);
- }
- var _DataManager_setupNewGame = DataManager.setupNewGame;
- DataManager.setupNewGame = function() {
- _DataManager_setupNewGame.call(DataManager);
- transferingStack = [];
- }
- })();
复制代码 |
|