赞 | 68 |
VIP | 397 |
好人卡 | 580 |
积分 | 22 |
经验 | 311270 |
最后登录 | 2022-3-9 |
在线时间 | 4033 小时 |
…あたしは天使なんかじゃないわ
- 梦石
- 0
- 星屑
- 2208
- 在线时间
- 4033 小时
- 注册时间
- 2010-10-4
- 帖子
- 10779
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 taroxd 于 2014-12-29 12:46 编辑
与 “事件转译器” 可能会有冲突,故停止维护
- #----------------------------------------------------------------------------
- # ● require Taroxd基础设置
- #----------------------------------------------------------------------------
- module Taroxd::Eval
- #--------------------------------------------------------------------------
- # ● 脚本中的简称列表
- #--------------------------------------------------------------------------
- SCRIPT_ABBR_LIST = {
- 'V' => '$game_variables',
- 'S' => '$game_switches',
- 'N' => '$game_actors',
- 'A' => '$game_actors',
- 'P' => '$game_party',
- 'G' => '$game_party.gold',
- 'E' => '$game_troop'
- }
- #--------------------------------------------------------------------------
- # ● 处理脚本用的正则表达式
- #--------------------------------------------------------------------------
- words = SCRIPT_ABBR_LIST.keys.join('|')
- SCRIPT_ABBR_RE = /(?<!::|['"\\\.])\b(?:#{words})\b(?! *[(@$\w'"])/
- #--------------------------------------------------------------------------
- module_function
- #--------------------------------------------------------------------------
- # ● 对脚本的处理
- #--------------------------------------------------------------------------
- def process_script(script)
- script.gsub(SCRIPT_ABBR_RE, SCRIPT_ABBR_LIST)
- end
- #--------------------------------------------------------------------------
- # ● 执行脚本
- #--------------------------------------------------------------------------
- def eval(script, *args)
- v = $game_variables
- s = $game_switches
- n = $game_actors
- a = $game_actors
- p = $game_party
- g = $game_party.gold
- e = $game_troop
- script = process_script(script)
- if args.empty?
- instance_eval(script, __FILE__, __LINE__)
- else
- Kernel.eval(script, *args)
- end
- end
- #--------------------------------------------------------------------------
- # ● 混入模块
- #--------------------------------------------------------------------------
- Game_Character.send :include, self
- Game_Interpreter.send :include, self
- end
-
- class RPG::UsableItem::Damage
- #--------------------------------------------------------------------------
- # ● 根据参数执行计算公式
- #--------------------------------------------------------------------------
- def eval(a, b, v)
- value = Taroxd::Eval.eval(@formula, b.formula_binding(a, b, v))
- value > 0 ? value * sign : 0
- end
- end
- class Game_BattlerBase
- #--------------------------------------------------------------------------
- # ● 执行计算公式的环境
- #--------------------------------------------------------------------------
- def formula_binding(a, b, v)
- s = $game_switches
- n = $game_actors
- p = $game_party
- g = $game_party.gold
- e = $game_troop
- binding
- end
- end
- class Window_Base < Window
- #--------------------------------------------------------------------------
- # ● 对 #{} 的处理
- #--------------------------------------------------------------------------
- process_expression = Proc.new do |old|
- old.gsub(/\e?#(?<brace>\{([^{}]|\g<brace>)*\})/) do |code|
- next code if code.slice!(0) == "\e"
- Taroxd::Eval.eval code[1..-2]
- end
- end
- def_with :convert_escape_characters, process_expression
- end
复制代码 |
|