[ZILF] Wear Action Discrepancy in Cloak of Darkness

I’m breaking down the “Cloak of Darkness” example and there is this object:

<OBJECT CLOAK
  (IN PLAYER)
  (DESC "cloak")
  (SYNONYM CLOAK)
  (FLAGS TAKEBIT WEARBIT WORNBIT)
>

With just that in place, if I play the Cloak game, I see this output:

> wear cloak
You already have that.

It looks like it’s treating the “wear” as a take. If you do an implicit take – for example, where the cloak is on the ground – you get:

> wear cloak
[taking the cloak]
You already have that.

This is basically using the example from the repository. I feel like I’m missing something extremely obvious. Specifically, is there a flag that I should be setting that I’m not?

Yes, I observed that as well. The default WEAR handler in zillib does an implicit TAKE. And even if you remove the WORNBIT from the OBJECT definition, performing “wear cloak” also gives the “you already have that” response. Maybe it can be re-implemented or re-defined…

1 Like

Got it. Yeah, it looks like it’s all about taking even though the object is worn. Example transcript (when the player is already carrying the cloak):

> i
You are carrying:
  a cloak (worn)

> wear cloak
You already have that.

> take off cloak
You drop the cloak.

> take cloak
You wear the cloak.

> i
You are carrying:
  a cloak (worn)

So it does actually treat a worn item as being worn. But notice the last two commands. If you take the cloak, it automatically wears it. It looks like it’s assuming that if you take an item that can be worn, then it will automatically wear it. And I agree that the WORNBIT can be removed or put in place and the behavior is exactly the same.

1 Like

After some more digging, it looks like this might be expected behavior.

I’m basing that off of the tests I see in the ZILF repository. For example test-then.zil shows that wearing the hat is the expected response to taking the hat.

IIRC, this unfortunate behavior was added back when ZILF’s library was just a quick proof-of-concept, and we never got around to rewriting it, even though holding an article of clothing and wearing it really should be separate concepts. Feel free to file an issue on Jira or send a PR on Heptapod.

3 Likes