Fixed error message spam in the console when editing Game Swtches via the Debug mode feature

This commit is contained in:
Maruno17
2022-07-06 20:03:10 +01:00
parent 8f73319605
commit 0b65865962

View File

@@ -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