Smell restrictions (Dialog example)

From IFWiki

The solution to our coding problem rests on the fact that in Dialog, excepting multi-queries, a definition following another definition of the same rule is called if and only if the previous rule fails.

(story author) Karona
(story noun) for IFWiki

(current player #player)

#player

#street

(name *) street
(room *)
(look *)
  This (name *) looks like something out of an IF code example. (The #sewer)
  is below you.
(from * go #down to #sewer)

(#player is #in *)

#sewer

(name *) sewer
(room *)
(look *)
  This (name *) looks like something out of an IF code example. (The #street)
  is above you.
(from * go #up to #street)

#flower

(name *) flower
%% We make the flower an item because we want it to be takeable.
(item *)
(appearance *)
  (A *) is here.
(* is #in #street)

#suit

(name *) spacesuit
(dict *) space suit
%% We do not need to make the spacesuit an item because the standard library
%% makes everything that is wearable an item -- and thus wearable.
(wearable *)
(appearance *)
  (A *) is here.
(* is #in #street)

#sewage

(name *) sewage
(appearance *)
  There is (name *) is here.
(* is #in #sewer)

(perform [smell])
  (#suit is #wornby #player)
  %% If the line above succeeds, the following line is displayed.
  You can't smell anything while wearing the spacesuit.

(instead of [smell $Obj])
  (#suit is #wornby #player)
  ~($Obj = #player)
  ~($Obj = #suit)
  %% If the lines above succeed, we redirect to (perform [smell]).
  (try [smell])
  
(perform [smell])
  (#player is #in #sewer)
  %% If the line above succeeds, the following line is displayed.
  It reeks.
  
(perform [smell #sewage])
  (#player is #in #sewer)
  %% If the line above succeeds, we redirect to (perform [smell]).
  (try [smell])
  
(perform [smell $])
  (#player is #in #sewer)
  The disgusting reek of the sewage overwhelms your nose. You can't smell anything else.

(perform [smell #flower])
  It smells wonderful.
  
%% What follows is the default response.
(perform [smell $Obj])
  You smell nothing unusual about (the $Obj).