Understand "[playerinput]" as a backdrop not working

The question du jour:

I want the player to be able to name something that will be a backdrop in every scene. Thanks to the documentation, this works:

The puppyname is a text that varies.

To decide whether collecting names: 
    if the command prompt is "What would you like to name the puppy? > ", yes; 
    no.

After reading a command when collecting names:
	if the number of words in the player's command is greater than 2:
		say "[paragraph break]How about just a first name? Let's keep it simple.";
		reject the player's command;
	now the puppyname is the player's command;
	reject the player's command.

Here’s where the problem is:

Puppy is a backdrop. It is everywhere. The description is "[puppyname] is such a cute puppy.".

Understand "[puppyname]" as Puppy.
The printed name of Puppy is "[puppyname]".

Here’s the error:

Problem. I was unable to understand what you meant by the grammar token ‘puppyname’ in the sentence ‘Understand “[puppyname]” as Puppy’

Inform doesn’t like something about me naming the puppy backdrop with the player’s input. How can I make this work?

How about something like the following?

"Puppy Name"

Place is a room.

Puppy is an animal in Place.

Puppy has some text called given name. The given name of Puppy is "Phil".

The printed name of Puppy is "[given name]".

Understand the given name property as describing Puppy. [See WWI 17.15 Understanding things by their properties]

Naming is an action applying to one thing and one topic. Understand "name [something] [text]" as naming.

Check naming when not the noun provides the property given name: [See WWI 13.8 The built-in verbs and their meanings... and scrutinize the last paragraph]
    say "Sorry, that can't be named." instead.
    
Check naming when the number of words in the topic understood is greater than 1: [See WWI 20.3 Characters, words, punctuated words, unpunctuated words, lines, paragraphs]
    say "Sorry, please try a one-word name." instead.

Carry out naming something:
    now the given name of the noun is the substituted form of "[topic understood]" in sentence case. [See WWI 20.7 Making new text with text substitutions; see WWI 20.4 Upper and lower case letters]

Report naming:
    say "OK, now [the noun] is named '[given name of the noun].'"

Test me with "x puppy / x phil / name puppy Fuzzy / x phil / x fuzzy".

EDIT: Added citations for further reading to the above.

And if you want to use the new and old name in the same output:

The naming action has some text called old name. [See WWI 12.10 Action variables]

Setting action variables for naming:
    now old name is the substituted form of the printed name of the noun.

Report naming:
    say "OK, now [old name] is named '[given name of the noun].'"

or you could add a new property old name and transfer the contents of the new name to it in the carry out rule.

1 Like

Well, hmm. I should have made it clear that the very first thing I’m going to ask the player for-- before the game starts-- is a name. So a “naming” verb won’t be useful, as it will never actually get used in the game. Also, I really do want the thing named to be a backdrop everywhere. I just used “puppy” because the real deal is long and convoluted.

Thanks for the reply… I’m having a little trouble seeing how to apply this to my situation, where the player input happens before the start of the game.

Then the most important citation is WWI 17.15 Understanding things by their properties. The same basic principles apply.

Otis steered you right for how something that originated as user input could become an understood name by which the player could refer to it thereafter. It just needs to be hooked into an advance of game question instead of a command. Something like:

Before looking when the given name of the-backdrop is empty: instead do nothing.

Rule for printing the banner text when the given name of the-backdrop is empty: do nothing.

Rule for constructing the status line when the given name of the-backdrop is empty: do nothing.

the-backdrop is a privately-named backdrop. The description of the-backdrop is "The universal backdrop.".
the-backdrop is everywhere.
The printed name of the-backdrop is "[given name]".
the-backdrop has a text called given name.

Understand the given name property as describing the-backdrop.

When play begins:
   now the command prompt is "Name that background >".

After reading a command when the given name of the-backdrop is empty:
  if "[the player's command]" is not empty begin;
    now the given name of the-backdrop is the player's command;
    now the command prompt is ">";
    try looking;
  end if;
  reject the player's command;

OK. So this is I think what I was looking for.
Understand the given name property as describing Puppy

So I’ve modified to add this, but I’m having trouble adding another command prompt to choose a gender :

To decide whether collecting info: 
    if the command prompt is "What would you like to name a puppy? > ", yes; 
    no.

After reading a command when collecting info:
	if the number of words in the player's command is greater than 1:
		say "[paragraph break]How about just a first name? Let's keep it simple.";
		reject the player's command;
	now the given name of Puppy is the player's command;
	now the command prompt is "What gender is the puppy?[paragraph break]1.) female[line break]2.) male[line break]3. it[line break]]> ";
	reject the player's command.

Pronoun1 is a text that varies.
Pronoun2 is a text that varies.


Something can be maled or femaled or itted.

To decide whether collecting pronouns: 
    if the command prompt is "What gender is the puppy?[paragraph break]1.) female[line break]2.) male[line break]3. other[line break]]> ", yes; 
    no.

After reading a command when collecting pronouns:
	if the player's command matches "1":
		now Puppy is femaled;
		now pronoun1 is "she";
		now pronoun2 is "her";
	otherwise if the player's command matches "1":
		now Puppy is maled;
		now pronoun1 is "he";
		now pronoun2 is "him";
	otherwise if the player's command matches "3":
		now Puppy is itted;
		now pronoun1 is "it";
		now pronoun2 is "it";
	now the command prompt is ">";
	begingame;
    reject the player's command.

To begingame:
   say "[paragraph break][banner text]";
    move player to Room 1.

Instead of looking when collecting pronouns: do nothing.
Rule for printing the banner text when collecting pronouns: do nothing.
Rule for constructing the status line when collecting pronouns: do nothing.	
Instead of looking when collecting info: do nothing.
Rule for printing the banner text when collecting info: do nothing.
Rule for constructing the status line when collecting info: do nothing.

This just keeps asking the player for a pronoun in an endless loop. What am I missing here?

I gotta say, asking the player for input prior to the game is HARD. The order of everything gets all wonky.

And @otistdog , that was an incredibly useful page. I have made my life hard by not understanding and using properties.

I’d like to better understand what you mean by “prior to the game”.

My first thought was that you meant “prior to start of the Standard Rules action processing loop.” My second thought is that you mean “prior to announcement of the game title and provision of the starting text to the player.”

It looks like you mean both, but the former definition is harder to deal with. If you consider your goal as the only the latter, the situation gets a lot less difficult. You can have a before we get started scene or the like, which begins when the game begins and allows normal action processing with specialized actions like naming. This can be split into subscenes (e.g. naming Puppy) for each question, each of which changes the prompt and takes one special action. Then, when that string of scenes is complete (and therefore the parent before we get started is complete), you proceed to the normal game loop.

I’m not a scenes expert, but the basics aren’t too difficult. Statements like

Understand "name [something] [text]" as naming when naming Puppy is happening.

mean that the command >NAME PUPPY FUZZY would only be recognized during that opening scene. As far as the player is concerned, that command just wouldn’t exist in the main game.

That’s a tremendous idea. That sounds so much easier than the byzantine knots I’ve been tying. Gonna try that now.

When you have values that have to match, it’s good to assign them to some given variable (or constant, table entry, whatever) and then invoke that variable. You’ll often regret it if you don’t, 'cause if you modify it in one place and forget one of the other places you need to also modify it, things go wrong. (This is generic programming advice called DRY – don’t repeat yourself.) Your loop is infinite because collecting pronouns is never true, because the string it tests for is different from the one you assigned.

AHAHA. OK, assigned “gender” variable and now it’s working. Sheesh, that was painful.
My only problem now is that it’s not printing the room title of the first scene, but I bet I did something weird there.