"to decide whether X attacks Y" syntax

I think I’m just missing something silly here, but this code

to decide whether (x - a thing) attacks (y - a thing):
	yes; [ok, more complex than this, but "attacks" is what this example focuses on]

Is sufficient for my purposes, as I don’t have any complex if statements, so I can use the syntax

unless x attacks y:

However, I would ideally like to be able to say

if x does not attack y:

Is there a way to do this? This feels like something that should work, and I’m whiffing.

I think a conditional relation (13.12) will do that, although I haven’t banged through an example.

You can also do the easy thing:

to decide whether (x - a thing) does not attack (y - a thing):
	unless x attacks y:
1 Like

For Inform, a phrase is an arbitrary set of words, so it does not try to conjugate them (it doesn’t realise that your phrase is a verb with a subject and an object).

In addition to what has bee said above, I think it’s also possible just to add a not, like in conventional programming languages.

if not (x attacks y):

I believe the parentheses are mandatory not to confuse Inform. And it’s not really natural-language-ish, but sometimes that’s OK, right?

That “not” syntax doesn’t exist in the standard library, I’m afraid.

You could add it, but I’d be a little worried about suborning “not” from the rest of the language.

I just tested to be sure and it does seem to work, but only with the parentheses, as I said.

If I understand correctly, it’s not defined in the Standard Rules, but directly in Inform’s syntax. (See <s-condition-atomic> in Syntax.preform).

The PDF describing the English syntax says about it:

The syntax for the logical operation “not” is more complicated, because it only sometimes work by simply preceding the text with “not”. Consider this, for instance:

if not we are carrying the torch, ...

(and the it goes on on explaining why it’s complicated.)

Whoops, you’re right. Sorry – I did a test but typoed it.

1 Like
To decide if (x - a thing) does not attack (y - a thing):
  if x attacks y, no;

I often write phrases in pairs like this to provide the negative. I’m not thrilled about it, but it seems to beat the alternatives.


Thanks everyone for the discussion. It gave me a lot of stuff to try. I was embarrassed to admit I thought of a solution like Zed’s, but it didn’t seem super-elegant.

It doesn’t need to be, of course. It just needs to be clear.


Yes, my code often inspires this reaction.


Oops … I didn’t quite mean it that way. I was actually relieved to see that this was probably the best solution given the situation. With Inform’s natural language, it feels like there should be something snazzy. It makes me feel better about other times my Inform code didn’t quite read like poetry. I suppose we should save the poetry for the game text.