I6: Comparing Properties

I have two objects which share a class. Both have a property (called “slot”) which contains a string. For both objects it’s slot “head”. Now I want to check (in the class object) if these properties are identical. So I objectloop til I find the object I want object 1 to compare with, and compare the properties.

  if(obj~=self && obj ofclass Armour && parent(obj)==player){
        "You're wearing ",(the)obj," already!";

Problem: obj.slot and self.slot are not identical, though they both have the value “head”. Debugging shows they have different integer values. Why is that so, and how can I work around it?

You want the I6 extension istring.h, which can be downloaded from inform-fiction.org/extensions/complete.html. I’ve never used it, but it should allow you to compare two strings and find out if they’re identical.


Thanks, according to the dox that’s exactly what I need.

It slowly deems to me that the concept behind Inform takes getting used to it.

Also, BTW, the link that I gave was to the list of extensions on the I6 website. That list hasn’t been updated in about 4 years. There may be a few newer extensions in the if-archive.

In fact, I’m pretty sure there’s at least one. I didn’t see my EventList.h extension on the I6 list, and it was in the archive the last time I looked (at http://www.ifarchive.org/indexes/if-archiveXinfocomXcompilersXinform6XlibraryXcontributions.html). You might find it useful. It implements TADS-style event lists in I6. These objects are useful, among other things, for having your NPC choose from a list of default conversation responses (for a less boring game transcript). They can also fire off complex events, if desired.

I6 is generally not conducive to comparing strings. Can you replace the slot values with integer constants? Or objects? It’ll be a lot faster.

Great idea! I’ll turn the strings into integers and give them constant names.