As this is using script calls to change the layers it would probably be best to use a common event to process the commands.
I will provide the adjusted script and break down the changes I did to make it work.
Added the option to the menu, you can change the command name if you like
Ruby:
COMMANDS =[
:window_red, # Changes the red tone for all windows.
:window_grn, # Changes the green tone for all windows.
:window_blu, # Changes the blue tone for all windows.
:volume_bgm, # Changes the BGM volume used.
:volume_bgs, # Changes the BGS volume used.
:volume_sfx, # Changes the SFX volume used.
:blank,
:autodash, # Sets the player to automatically dash.
:instantmsg, # Sets message text to appear instantly.
:animations, # Enables battle animations or disables them.
# :switch_1, # Custom Switch 1. Adjust settings below.
# :switch_2, # Custom Switch 2. Adjust settings below.
# :variable_1, # Custom Variable 1. Adjust settings below.
# :variable_2, # Custom Variable 2. Adjust settings below.
:ce_1,
:blank,
:to_title, # Returns to the title screen.
:shutdown, # Shuts down the game.
] # Do not remove this.
Added the custom CE by Switch section below CUSTOM_SWITCHES
Ruby:
# -------------------------------------------------------------------------
} # Do not remove this.
#--------------------------------------------------------------------------
# - Custom Common Event Switches -
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# If you want your game to have system options other than just the ones
# listed above, you can insert custom switches here to produce such an
# effect. Adjust the settings here as you see fit.
#--------------------------------------------------------------------------
CUSTOM_CE_SWITCHES ={
# -------------------------------------------------------------------------
# :switch => [Switch, Name, Off Text, On Text,
# Help Window Description,
# Switch off CE called, Switch on CE called
# ], # Do not remove this.
# -------------------------------------------------------------------------
:ce_1 => [ 1, "Custom CE 1", "OFF", "ON",
"Help description used for custom switch 1.",
1, 2 # CE called (off / on)
],
# -------------------------------------------------------------------------
:ce_2 => [ 2, "Custom CE 2", "OFF", "ON",
"Help description used for custom switch 2.",
3, 4 # CE called (off / on)
],
# -------------------------------------------------------------------------
} # Do not remove this.
Added a line in make_command_list
Ruby:
else
process_custom_switch(command)
process_custom_ce_switch(command)
process_custom_variable(command)
end
end
end
Added custom method below process_custom_switch
Ruby:
#--------------------------------------------------------------------------
# process_custom_switch
#--------------------------------------------------------------------------
def process_custom_ce_switch(command)
return unless YEA::SYSTEM::CUSTOM_CE_SWITCHES.include?(command)
name = YEA::SYSTEM::CUSTOM_CE_SWITCHES[command][1]
add_command(name, :custom_ce, true, command)
@help_descriptions[command] = YEA::SYSTEM::CUSTOM_CE_SWITCHES[command][4]
end
Added option in draw_item(index)
Ruby:
#--------------------------------------------------------------------------
# draw_item
#--------------------------------------------------------------------------
def draw_item(index)
reset_font_settings
rect = item_rect(index)
contents.clear_rect(rect)
case @list[index][:symbol]
when :window_red, :window_grn, :window_blu
draw_window_tone(rect, index, @list[index][:symbol])
when :volume_bgm, :volume_bgs, :volume_sfx
draw_volume(rect, index, @list[index][:symbol])
when :autodash, :instantmsg, :animations
draw_toggle(rect, index, @list[index][:symbol])
when :to_title, :shutdown
draw_text(item_rect_for_text(index), command_name(index), 1)
when :custom_switch
draw_custom_switch(rect, index, @list[index][:ext])
when :custom_ce
draw_custom_ce_switch(rect, index, @list[index][:ext])
when :custom_variable
draw_custom_variable(rect, index, @list[index][:ext])
end
end
Added custom method below draw_custom_switch(rect, index, ext)
Ruby:
#--------------------------------------------------------------------------
# cursor_right
#--------------------------------------------------------------------------
def draw_custom_ce_switch(rect, index, ext)
name = @list[index][:name]
draw_text(0, rect.y, contents.width/2, line_height, name, 1)
#---
dx = contents.width / 2
enabled = $game_switches[YEA::SYSTEM::CUSTOM_CE_SWITCHES[ext][0]]
dx = contents.width/2
change_color(normal_color, !enabled)
option1 = YEA::SYSTEM::CUSTOM_CE_SWITCHES[ext][2]
draw_text(dx, rect.y, contents.width/4, line_height, option1, 1)
dx += contents.width/4
change_color(normal_color, enabled)
option2 = YEA::SYSTEM::CUSTOM_CE_SWITCHES[ext][3]
draw_text(dx, rect.y, contents.width/4, line_height, option2, 1)
end
Added process in cursor_change(direction)
Ruby:
#--------------------------------------------------------------------------
# cursor_change
#--------------------------------------------------------------------------
def cursor_change(direction)
case current_symbol
when :window_red, :window_blu, :window_grn
change_window_tone(direction)
when :volume_bgm, :volume_bgs, :volume_sfx
change_volume(direction)
when :autodash, :instantmsg, :animations
change_toggle(direction)
when :custom_switch
change_custom_switch(direction)
when :custom_ce
change_custom_ce_switch(direction)
when :custom_variable
change_custom_variables(direction)
end
end
Added custom method below change_custom_switch(direction)
Ruby:
#--------------------------------------------------------------------------
# change_custom_switch
#--------------------------------------------------------------------------
def change_custom_ce_switch(direction)
value = direction == :left ? false : true
ext = current_ext
current_case = $game_switches[YEA::SYSTEM::CUSTOM_CE_SWITCHES[ext][0]]
$game_switches[YEA::SYSTEM::CUSTOM_CE_SWITCHES[ext][0]] = value
# start ce
if value != current_case
value == true ?
$game_temp.reserve_common_event(YEA::SYSTEM::CUSTOM_CE_SWITCHES[ext][6]) :
$game_temp.reserve_common_event(YEA::SYSTEM::CUSTOM_CE_SWITCHES[ext][5])
end
# end of ce
Sound.play_cursor if value != current_case
draw_item(index)
end
Then setup your common events