我想做出单一货币的进位效果,比如网游里常见的:1金币=100银币=10000铜币(百进制),或者在古代背景里适用的:1贯=1000文(千进制),或者现实背景下的:1元=10角=100分(十进制) 在论坛搜了一下,关于货币的帖 ...
sprintf("%03d贯%03d文",value/1000, value % 1000)
=begin =============================================================================== 元角分 By喵呜喵5=============================================================================== 【说明】 把金钱的显示方式修改成了XX元XX角XX分这样的形式 =end module M5Money#==============================================================================# 设定部分#============================================================================== RATE = 10 #设定进制,例如10分=1角、10角=1元的时候就把上方的数字设置成10 FEN = "分" #设定游戏中1G所对应的单位,默认获得1G即获得1分钱 JIAO = "角" #设定游戏中1G*RATE所对应的单位 YUAN = "元" #设定游戏中1G*RATE*RATE所对应的单位 #==============================================================================# 设定结束#==============================================================================#==============================================================================# 脚本部分#==============================================================================end class Window_Gold < Window_Base def refresh contents.clear draw_currency_value("",m5_gain_gold($game_party.gold),4, 0, contents.width - 8) end def m5_gain_gold(gold) yuan = gold / ( M5Money::RATE * M5Money::RATE) val = (yuan == 0 ? "" : yuan.to_s + M5Money::YUAN ) jiao = (gold / M5Money::RATE) % M5Money::RATE val += (jiao == 0 ? "" : jiao.to_s + M5Money::JIAO ) fen = gold % ( M5Money::RATE ) val += fen.to_s + M5Money::FEN end endclass << BattleManager def gain_gold if $game_troop.gold_total > 0 gold = $game_troop.gold_total yuan = gold / ( M5Money::RATE * M5Money::RATE) val = (yuan == 0 ? "" : yuan.to_s + M5Money::YUAN ) jiao = (gold / M5Money::RATE) % M5Money::RATE val += (jiao == 0 ? "" : jiao.to_s + M5Money::JIAO ) fen = gold % ( M5Money::RATE ) val += fen.to_s + M5Money::FEN text = '获得了' + val $game_message.add('\.' + text) $game_party.gain_gold($game_troop.gold_total) end wait_for_message endend
=begin =============================================================================== 元角分 By喵呜喵5 =============================================================================== 【说明】 把金钱的显示方式修改成了XX元XX角XX分这样的形式 =end module M5Money #============================================================================== # 设定部分 #============================================================================== RATE = 10 #设定进制,例如10分=1角、10角=1元的时候就把上方的数字设置成10 FEN = "分" #设定游戏中1G所对应的单位,默认获得1G即获得1分钱 JIAO = "角" #设定游戏中1G*RATE所对应的单位 YUAN = "元" #设定游戏中1G*RATE*RATE所对应的单位 #============================================================================== # 设定结束 #============================================================================== #============================================================================== # 脚本部分 #============================================================================== end class Window_Gold < Window_Base def refresh contents.clear draw_currency_value("",m5_gain_gold($game_party.gold),4, 0, contents.width - 8) end def m5_gain_gold(gold) yuan = gold / ( M5Money::RATE * M5Money::RATE) val = (yuan == 0 ? "" : yuan.to_s + M5Money::YUAN ) jiao = (gold / M5Money::RATE) % M5Money::RATE val += (jiao == 0 ? "" : jiao.to_s + M5Money::JIAO ) fen = gold % ( M5Money::RATE ) val += fen.to_s + M5Money::FEN end end class << BattleManager def gain_gold if $game_troop.gold_total > 0 gold = $game_troop.gold_total yuan = gold / ( M5Money::RATE * M5Money::RATE) val = (yuan == 0 ? "" : yuan.to_s + M5Money::YUAN ) jiao = (gold / M5Money::RATE) % M5Money::RATE val += (jiao == 0 ? "" : jiao.to_s + M5Money::JIAO ) fen = gold % ( M5Money::RATE ) val += fen.to_s + M5Money::FEN text = '获得了' + val $game_message.add('\.' + text) $game_party.gain_gold($game_troop.gold_total) end wait_for_message end end
查看全部评分
折叠内容标题(非必须)
折叠内容
站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作
GMT+8, 2024-11-17 18:40
Powered by Discuz! X3.1
© 2001-2013 Comsenz Inc.