じ☆ve冰风 发表于 2026-8-3 09:35:36

Switch Tags ACE

Switch Tags 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!

You will see the effects of that action while it is still printing the text on screen!


                Ruby:       
# * 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 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!(/^[\+\-\$\.\|\^!><\{\}\\]|^+/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.
Due credit is optional.
That's it!



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