That depends on whether the player will ever need to become solid at some point in the game. If not, then just blocking all actions other than examining (and I suppose listening to) should be sufficient. If the player will be switching between a ghostly state and a solid state during the course of the game, then things become a bit more complex-- for example, mental objects will have to be dropped when the player becomes physical (and vice versa), and X ME should reflect the current status.
This should be a good start for that scenario though:
[code]A thing can be mental or physical. A thing is usually physical.
The player is mental. [heh heh] The description is “[if the player is mental]You seem to be translucent and glowing[otherwise]You seem solidly tangible[end if].”
Xyzzying is an action applying to nothing. Understand “xyzzy” as xyzzying.
Carry out xyzzying:
if the player is mental:
say “You solidify.”;
repeat with possession running through carried things:
if the possession is mental, silently try dropping the possession;
now the player is physical;
otherwise:
say “You ectoplasmize.”;
repeat with Larry running through carried things:
if Larry is physical, silently try dropping Larry;
now the player is mental.
Instead of doing something other than listening to or examining with a physical thing when the player is mental, say “Your ghostly hand passes through [the noun] without effect.”
Instead of doing something other than listening to or examining with a mental thing when the player is physical, say “Your solid hand passes through the ephemeral [noun] without effect.”
Haunted Living Room is a room. “This place is all spooky and whatever. On the wall the word XYZZY is written… in blood, of course.”
The lamp is in the living room. The description is “It’s a lamp.” The couch is in the living room. The description is “It’s a couch.” It is fixed in place.
The ectoplasm is in the living room. It is mental. The description is “It glows eerily.” The indefinite article is “some”.
test me with “x me / x lamp / listen to lamp / get lamp / x couch / eat couch / push couch / get ectoplasm / lock ectoplasm with lamp / lock lamp with ectoplasm”.
test me2 with “xyzzy / test me”.[/code]