• Having trouble receiving email verification when signing up? Contact an administrator via our Discord server!
  • Consider joining our Discord server if you haven't already! Discord is a free voice and text chat platform that's more or less a combination of Skype and Teamspeak. Using Discord, you can chat with other Relic Castle members in real-time! Wowza! Click here for the details!
Resource icon

Unlimited Self-Switches for Events

Pokémon Essentials Version
v16.2 ➖
Tired of being limited to 4 self-switches per event? This is the tutorial for you.
Add this script as a new section above Main
# More Self-Switches
# Version 1.3
# Author game_guy
# Intro:
# Ever need more than 4 self switches? With this small script, you can now
# have as many self switches you want. You aren't just limited to letters
# either. You can have names for them.
# Features:
# -More Self Switches
# -Name them whatever
# Instructions:
# -First, lets create a self switch for our event. Anywhere in the event, add
# a comment and type this,
# Switch:switch_name.
# switch_name can be whatever you want to name the switch. Thats all you have
# to do to create a self switch for that page.
# There cannot be any spaces between the colon and the switch name.
# e.g. Switch: switch - Does not work.
# e.g. Switch:switch - Does work.
# You also need the Self-Switch box on the page checked.
# -Now to turn this switch of or on, call this in a script call.
# self_switch("switch", true/false)
# switch is the switch name, this must be in double " " or single ' ' quotes.
# true/false tells the script whether to turn it off or on. true = on, 
# false = off.
# -If you want to see if a self switch is on/off, use this script in a
# condtional branch.
# self_switch_state("switch") == true/false
# switch is the switch name, this must be in double " " or single ' ' quotes.
# true = on, false = off
# Compatibility:
# Not tested with SDK.
# Should work with anything.
# Credits:
# game_guy ~ For creating it.
class Game_Event < Game_Character
=begin  #moved into the main initialize method
 alias gg_init_more_switches_lat initialize
 def initialize(map_id, event, map=nil)
	gg_init_more_switches_lat(map_id, event, nil)
 def check_custom_switch(page, code)
	a = code.split(':')
	return if a.length==0
	if a[0].downcase == "switch" && a[1] != nil
	  page.condition.self_switch_ch = a[1]  
class Interpreter
 def self_switch(switch, state)
	if @event_id > 0
	  key = [$game_map.map_id, @event_id, switch]
	  $game_self_switches[key] = state
	$game_map.need_refresh = true
 def self_switch_state(switch)
	key = [$game_map.map_id, @event_id, switch]
	return $game_self_switches[key]
def pbCheckSelfSwitchState(event_id,switch)
 key = [$game_map.map_id, event_id, switch]
 return $game_self_switches[key]
In Game_Event, replace def initialize with
def initialize(map_id, event, map=nil)
	@map_id = map_id
	@event = event
	@id = @event.id
	@erased = false
	@starting = false
	@through = true
	moveto(@event.x, @event.y) if map
	@event.pages.each {|page| page.list.each {|command|
	  if [108, 408].include?(command.code)
		command.parameters.each {|p| check_custom_switch(page, p) }
To use a custom switch, in the event check the self-switch box under conditions (which switch you use there doesn't matter), and add a comment saying which switch. Comment must be in the format
no spaces. Note that self switch names will be converted to lower case.
Example event

Example of event flipping the above switch

Edit: Questions that might come up
Q: Can you still use regular switches? (A, B, etc)
A: Absolutely.
Q: Can you have multiple conditions for a page?
A: Nope
Q: What takes precedence over what? (Comment order, regular switches)
A: You have to tick the regular switch box to make the event work, but regular switches are ignored if you have a commented switch. If you have multiple comment switches, the last one on the event page is the only one that matters.
Edit 2: Fixed empty comments crashing
First release
Last update
0.00 star(s) 0 ratings

More resources from mej71