赞 | 8 |
VIP | 4 |
好人卡 | 4 |
积分 | 33 |
经验 | 76902 |
最后登录 | 2025-4-16 |
在线时间 | 135 小时 |
Lv3.寻梦者
- 梦石
- 0
- 星屑
- 3297
- 在线时间
- 135 小时
- 注册时间
- 2010-7-17
- 帖子
- 149
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
/*:
* @target MZ
* @plugindesc 使用指定物品时,在新窗口显示 50 个变量的数据及名称
* @author 开发者
*
* @param itemId
* @text 物品 ID
* @desc 使用此物品会触发显示变量窗口
* @type item
* @default 1
*
* @param startVariableId
* @text 起始变量 ID
* @desc 从该 ID 开始显示 50 个连续变量的数据和名称
* @type variable
* @default 1
*
* @param windowX
* @text 窗口 X 坐标
* @desc 窗口在屏幕上的 X 坐标
* @type number
* @default 10
*
* @param windowY
* @text 窗口 Y 坐标
* @desc 窗口在屏幕上的 Y 坐标
* @type number
* @default 10
*
* @param windowWidth
* @text 窗口宽度
* @desc 窗口的宽度
* @type number
* @default 400
*
* @param windowHeight
* @text 窗口高度
* @desc 窗口的高度
* @type number
* @default 600
*
* @param fontSize
* @text 字体大小
* @desc 窗口内文本的字体大小
* @type number
* @min 12
* @Max 72
* @default 14
*
* @help
* 本插件允许你在使用指定物品时,在新窗口中显示 50 个变量的数据和名称。
* 请设置正确的物品 ID 和起始变量 ID。
*/
(() => {
const pluginParams = PluginManager.parameters('ShowVariablesWithNames');
const itemId = Number(pluginParams.itemId);
const startVariableId = Number(pluginParams.startVariableId);
const windowX = Number(pluginParams.windowX);
const windowY = Number(pluginParams.windowY);
const windowWidth = Number(pluginParams.windowWidth);
const windowHeight = Number(pluginParams.windowHeight);
const fontSize = Number(pluginParams.fontSize);
class VariableDisplayWindow extends Window_Base {
constructor() {
try {
console.log('开始创建 VariableDisplayWindow 窗口');
super(new Rectangle(windowX, windowY, windowWidth, windowHeight));
this.opacity = 255;
this.visible = true;
this.refresh();
console.log('VariableDisplayWindow 窗口创建完成');
} catch (error) {
console.error('创建 VariableDisplayWindow 窗口时出错:', error);
}
}
refresh() {
try {
console.log('开始刷新 VariableDisplayWindow 窗口内容');
this.contents.clear();
this.contents.fontSize = fontSize;
let y = 0;
for (let i = 0; i < 50; i++) {
const variableId = startVariableId + i;
const variableName = $dataSystem.variables[variableId];
const variableValue = $gameVariables.value(variableId);
const text = `${variableName}: ${variableValue}`;
this.drawText(text, 0, y, this.contents.width);
y += this.lineHeight();
}
console.log('VariableDisplayWindow 窗口内容刷新完成');
} catch (error) {
console.error('刷新 VariableDisplayWindow 窗口内容时出错:', error);
}
}
}
const _Game_Interpreter_command301 = Game_Interpreter.prototype.command301;
Game_Interpreter.prototype.command301 = function () {
console.log('使用物品,物品 ID:', this._params[0]);
if (this._params[0] === itemId) {
console.log('使用的物品 ID 匹配,开始创建窗口');
const scene = SceneManager._scene;
if (scene instanceof Scene_Map) {
try {
scene._variableDisplayWindow = new VariableDisplayWindow();
if (scene._variableDisplayWindow) {
console.log('窗口对象创建成功');
scene.addWindow(scene._variableDisplayWindow);
console.log('窗口已添加到场景中');
} else {
console.error('窗口对象创建失败');
}
} catch (error) {
console.error('创建变量显示窗口时出错:', error);
}
}
}
return _Game_Interpreter_command301.call(this);
};
})();
这插件有什么问题,使用指定物品后,并没有打开窗口 |
|