Skip to content

Commit

Permalink
Update safe-room.lic for custom healing plants
Browse files Browse the repository at this point in the history
  • Loading branch information
Tirost authored Oct 30, 2024
1 parent cedce88 commit a19c4c7
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions safe-room.lic
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a19c4c7

Please sign in to comment.