01-08-2024, 01:08 AM 
(This post was last modified: 01-08-2024, 03:19 AM by kyonides.
 Edit Reason: ACE + VX
)
	
	
	Switch Tags
VX + ACE
by Kyonides
by Kyonides
Introduction
With this scriptlet you will be able to turn on or off any given switch by leaving 3 different tags in the show text box!
 
 You will see the effects of that action while it is still printing the text on screen!
 
 VX Script
Code:
# * Switch Tags VX * #
#   Scripter : Kyonides Arkanthes
#   2024-01-07
# The script implements the use of 2 game switch tags that look something like
# this: First \s[10] and later \+ or \-
class Window_Message
  alias :kyon_switch_tag_win_mess_conv_sp_char :convert_special_characters
  def convert_special_characters
    @switch_block = Proc.new {}
    @text.gsub!(/\\\+/, "\x18")
    @text.gsub!(/\\\-/, "\x19")
    kyon_switch_tag_win_mess_conv_sp_char
    @text.gsub!(/\\s\[(\d+)\]/i) { @switch_block = switch_proc($1.to_i); "" }
  end
  def switch_proc(switch_id)
    Proc.new do |state|
      $game_switches[switch_id] = state
      $game_map.need_refresh = true
    end
  end
  def process_character(c)
    case c
    when "\x01"
      @text.sub!(/\[([0-9]+)\]/, "")
      contents.font.color = text_color($1.to_i)
    when "\x02"
      @gold_window.refresh
      @gold_window.open
    when "\x03"
      @wait_count = 15
      @break = true
    when "\x04"
      @wait_count = 60
      @break = true
    when "\x05"
      self.pause = true
      @break = true
    when "\x06"
      @line_show_fast = true
    when "\x07"
      @line_show_fast = false
    when "\x08"
      @pause_skip = true
    when "\x18"
      @switch_block.call(true)
    when "\x19"
      @switch_block.call(false)
    else
      contents.draw_text(@contents_x, @contents_y, 40, WLH, c)
      c_width = contents.text_size(c).width
      @contents_x += c_width
    end
  end
  def update_message
    loop do
      c = @text.slice!(/./m)
      case c
      when nil
        finish_message
        break
      when "\x00"
        new_line
        if @line_count >= MAX_LINE
          unless @text.empty?
            self.pause = true
            break
          end
        end
      end
      process_character(c)
      if @break
        @break = nil
        break
      end
      break unless @show_fast or @line_show_fast
    end
  end
endVX ACE Script
Code:
# * Switch Tags ACE * #
#   Scripter : Kyonides Arkanthes
#   2024-01-07
# The script implements the use of 2 game switch tags that look something like
# this: First \s[10] and later \+ or \-
class Window_Base
  alias :kyon_switch_tag_win_bs_conv_esc_char :convert_escape_characters
  def convert_escape_characters(text)
    @switch_block = Proc.new {}
    result = kyon_switch_tag_win_bs_conv_esc_char(text)
    result.gsub!(/\es\[(\d+)\]/i) do
      @switch_id = $1.to_i
      @switch_block = Proc.new {|state| $game_switches[@switch_id] = state }
      ""
    end
    result
  end
  def obtain_escape_code(text)
    text.slice!(/^[\+\-\$\.\|\^!><\{\}\\]|^[A-Z]+/i)
  end
end
class Window_Message
  alias :kyon_switch_tag_win_mess_proc_esc_char :process_escape_character
  def process_escape_character(code, text, pos)
    case code
    when '+'
      @switch_block.call(true)
    when '-'
      @switch_block.call(false)
    end
    kyon_switch_tag_win_mess_proc_esc_char(code, text, pos)
  end
endTerms & Conditions
Free for use in ANY game.

Due credit is optional.
That's it!
 
	
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
![[Image: SP1-Scripter.png]](https://www.save-point.org/images/userbars/SP1-Scripter.png)
![[Image: SP1-Writer.png]](https://www.save-point.org/images/userbars/SP1-Writer.png)
![[Image: SP1-Poet.png]](https://www.save-point.org/images/userbars/SP1-Poet.png)
![[Image: SP1-PixelArtist.png]](https://www.save-point.org/images/userbars/SP1-PixelArtist.png)
![[Image: SP1-Reporter.png]](https://i.postimg.cc/GmxWbHyL/SP1-Reporter.png)
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!
Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
	
	
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
![[Image: SP1-Scripter.png]](https://www.save-point.org/images/userbars/SP1-Scripter.png)
![[Image: SP1-Writer.png]](https://www.save-point.org/images/userbars/SP1-Writer.png)
![[Image: SP1-Poet.png]](https://www.save-point.org/images/userbars/SP1-Poet.png)
![[Image: SP1-PixelArtist.png]](https://www.save-point.org/images/userbars/SP1-PixelArtist.png)
![[Image: SP1-Reporter.png]](https://i.postimg.cc/GmxWbHyL/SP1-Reporter.png)
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE

 
 
 Switch Tags
 Switch Tags
 

 
 Sadly, RMXP won't be getting its own port for the Window_Message class isn't modular enough to let me do so without coming up with a brand new script.
 Sadly, RMXP won't be getting its own port for the Window_Message class isn't modular enough to let me do so without coming up with a brand new script.
	