There are a number of methods you can use to achieve the result you desire, the following solution uses an Array variable to contain a list of the Passage Name of each of the potential 'rooms' the spirit can appear in. This variable should be intialised within your project's startup tagged special Passage.
note: I don't the Passage Names of your 'room' passage so I will use Library, Bathroom, and Hallway in this example.
(set: $rooms to (a: "Library", "Bathroom", "Hallway"))
Next you will need a way to make the Spirit move, this can be done by adding a header tagged special passage to your project and then adding code like the following to it. The name of this passage is not important, I named mine Spirit Movement.
(set: $spiritLocation to (either: ...$rooms))
Within each of your 'room' passages you can use the current value of the new $spiritLocation variable combined with the (passage:) macro to determine if you should display your 'search the room' related link.
(if: $spiritLocation is not (passage:)'s name)[{
(link: "Search Room")[
<!-- Place code for searching this room within this link's associated hook. -->
]
}]
You can also use a footer tagged special passage to display if the spirit is in the current 'room' or not, again the name of this passage isn't important. I named mine Is Spirit Here.
{
(if: $spiritLocation is (passage:)'s name)[
Spirit is here.
]
}