Here’s the scenario: I have several objects that have identical counterparts. An object and its counterpart are always of the same kind. At some point in the game they need to be functionally identical, that is, the values of their properties must match.
For debugging I need a routine that checks whether two objects have identical properties. Can I somehow loop through properties, like “Repeat with X running through properties of item1: if X of item1 is X of item2…” ?
Problem. You wrote 'repeat with P running through properties provided by A begin' : but this is not a condition I am able to test, or at any rate not during play.
It doesn’t seem likely, unfortunately.
You could cook up some code to trawl the veneer-level property tables. However, this is going to pick up some library properties that you probably don’t care about.
The best solution is just to write the check out manually.
That’s the solution I ended up using, for now at least. First I was afraid that I’d have to write a separate phrase for each kind, but using “provides the property” takes care of the general case as long as I remember to add all new properties to the list:
To decide whether (item1 - a thing) is identical to (item2 - a thing):
if the printed name of item1 is not the printed name of item2, decide no;
if item1 is lit and item2 is unlit, decide no;
if item1 is unlit and item2 is lit, decide no;
[...and so on; we can assume that these properties exist because each thing has them.]
if item1 provides the property xyzzy and item1 is xyzzy and item2 is not xyzzy, decide no;
if item1 provides the property xyzzy and item1 is not xyzzy and item2 is xyzzy, decide no;
if item1 provides the property fnurgle and the fnurgle of item1 is not the fnurgle of item2, decide no;
It’s not as pretty as I’d like, but does the job.
You could compare the results of ShowMeSub().
Thanks - that might work, but the objects are not in the same room so their showmes are not exactly the same. I’ll look into it if the manual solution gets too cumbersome.
If it’s a debugging thing, could you temporarily move one into the room with the other before running the check?
That’s crazy enough that it just might work. The next question is, how do I compare two ShowMeSubs? As far as I can tell it prints the text directly.
You’ll have to print it to a buffer. I suggest then turning the buffer into indexed text so that you can compare them with regexs - if there are any properties which don’t need to be the same then you can strip them out first.
ShowMeSub is only compiled for debug. If you need this in the final result then possibly your first solution might end up simpler.