扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 180|回复: 0

[转载发布] 如何在存档界面显示变量

[复制链接]
累计送礼:
0 个
累计收礼:
0 个
  • TA的每日心情
    开心
    昨天 17:34
  • 签到天数: 112 天

    连续签到: 2 天

    [LV.6]常住居民II

    2332

    主题

    398

    回帖

    1万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    6
    卡币
    10541
    OK点
    16
    推广点
    0
    同能卷
    0
    积分
    13299

    灌水之王

    发表于 2024-2-15 01:24:04 | 显示全部楼层 |阅读模式
    我使用了一个AltSaveScreen.js插件,这个插件的代码如下:
    JS 代码
    1. //=============================================================================
    2. // RPG Maker MZ - Alternative Save Screen
    3. //=============================================================================
    4. /*:
    5. * @target MZ
    6. * @plugindesc Alternative save/load screen layout.
    7. * @author Yoji Ojima
    8. *
    9. * @help AltSaveScreen.js
    10. *
    11. * This plugin changes the layout of the save/load screen.
    12. * It puts the file list on the top and the details on the bottom.
    13. *
    14. * It does not provide plugin commands.
    15. */
    16. /*:ja
    17. * @target MZ
    18. * @plugindesc セーブ/ロード画面のレイアウトを変更します。
    19. * @author Yoji Ojima
    20. *
    21. * @help AltSaveScreen.js
    22. *
    23. * このプラグインは、セーブ/ロード画面のレイアウトを変更します。
    24. * ファイル一覧を上側に、詳細を下側に配置します。
    25. *
    26. * プラグインコマンドはありません。
    27. */
    28. (() => {
    29.     const _Scene_File_create = Scene_File.prototype.create;
    30.     Scene_File.prototype.create = function() {
    31.         _Scene_File_create.apply(this, arguments);
    32.         this._listWindow.height = this._listWindow.fittingHeight(3);
    33.         const x = 0;
    34.         const y = this._listWindow.y + this._listWindow.height;
    35.         const width = Graphics.boxWidth;
    36.         const height = Graphics.boxHeight - y;
    37.         const rect = new Rectangle(x, y, width, height);
    38.         const statusWindow = new Window_SavefileStatus(rect);
    39.         this._listWindow.mzkp_statusWindow = statusWindow;
    40.         this.addWindow(statusWindow);
    41.     };
    42.     const _Scene_File_start = Scene_File.prototype.start;
    43.     Scene_File.prototype.start = function() {
    44.         _Scene_File_start.apply(this, arguments);
    45.         this._listWindow.ensureCursorVisible();
    46.         this._listWindow.callUpdateHelp();
    47.     };
    48.     Window_SavefileList.prototype.windowWidth = function() {
    49.         return Graphics.boxWidth;
    50.     };
    51.     Window_SavefileList.prototype.maxCols = function() {
    52.         return 4;
    53.     };
    54.     Window_SavefileList.prototype.itemHeight = function() {
    55.         return this.lineHeight() * 2 + 16;
    56.     };
    57.     const _Window_SavefileList_callUpdateHelp =
    58.         Window_SavefileList.prototype.callUpdateHelp;
    59.     Window_SavefileList.prototype.callUpdateHelp = function() {
    60.         _Window_SavefileList_callUpdateHelp.apply(this, arguments);
    61.         if (this.active && this.mzkp_statusWindow) {
    62.             this.mzkp_statusWindow.setSavefileId(this.savefileId());
    63.         }
    64.     };
    65.     function Window_SavefileStatus() {
    66.         this.initialize.apply(this, arguments);
    67.     }
    68.     Window_SavefileStatus.prototype = Object.create(Window_Base.prototype);
    69.     Window_SavefileStatus.prototype.constructor = Window_SavefileStatus;
    70.     Window_SavefileStatus.prototype.initialize = function(rect) {
    71.         Window_Base.prototype.initialize.call(this, rect);
    72.         this._savefileId = 1;
    73.     };
    74.     Window_SavefileStatus.prototype.setSavefileId = function(id) {
    75.         this._savefileId = id;
    76.         this.refresh();
    77.     };
    78.     Window_SavefileStatus.prototype.refresh = function() {
    79.         const info = DataManager.savefileInfo(this._savefileId);
    80.         const rect = this.contents.rect;
    81.         this.contents.clear();
    82.         this.resetTextColor();
    83.         this.drawTitle(this._savefileId, rect.x, rect.y);
    84.         if (info) {
    85.             this.drawContents(info, rect);
    86.         }
    87.     };
    88.     Window_SavefileStatus.prototype.drawTitle = function(savefileId, x, y) {
    89.         if (savefileId === 0) {
    90.             this.drawText(TextManager.autosave, x, y, 180);
    91.         } else {
    92.             this.drawText(TextManager.file + " " + savefileId, x, y, 180);
    93.         }
    94.     };
    95.     Window_SavefileStatus.prototype.drawContents = function(info, rect) {
    96.         const bottom = rect.y + rect.height;
    97.         const playtimeY = bottom - this.lineHeight();
    98.         this.drawText(info.title, rect.x + 192, rect.y, rect.width - 192);
    99.         this.drawText("处于第" + $gameVariables.value(1) +"层", rect.x + 330, rect.y, rect.width - 192);
    100.         this.drawPartyfaces(info.faces, rect.x, bottom - 144);
    101.         this.drawText(info.playtime, rect.x, playtimeY, rect.width, "right");
    102.     };
    103.     Window_SavefileStatus.prototype.drawPartyfaces = function(faces, x, y) {
    104.         if (faces) {
    105.             for (let i = 0; i < faces.length; i++) {
    106.                 const data = faces[i];
    107.                 this.drawFace(data[0], data[1], x + i * 150, y);
    108.             }
    109.         }
    110.     };
    111. })();
    复制代码




    我想在存档中显示一个表示层数的变量。
    JS 代码
    1. this.drawText("处于第" + $gameVariables.value(1) +"层", rect.x + 330, rect.y, rect.width - 192)
    复制代码

    但这么做很明显,无法显示每一个存档中存储到的1号变量。当前如图所示,显示的全是初始状态下的数字0。
    请问应该如何修改?

                 本帖来自P1论坛作者古树旋律,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=491250  若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2025-3-13 08:45 , Processed in 0.115715 second(s), 54 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表