Hiding text that would normally print

Hi all–I’m back with another basic question. In this scenario, if the player tries to open a locked gate while carrying the key, I want the game to automatically have them unlock the gate first. I’ve written the below:

Before opening the gate:
	say "(first unlocking the gate)";
	try unlocking the gate with the key.

However, this results in:

open gate
(first unlocking the gate)
You unlock the gate.

You open the gate.

How can I hide the “You unlock the gate” line?


In cases like this, you can just do:

Try silently unlocking the gate with the key.

That attempts the action without firing the regular reporting rules, which are responsible for that line you want to eliminate (the RULES testing command is helpful for instances like this – it will show you a lot of detail that can be overwhelming, but if you just look for the last rule that displays before the text you’re interested in, that will usually tell you where the issue is).

This rule is a little funny looking, though – like, if the player isn’t carrying the key, it’ll try to get it with an implicit take, and if the key isn’t in the location, they’ll get a confusing “That isn’t available” response. Do you just want to automate the process of unlocking a door? If so, you could just use the Locksmith extension by Emily Short, which automates a lot of the annoying busywork involving doors – it’s another built-in extension, so you can just write “Include Locksmith by Emily Short.” in your code. The documentation goes into more detail on what it does, but it’s a nice quality of life improvement!


Ah, thanks so much! I’ve added the Locksmith extension. :closed_lock_with_key: