Check rule goes awry when the actor is ordered by player

If the player tells Skymaster to morph, and Skymaster is in morphed state already, I get an additional message, here shown in red:

Engine Hall
You can see Skymaster here.

skymaster, morph
Skymaster transforms!

skymaster, morph
Skymaster has already morphed.

Skymaster is unable to do that.

[code]A person is either mint or morphed. A person is usually mint.
morphing is an action applying to nothing.
Understand “morph” as morphing.
Persuasion rule for asking a person to try morphing: persuasion succeeds.

Check an actor morphing:
If the actor is morphed:
Say “[Actor] [have] already morphed.” instead;

Carry out an actor morphing:
Say “[Actor] transforms!”;
Now the actor is morphed.

Engine Hall is a room.
Skymaster is a man in the Engine Hall.[/code]

It works fine when the player morphs, so it has something to do with the player ordering Skymaster.

The general expectation is that failed actions by NPCs will print responses in the “Unsuccessful Attempt” stage rather than the “Check” stage, since that takes visibility into account. (The action could be called from a “try” statement, or in a series of commands like “Alice, se. se. morph. nw. nw.” The player is usually aware of their own actions, but the error shouldn’t print for Alice unless the player can actually see her.)

Thanks, I didn’t knew what the problem was. But okay, ‘Unsuccessful attempt’ is where it goes wrong. I adding this, which solved the problem:

Unsuccessful attempt by actor morphing:
	Do nothing;

Is this the right way to deal with this? I don’t want to write crap code.

This still produces an incorrect response if the actor isn’t in the location. You want to move the error message to the unsuccessful attempt rule.

Check someone morphing when the actor is [something something something] (this is the no morphing rule): stop the action. Unsuccessful attempt by someone morphing when the reason the action failed is the no morphing rule: say [something something something].
This is unwieldy for a single rule but you can lump a lot of them together. See the Measured Liquid extension for a real world example of this paradigm.

Quite useful, this - thanks!

I have inserted your code example, and it’s working:

Check someone morphing when the actor is morphed (this is the no morphing rule): stop the action. Unsuccessful attempt by someone morphing when the reason the action failed is the no morphing rule: say "[actor] [have] already morphed."

I tried looking into measured liquid extension as you said. Alas, I failed to grasp how the above rule can be lumped together with others. Can you give me some some pointers?

I think what Draconis is talking about is the section on Unsuccessful attempts, which includes a rule like this:

Unsuccessful attempt by someone drinking something (this is the explain unsuccessful drinking rule): if the reason the action failed is: -- the can't drink things that aren't fluids rule: say "[The noun] [is-are]n't suitable to drink."; rule succeeds; -- the can't drink from empty containers rule: say "[The noun] contain[s] nothing." instead; rule succeeds; -- the can't drink noxious containers rule: say "The [liquid of the noun] [is-are]n't something [the actor] can drink."; rule succeeds.

This uses the switch-case syntax (that thing with the dashes) to enable us to run through various rules that could’ve stopped the action and to consolidate them into one rule, so we don’t have to write one rule for “Unsuccessful attempt by someone drinking something when the reason the action failed is the can’t drink things that aren’t fluids rule,” another similar thing for the can’t drink from empty containers rule, and so on. It saves you a lot of typing, and if you put the unsuccessful attempts in one place like that, then I guess you know that when you add a new check rule you have to jet on over to the “Unsuccessful attempts” portion of your code and add another switch case.

Oh that makes sense! I tried it out, but for some reason, the Check never stops the player from morphing, only the NPCs:

[code]Chapter - Define Things

A person is either immune-to-morphing or not-immune-to-morphing. A person is usually not-immune-to-morphing.
A person is either mint or morphed. A person is usually mint.

Chapter - Morphing

morphing is an action applying to nothing.
Understand “morph” as morphing.
Persuasion rule for asking a person to try morphing: persuasion succeeds.

Check someone morphing when the actor is morphed (this is the no-morphing rule):
stop the action.

Check someone morphing when the actor is immune-to-morphing (this is the immune-to-morphing rule):
stop the action.

Unsuccessful attempt by someone morphing (this is the explain-failed-morphing rule):
if the reason the action failed is:
– the no-morphing rule:
say “[regarding actor][They] [have] already morphed.”;
Rule succeeds;
– the immune-to-morphing rule:
say “[regarding actor][They] [can’t] be morphed.”;
Rule succeeds;

Carry out an actor morphing:
Say “[regarding actor][They] transforms!”;
Now the actor is morphed.

Chapter - The World

Engine Hall is a room.
Skymaster is a man in the Engine Hall.
Froggydog is a man in the Engine Hall. Froggydog is immune-to-morphing.[/code]

When you have “someone” in an action description, it only applies to NPCs.

Yeah, that’s right. It works now! (But I had to add a say statement in the check itself, since the explain-failed-morphing rule is don’t like the player)

Chapter - Define Things

A person is either immune-to-morphing or not-immune-to-morphing. A person is usually not-immune-to-morphing.
A person is either mint or morphed. A person is usually mint.

Chapter - Morphing

morphing is an action applying to nothing.
Understand "morph" as morphing.
Persuasion rule for asking a person to try morphing: persuasion succeeds.

Check an actor morphing when the actor is morphed (this is the no-morphing rule):
	If the actor is the player, say "[regarding actor][They] [have] already morphed.";
	stop the action.

Check an actor morphing when the actor is immune-to-morphing (this is the immune-to-morphing rule):
	If the actor is the player, say "[regarding actor][They] [can't] be morphed.";
	stop the action.

Unsuccessful attempt by an actor morphing (this is the explain-failed-morphing rule):
	if the reason the action failed is:
		-- the no-morphing rule:
			say "[regarding actor][They] [have] already morphed.";
			Rule succeeds;
		-- the immune-to-morphing rule:
			say "[regarding actor][They] [can't] be morphed.";
			Rule succeeds;
	
Carry out an actor morphing:
	Say "[regarding actor][They] transforms!";
	Now the actor is morphed.

Chapter -  The World

Engine Hall is a room.
Skymaster is a man in the Engine Hall.
Froggydog is a man in the Engine Hall. Froggydog is immune-to-morphing.

Looks like the right way to do it!

One point, though, is that you probably want to move the message about morphing into a separate Report rule. If it’s in a Report rule, then the message won’t print if you can’t see the action, which is probably what you want.

In general it’s considered a good idea not to put messages in Carry out rules, except for actions like looking or taking inventory where the action is about printing a message–though I’ve found that sometimes I can’t help it.

Nice catch! I didn’t consider that.

(But, if needed, I guess I could keep the message in Carry out by letting it be dependent on a If actor can touch the player)

Updated:

Chapter - Define Things

A person is either immune-to-morphing or not-immune-to-morphing. A person is usually not-immune-to-morphing.
A person is either mint or morphed. A person is usually mint.

Chapter - Morphing

morphing is an action applying to nothing.
Understand "morph" as morphing.
Persuasion rule for asking a person to try morphing: persuasion succeeds.

Check an actor morphing when the actor is morphed (this is the no-morphing rule):
	If the actor is the player, say "[regarding actor][They] [have] already morphed.";
	stop the action.

Check an actor morphing when the actor is immune-to-morphing (this is the immune-to-morphing rule):
	If the actor is the player, say "[regarding actor][They] [can't] be morphed.";
	stop the action.

Unsuccessful attempt by an actor morphing (this is the explain-failed-morphing rule):
	if the reason the action failed is:
		-- the no-morphing rule:
			say "[regarding actor][They] [have] already morphed.";
			Rule succeeds;
		-- the immune-to-morphing rule:
			say "[regarding actor][They] [can't] be morphed.";
			Rule succeeds;
	
Carry out an actor morphing:
	Now the actor is morphed.
	
Report an actor morphing:
	Say "[regarding actor][They] transforms!";
	

Chapter -  The World

Engine Hall is a room.
Skymaster is a man in the Engine Hall.
Froggydog is a man in the Engine Hall. Froggydog is immune-to-morphing.
1 Like