Text comparisons in if statement

Hi, i’m a bit puzzled on having to start a new thread just for this matter, since it should be rather elementary, yet i haven’t actually found what i’m looking for.

I’m creating an animal which the player can name (through a js prompt thanks to vorple) and that is working fine. The animal is also intended to have a “truename”, thus i’ve declared it as having the truename and nickname properties as per the Fido example in the docs.

Now my question is, how do i check whether the text in these two variables is the same?

Instead of examining the cat:
	say "cat nick [nickname of the cat].  cat truen [truename of the cat] ";
	if  "[nickname of the cat]" exactly matches the text "[truename of the cat]":
		say "How did you know? ";

Maybe a clarifying question is in order. When i declare, for example, that

`The cat has some text called the truename. Understand the truename property as describing the cat

Would the property of truename be called [truename] or does it need to be specified as [truename of the cat]? The decleration is unique for the cat instance of the animal, right?

WI 8.6: Whose property? sheds light on this.

You don’t need to say of the cat there, but not because the cat’s the only thing with a property of that name. In action rulebook rules, properties whose objects aren’t explicitly stated are taken to be of the noun.

Also, you can leave off the quotes and brackets and say:

if the nickname exactly matches the text truename:

because these are text properties. When the value is coming directly from a say phrase, you need the quotes and brackets. So:

To say abc: say "xyz".

when play begins:
let def be "[abc]"; [ needed quotes and brackets because abc is a say statement ]
if def is "": [...] [didn't need quotes and brackets because def is a text variable (variables and properties are equivalent in this regard) ]

While this most definitely is a helpful and explanatory answer, my issue was a different one.
I had a . in the truename. :melting_face:

1 Like