じ☆ve冰风 发表于 2026-7-17 19:51:19

Switch Tags VX

Switch Tags VX

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!


                Ruby:       
# * 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 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 = state
      $game_map.need_refresh = true
    end
end

def process_character(c)
    case c
    when "\x01"
      @text.sub!(/\[(+)\]/, "")
      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


Terms & Conditions

Free for use in ANY game.
Due credit is optional.
That's it!



本贴来自国际rpgmaker官方论坛作者:kyonides处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/switch-tags-vx.164595/
页: [1]
查看完整版本: Switch Tags VX