设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 101|回复: 0

[转载发布] GlobalValues XP

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    6120

    主题

    864

    回帖

    3万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    26247
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    33261

    灌水之王

    发表于 2026-7-18 15:36:19 | 显示全部楼层 |阅读模式
    GlobalValues XP

    by Kyonides


    Introduction

    Once upon a weird time, there was a forumer that wanted to rewrite many saved games for no good reason.
    What if there was a better solution?
    Yeah, like a Global Save File!


    My scriptlet will handle almost everything on its own except for one single thing, namely the Game Over screen.
    You got to make the script call by hand so to say.


    The Script

                    Code:       
    1. # * GlobalValues XP * #
    2. #  Scripter : Kyonides Arkanthes
    3. #  v0.3.0 - 2023-06-03
    4. # This script creates a new Global Variable and stores values there for future
    5. # use in all game sessions.
    6. # It will update the battle result variables automatically if you are using
    7. # a Battle System that is compatible enough with the Default BS.
    8. # Stats like Wins, Escapes, Losses, Saves, and Loads are already
    9. # updated by the script automatically!
    10. # * Script Calls * #
    11. # - Access Wins:
    12. #  $global_data.wins
    13. # - Access Escapes:
    14. #  $global_data.escapes
    15. # - Access Losses:
    16. #  $global_data.losses
    17. # - Access Total Saves:
    18. #  $global_data.saves
    19. # - Access Total Loads:
    20. #  $global_data.loads
    21. # - Access or Update Total Gameovers:
    22. #  $global_data.gameovers
    23. #  $global_data.gameover!
    24. # - Access or Update the Switch:
    25. #  $global_data.switch
    26. #  $global_data.switch = true
    27. #  $global_data.switch = false
    28. # * Optional - No Need for You to use them! * #
    29. # - Create or Load the new Global Variable
    30. #  Global.load_file
    31. # - Save Global Data at Any Moment
    32. #  Global.save_file
    33. module Global
    34.   # PATH = "" means the Game's Root Directory (RD)
    35.   # PATH = "Saves" means the Saves Directory at the RD
    36.   PATH = ""
    37.   FILENAME = "GlobalValues.rxdata"
    38.   class Values
    39.     def initialize
    40.       @wins = 0
    41.       @escapes = 0
    42.       @losses = 0
    43.       @saves = 0
    44.       @loads = 0
    45.       @gameovers = 0
    46.       @switch = nil
    47.     end
    48.     def save_result(result)
    49.       case result
    50.       when 0
    51.         @wins += 1
    52.       when 1
    53.         @escapes += 1
    54.       when 2
    55.         @losses += 1
    56.       end
    57.       Global.save_file
    58.     end
    59.     def saved!
    60.       @saves += 1
    61.       Global.save_file
    62.     end
    63.     def loaded!
    64.       @loads += 1
    65.       Global.save_file
    66.     end
    67.     def gameover!
    68.       @gameovers += 1
    69.       Global.save_file
    70.     end
    71.     attr_accessor :wins, :escapes, :losses
    72.     attr_accessor :saves, :loads, :gameovers, :switch
    73.   end
    74.   extend self
    75.   def filename
    76.     if PATH.empty?
    77.       FILENAME
    78.     else
    79.       PATH + "/" + FILENAME
    80.     end
    81.   end
    82.   def save_file
    83.     save_data($global_data, filename)
    84.   end
    85.   def load_file
    86.     if File.exist?(filename)
    87.       $global_data = load_data(filename)
    88.     else
    89.       $global_data = Global::Values.new
    90.       save_file
    91.     end
    92.   end
    93.   load_file
    94. end
    95. class Scene_Save
    96.   alias :kyon_global_values_scn_sv_wsd :write_save_data
    97.   def write_save_data(file)
    98.     kyon_global_values_scn_sv_wsd(file)
    99.     $global_data.saved!
    100.   end
    101. end
    102. class Scene_Load
    103.   alias :kyon_global_values_scn_ld_rsd :read_save_data
    104.   def read_save_data(file)
    105.     kyon_global_values_scn_ld_rsd(file)
    106.     $global_data.loaded!
    107.   end
    108. end
    109. class Scene_Battle
    110.   alias :kyon_global_values_scn_btl_btl_end :battle_end
    111.   def save_global_data(result)
    112.     $global_data.save_result(result)
    113.   end
    114.   def battle_end(result)
    115.     save_global_data(result)
    116.     kyon_global_values_scn_btl_btl_end(result)
    117.   end
    118. end
    复制代码


    Terms & Conditions

    Free for use in any game, as long as you don't complain at all.
    Include my nickname in your game credits.
    That's it!


    本贴来自国际rpgmaker官方论坛作者:kyonides处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/globalvalues-xp.158025/

    本帖子中包含更多资源

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

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

    使用道具 举报

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

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-7-27 07:01 , Processed in 0.146348 second(s), 59 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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