# Magical closet: the object is always in the LAST opened closet # We want "use" and "open" to give the same end result # so we duplicate everything for use and open :use > [middle_closet_open] # The closet is already open, so exit the command stop set_global middle_closet_open true # Increment the counter of the number of open closets inc_global open_closets 1 # Animate the door opening set_state r9_closet_middle open_door > [eq open_closets 3] # After opening this one, we have 3 closets open # Activate the magic bottle in this particular closet > [i/r9_bottle] # If they've already picked up the bottle, don't make it appear stop > [r9_puzzle_complete] # If they've already completed the puzzle, don't make it appear stop set_active r9_bottle_middle true # Note which cupboard the bottle is in in case the player # exits then reenters the room set_global r9_bottle_closet 2 stop :open > [middle_closet_open] # The closet is already open, so exit the command stop set_global middle_closet_open true # Increment the counter of the number of open closets inc_global open_closets 1 # Animate the door opening set_state r9_closet_middle open_door > [eq open_closets 3] # After opening this one, we have 3 closets open # Activate the magic bottle in this particular closet > [i/r9_bottle] # If they've already picked up the bottle, don't make it appear stop > [r9_puzzle_complete] # If they've already completed the puzzle, don't make it appear stop set_active r9_bottle_middle true # Note which cupboard the bottle is in in case the player # exits then reenters the room set_global r9_bottle_closet 2 stop :close > [!middle_closet_open] # If the closet isn't open, ignore the close command stop > [eq open_closets 3] # If there's 3 closets open, the bottle was made active # We don't know which closet it was activated in so lets # deactivate all of them set_active r9_bottle_left false set_active r9_bottle_middle false set_active r9_bottle_right false # Animate the door closing set_state r9_closet_middle close_door set_global middle_closet_open false # Decrement the counter of closets open (used to determine when to show # the magic bottle) dec_global open_closets 1