diff --git a/Data/Scripts/020_Debug/003_Debug menus/003_Debug_MenuExtraCode.rb b/Data/Scripts/020_Debug/003_Debug menus/003_Debug_MenuExtraCode.rb index c96bdce37..e5ba27036 100644 --- a/Data/Scripts/020_Debug/003_Debug menus/003_Debug_MenuExtraCode.rb +++ b/Data/Scripts/020_Debug/003_Debug menus/003_Debug_MenuExtraCode.rb @@ -85,7 +85,23 @@ class SpriteWindow_DebugVariables < Window_DrawableCommand if @mode == 0 name = $data_system.switches[index + 1] codeswitch = (name[/^s\:/]) - val = (codeswitch) ? (eval($~.post_match) rescue nil) : $game_switches[index + 1] + if codeswitch + code = $~.post_match + code_parts = code.split(/[(\[=<>. ]/) + code_parts[0].strip! + code_parts[0].gsub!(/^\s*!/, "") + val = nil + if code_parts[0][0].upcase == code_parts[0][0] && + (Kernel.const_defined?(code_parts[0]) rescue false) + val = (eval(code) rescue nil) # Code starts with a class/method name + elsif code_parts[0][0].downcase == code_parts[0][0] && + !(Interpreter.method_defined?(code_parts[0].to_sym) rescue false) && + !(Game_Event.method_defined?(code_parts[0].to_sym) rescue false) + val = (eval(code) rescue nil) # Code starts with a method name (that isn't in Interpreter/Game_Event) + end + else + val = $game_switches[index + 1] + end if val.nil? status = "[-]" colors = 0