diff --git a/safe-room.lic b/safe-room.lic index c198e8fd8a..1468eb3435 100644 --- a/safe-room.lic +++ b/safe-room.lic @@ -24,7 +24,11 @@ class SafeRoom @stop_performance_after_heal = false @tome_while_healing = settings.tome_while_healing @stop_tome_after_heal = false - @plant_regex = /(?:#{@plant_adjectives}) (\w+)/ + @plant_adjectives = settings.healing_plant_adjectives + @plant_nouns = settings.healing_plant_nouns + @adjectives_regex = Regexp.union(settings.healing_plant_adjectives) + @noun_regex = Regexp.union(settings.healing_plant_nouns) + @plant_regex = Regexp.new("#{@adjectives_regex} #{@noun_regex}") return unless args.force || need_healing? @@ -211,9 +215,10 @@ class SafeRoom DRC.release_invisibility - if /#{@plant_adjectives} (\w+)/ =~ DRRoom.room_objs.grep(@plant_regex).to_s - plant_type = Regexp.last_match(1) - fput("touch #{plant_type}") + # Match room objects against the full regex to find and capture the noun + if DRRoom.room_objs.grep(@plant_regex).to_s =~ @plant_regex + plant_type = Regexp.last_match(1) # Captures the noun (e.g., "plant", "bush") + fput("touch #{plant_type}") # Sends command to touch the specific noun end # check for safe-room idle thing to do