Hello guys. I’m trying to make a disable choice script for RPGMaker XP.
Himeswork had one going for VXAce but it’s down, and it utilizes RGSS3, not RGSS1 (the links that are currently up have no explanation of what the code does, all is lost…)
I’ve gotten this far with the help of Google Search AI, but the code it helped me organize is not working as intended.
#==============================================================================
# ■ Case-by-Case Choice Disabler for RPG Maker XP (RGSS1)
#==============================================================================
class Window_Command < Window_Selectable
#--- Overwrite Initialization to clean up text tags on the fly ---
alias xp_tag_choice_initialize initialize
def initialize(width, commands)
@raw_commands = commands.clone # Save original text containing tags
clean_commands = commands.map { |text| text.gsub(/\\[Ss]\[\d+\]/, "") }
xp_tag_choice_initialize(width, commands)
end
#--- Draw the item, changing color if its tagged switch is ON ---
def draw_item(index, color)
raw_text = @raw_commands[index]
if raw_text =~ /\\[Ss]\[(\d+)\]/
switch_id = $1.to_i
if $game_switches[switch_id] == true
self.contents.font.color = disabled_color
else
self.contents.font.color = color
end
else
self.contents.font.color = color
end
rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @raw_commands[index])
end
#--- Accessor to let the selection process see the raw tags ---
def raw_commands
return @raw_commands
end
end
#--- Block the input if the player tries to select a disabled option ---
class Window_Selectable < Window_Base
alias xp_tag_choice_update update
def update
if self.active && @item_max > 0 && Input.trigger?(Input::C)
if self.is_a?(Window_Command)
raw_text = self.raw_commands[self.index]
if raw_text =~ /\\[Ss]\[(\d+)\]/
switch_id = $1.to_i
if $game_switches[switch_id] == true
$game_system.se_play($data_system.buzzer_se)
return
end
end
end
end
xp_tag_choice_update
end
end
Something’s terribly wrong with this. Whenever it runs through, not only does it not get rid of the switch text (\s[1]), it also does not change the color. I suspect it’s failing at either .clone or at .map