Is there a way to get Inform to react in both its ways to the same nounless action?

What do I mean by this question?

Let’s say the verb is ATTACK.

You can set up grammar for a noun-taking action so that when it doesn’t receive a noun (I just type ATTACK) Inform will run the rules for supplying a missing noun first. Then if it doesn’t get one that applies, it will just say ‘You must supply a noun.’

On the other hand, you can set the grammar up so that if no noun is typed, Inform says ‘What do you want to ATTACK?’ and will then as a Nicety, act on a one word answer to this question. But if you go this route, the rules for supplying a missing noun are never involved.

Ideally I want a mix. I want a nounless ATTACK to consult rules for supplying a missing noun, act on them if it finds a good one, and if it doesn’t, say ‘What do you want to attack?’ + give the one-word answer Nicety.

Is this possible?

EDIT: For clarification, it’s not the message ‘You must supply a noun’ I don’t like, because I could change that to anything I like. It’s the lack of the Nicety. After ‘you must supply a noun’, you can’t just type the noun. You have to enter a new command.

-Wade

Unfortunately, I don’t believe there is. You can use “does the player mean” rules to suggest which objects the action should act on, and if there’s only one relevant object at hand, the game will choose that one. But that’s a lot less precise of control than “supplying a missing noun”.

1 Like

I had a feeling that would probably be the case.

In this game, over time I’ve gone off liking making separate one word versions of actions (of which I have some), because then I have to watch out for those on top of the with-noun versions in Before and Instead actions. i.e. Typically with before and instead, I’m screening actions at strange moments.

I could group the one word and two word versions of ATTACK together into a type of action, but then I still have to do a retrofit pass over the whole game code, watching out for mistakes. I’m also liking doing that kind of thing less these days, unsurprisingly :slight_smile:

This is all just some aloud-thinking for anyone else who comes this way. I may simply end up giving a more cool response than ‘You must supply a noun’ and enjoy the Supply Missing Nouns rules doing their thing, in today’s case.

-Wade

1 Like

The usual method for avoiding that is to have one redirect to the other at the Before stage, which means you only have to write a full set of rules for one of them. This is how Stormrider handles sabotage, for example; if you have an appropriate tool, it’s applied automatically.

Does this get you at least part of the way there? (Note: I modified this quickly from some WIP code, so it may be a bit not-right.) UPDATE: edited to remove some extraneous lines in the code.

Following-up is a truth state that varies.

A Question is a kind of object.
A question has an object based rulebook called the result.
The current inquiry is a question that varies.

To prepare to ask (Q - a question):
	now the current inquiry is Q;
	say Q;
	now Following-up is true;
	
Supplying an answer with is an action applying to one object.

Understand "[something]" as supplying an answer with when following-up is true.

This is the clear questioning rule:
 	now Following-up is false;
	
Carry out supplying an answer with:
	let RB be the result of the current inquiry;
	follow RB for the noun;
	
The clear questioning rule is listed before the generate action rule in the turn sequence rulebook.

Troll Room is a room.

The player carries the elvish sword.
The troll-creature is an animal in the Troll Room. It is privately-named. The printed name is "troll". Understand "troll" as the troll-creature.
Understand "attack" as attacking.

attack-what is a Question. The printed name is "What do you want to attack?[line break]".

attack clarifying is an object based rulebook.
	
The result of attack-what is attack clarifying.

attack clarifying something (called S):
	try attacking S;

Rule for supplying a missing noun while attacking:
	prepare to ask attack-what;
	
Instead of attacking the troll-creature:
	say "The troll is knocked out!";

test me with "attack/troll/attack/me/attack/i".
1 Like

How about something like the following?

Attacking Rules
"Attacking Rules"

Dojo is a room.

The block attacking rule does nothing.

Understand "attack" as attacking.

A target is here.

Before doing anything:
	now implicit action is the waiting action.

Carry out attacking something:
	now the noun is off-stage.

Report attacking something:
	say "You break [the noun] apart with your bare hands."

An apple is here.

After attacking the apple:
	say "You mash [the noun] to pulp."

A boulder is here.

Instead of attacking the boulder:
	say "You'd rather keep your hands intact."

Instead of attacking yourself:
	say "Um, no."

Targeting is a rulebook producing an object.

First targeting:
	now implicit action is the waiting action.

Targeting when the player can see the target:
	rule succeeds with result target.

Targeting when the player can see the apple:
	rule succeeds with result apple.

Last Targeting:
	say "What do you want to attack?";
	now implicit action is the attacking action.

Rule for supplying a missing noun while attacking:
	let target be the object produced by the targeting rules;
	now the noun is target.

Implicit action is initially the waiting action.

Noun naming is an action applying to one thing. Understand "[thing]" as noun naming when implicit action is not the waiting action.

Before noun naming:
	convert to implicit action on the noun.

Rule for printing a parser error when the latest parser error is the not a verb I recognise error and implicit action is the attacking action:
	say "I don't see any such target. Try again."

Test attacks with "attack / attack / attack / boulder / me / attack boulder / attack / darkness / me / attack / jump".

which yields:

>[1] attack
You break the target apart with your bare hands.

>[2] attack
You mash the apple to pulp.

>[3] attack
What do you want to attack?

>[4] boulder
You'd rather keep your hands intact.

>[5] me
I didn't understand that sentence.

>[6] attack boulder
You'd rather keep your hands intact.

>[7] attack
What do you want to attack?

>[8] darkness
I don't see any such target. Try again.

>[9] me
Um, no.

>[10] attack
What do you want to attack?

>[11] jump
You jump on the spot.
2 Likes

Thanks for these similar systems you two. I’d just grown attached to my contextually aware help message, which took a modicum of programming, but now I may have to abandon it and grudgingly accept the help I originally requested.

-Wade

My apologies for the semi-duplicate. (And for stepping on your toes, rileypb – you got there first!) After only glancing at the first few lines of rileypb’s solution, I mistakenly understood it to require the Questions extension and wanted to suggest something that didn’t need additional third party code.

I note that rileypb’s solution doesn’t depend on an undocumented phrase, nor does it require fleshing out rules for the attacking action (as mine does because it removes the block attacking rule).

What’s the undocumented phrase?

Don’t worry about that, I removed that rule from this program about four years ago :laughing:

-Wade

It’s a phrase in the Standard Rules:

To convert to (AN - an action name) on (O - an object):
	(- return GVS_Convert({AN},{O},0); -) - in to only.

Ah, yes. I forgot it was technically undocumented. It’s something I’d cribbed from the Standard Rules a way back and have probably used about the place in the interrim.

-Wade