Empty inventory or change it when (something)

Hiya.

Before going to [location]: repeat unless the inventory is empty: if the player is carrying anything (called it): remove it from play; otherwise: continue the action.

I’m trying to make it so that if the player is carrying anything, it should be removed from play.
however, without the repeat line, it only removes one thing.
and with the repeat line, it tells me there’s an error.

things that don’t work:
drop all;
now the player is carrying nothing;
try dropping all;
silently try dropping all;

For this sort of thing, you can use a while loop:

while the player carries something (called item): now item is nowhere.

You can also in this case use a repeat… running through loop:

repeat with item running through things carried by the player: now item is nowhere.

You can look at section 11.9 through 11.12 of Writing with Inform on the different kinds of loops.

But in fact you don’t even need a loop, because this works:

now everything carried by the player is nowhere.

Why did I change “remove item from play” to “now item is nowhere”? It turns out, as stated in section 8.10 of Writing with Inform, that “remove foo from play” is now deprecated! That means that it’s not going to be in the next big rewrite of Inform, so get used to changing it now. And in fact, this shows the power of “now foo is nowhere” over “remove foo from play,” because you can’t say “remove everything carried by the player from play”–that sort of wholesale stuff only works in “now” phrases.

(Deprecating “remove from play” is going to break a lot of code, though.)

BTW, the “unless” won’t work in these phrases, but you don’t need it–if the player isn’t carrying anything then these phrases won’t do anything. You might want to check if the player is carrying something before running them, though, so you can print a special message if you need to.