Crash on wrongly-terminated if phrase & Cprrect Way

I wrote the below into Inform and it crashed. This is due to a bug which crashes on a wrongly-terminated if phrase.

Check flirting with: if a person is distracted; say "No need, he's already totally engrossed in you."; stop.
However how do I get this to work?
I was told:

However if I write:

Check flirting with: if a person is distracted: say "No need, he's already totally engrossed in you."; stop.
It comes up with:

Problem. The phrase or rule definition 'Check flirting with' is written using the 'colon and indentation' syntax for its 'if's, 'repeat's and 'while's, where blocks of phrases grouped together are indented one tab step inward from the 'if ...:' or similar phrase to which they belong. But the phrase 'if a person is distracted' , which ought to begin a block, is immediately followed by 'say "No need, he's already totally engrossed in you."' at the same or a lower indentation, so the block seems to be empty - this must mean there has been a mistake in indenting the phrases.

So what is the correct way to make sure the player can’t flirt with a person twice and “make them distracted” again since a character can only be distracted once?

The thing that’s stopping it here is a formatting issue, namely indentation.

By the way, have you defined ‘flirting with’ so that you can only flirt with people, and not with inanimate objects? Because we’ll need to refer to the target of the action when we do the check. In the code below, the phrase ‘the noun’ refers to whatever noun the player typed, which should be the person they’re trying to flirt with, and hopefully not a table or a chair if you set up ‘flirting with’ right.

So proceeding on this logic, either of the following will work. Both of these have the correct indentation and do the same thing. I’ll explain the code difference after:

[code]Check flirting with:
if the noun is distracted:
say “No need, he’s already totally engrossed in you.”;
stop the action;

Check flirting with:
if the noun is distracted:
instead say “No need, he’s already totally engrossed in you.”;[/code]

So after an if statement like this, everything that’s a result of that ‘if’ clause needs to be tabbed in one more tab character than the initial ‘if’ line. You’ll see both examples above meet this criteria.

Because this is the ‘check’ stage of the action and you want to abort if someone’s distracted, you do indeed want to stop the action. You can do this with ‘stop’ or ‘stop the action’. If you immediately want to do something else as part of the rejection, you can use ‘instead’, like in my second example. Using that instead ALSO stops the action as it ‘says’ that line.

It’s considered better style per se to block things with an instead rule, rather than using ‘stop the action’:

Instead of flirting with a distracted person: say "No need, he's already totally engrossed in you."

But in the end, all 3 examples here have done the same thing. And depending on how you’re writing the flirting stuff, your way might be more convenient, or just more logical to you.

-Wade

"Flirt Zone"
	
Flirt Chamber is a room.

A person can be distracted. A person is usually not distracted.

The guard is a person in the Flirt Chamber. "A guard stares [if guard is distracted]distractedly at nothing[otherwise]observantly in your direction[end if]."

The gold key is carried by the guard. 

Instead of examining the guard:
	say "The guard is [if the guard is distracted]distracted[otherwise]vigilant[end if][if the guard carries the gold key]. You notice that a gold key is attached to his belt[end if]."
	
Instead of taking the gold key when the gold key is carried by the guard:
	if the guard is not distracted:
		say "The guard reaches for his taser, and you think better of it.";
	otherwise:
		now the player carries the gold key;
		say "You swipe the key while the guard is distracted."
	
Flirting with is an action applying to one visible thing.
Understand "flirt with [someone]" as flirting with.

Check flirting with:
	if the noun is distracted:
		instead say "No need, [the noun] is already totally engrossed in you."
		
Carry out flirting with:
	now the noun is distracted.
	
Report flirting with:
	say "You bat your eyelashes and smile mischievously at [the noun]. [The noun] stares off into space, contemplating possibilities."

Test me with "x guard / take key / flirt with guard / l / x guard / flirt with guard / take key / x guard / drop key / take key"

I see the check, carry out, and report rules as governing the normal course of an action in the general case, with instead rules being exceptions applying to specific objects or conditions in the world. Since we want to prevent flirting with a distracted person generally, I chose to put the test in the check rule for the flirting with action. In contrast, I’d put something in an instead rule if it applied to flirting with a specific person and I wanted the result to supersede the usual behavior. One could argue it either way in this case, though, since distracted people are a specific subset of people.

Thanks vlaviano. It totally worked.