Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Switch Tags
#1
Switch Tags
VX + ACE

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! Grinning
You will see the effects of that action while it is still printing the text on screen! Shocked

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
end

VX 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
end

Terms & Conditions

Free for use in ANY game. Gamer
Due credit is optional.
That's it! Tongue sticking out
"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]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: 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! Laughing + Tongue sticking out

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
Reply }
#2
Script Backported to VX!

Well, I thought it would be unfair for those few RMVX users not to be able to turn on switches at will like the VX ACE folks could. Thus, I felt inspired enough as to come up with its VX port after a short while working on it. Grinning

Sad 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.
"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]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: 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! Laughing + Tongue sticking out

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
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   Name Game Switch & Variable RG kyonides 0 599 06-27-2023, 09:17 PM
Last Post: kyonides
   Switch Extraction Generator DerVVulfman 1 3,060 06-19-2020, 03:43 AM
Last Post: DerVVulfman
   Extra Terrain Tags DerVVulfman 2 6,207 12-21-2014, 04:25 AM
Last Post: DerVVulfman
   Switch Swap [Snippet] PK8 0 4,188 11-09-2009, 07:07 AM
Last Post: PK8



Users browsing this thread: