Squeaky floorboards and darkness in Inform 6

Hey, everyone. I’m working on a game in Inform 6 involving a stealth mechanic. For now I’m starting simple: when you walk into a room with a squeaky floorboard, an NPC hears it comes over and investigates.

But just getting this into a working state is turning out harder than I thought it would because of the way darkness works. Eventually I decided to replace NoteArrival…

[ NoteArrival descin; if (location == thedark) { lastdesc = thedark; if ((real_location has squeaky) && (action ~= ##Look)) print "The floorboards squeak as you blindly stumble into the room.^"; return; } if (location ~= lastdesc) { if ((real_location has squeaky) && (action ~= ##Look)) print "The floorboards squeak as you move into the room, which will totally alert the NPC when it's coded in later.^"; if (location.initial ~= 0) PrintOrRun(location, initial); descin = location; NewRoom(); lastdesc = descin; } ];

…which works pretty well, but the way it’s set up now, entering a ~light room with, say, a flashlight, and then turning it off, causes the “The floorboards squeak as you blindly stumble…” text to print since the player has “entered” the darkness, even though the player hasn’t actually gone anywhere. How do I prevent that from happening? I’m totally stumped.

Check if real_location is different from lastdesc, instead of location?