Inform 7: changing the name of an object

[code]Dim Lit room is a room. “[if unvisited] This room is the most disturbing thing you have ever seen in your life. The thing that disturbs you is behind a glass wall.[otherwise] The room still disturbs you but the shock has worn off. The entire room is made of metal. The thing that disturbs you is behind a glass wall.”

A desk is here. the desk is a supporter. a page is a portable supporter on the desk. a paperweight is on the page. clear glass is part of the glass wall. the glass wall is a closed scenery door. the glass wall is east of Dim Lit room. the glass wall is west of the wall of horrors.

Instead of opening the glass wall, say “You can’t open the glass wall.”
The description of the paperweight is “A small red rock with a flat bottom.”
Rule for printing room description details of the desk: omit contents in listing.
The description of the glass wall is “A large wall made of glass, you dont want to say what you see on the other side.”

Instead of examining the page for the first time:
Say “The title of the page is Experiment data.”;
Now the printed name of the page is “Experiment Data page.”;
Now the description of the page is “which page?”;
The Experiment Data page is the page.

Check taking the page:
If a thing is on the page, say “You can’t take the page while [a random thing on the page] is on it.” instead.[/code]
Whats wrong with my code? Im trying to change the pages name to Experiment Data and make the page be Experiment Data when the player has examined it.

When you post these questions, it’s helpful to print what error or output you’re getting.

In this case, when I copy your code, I get an error message that looks pretty applicable:

What purpose is “The Experiment Data page is the page.” supposed to serve? It’s not going to do anything but throw an error now, because there is no experiment data page; all you’ve declared is the existence of a page.

When I take it out, the code appears to work as normal, although you might want to double check capitalization and punctuation:

Edit: Actually, even if there was an experiment data page, that phrase wouldn’t work, because they’re both objects. You couldn’t declare one the other any more than it would make sense to say “Now the horse is the car.” (And that would be the correct syntax within an if statement.) If page was a variable it would make sense, but it doesn’t look like you need a variable there.

I guess you want the player to be able to refer to the page as “experiment data page” once (s)he has examined it, but not before that.
You can do that with an understand statement:

Understand "experiment" and "data" as the page when we have examined the page.

I think there is a problem in this particular case, since an instead rule stops the action in failure, and Inform may therefore think we have not examined the page. So, I suggest you rather do something like this:

The description of the page is "The title of the page is Experiment Data."

Before examining the page for the first time:
	now the printed name of the page is "Experiment Data page".

After examining the page for the first time:
	now the description of the page is "Which page?"[I am not at all sure that this after rule is what you really want!!!]

Understand "experiment" and "data" as the page when we have examined the page.
1 Like

Felix hit it exactly.

Here’s a second option, though, which might come in handy if you plan to have lots of papers or other objects whose names change as the player learns more about them:

[code]A paper is a kind of supporter. A paper is always portable.
A paper has some indexed text called Title1.
A paper has some indexed text called Title2. [This allows two-word titles. It should be obvious how to expand it to allow longer ones…]

before printing the name of a paper (called p):
if Title1 of p is not empty, say "[Title1 of p] ";
if Title2 of p is not empty, say "[Title2 of p] ";

understand the Title1 property as describing a paper;
understand the Title2 property as describing a paper; [This lets the player refer to the paper by name, even if the title changes during play.]

a page is a paper on the desk.

instead of examining the page for the first time:
say “It’s titled [’]Experimental Data[’].”;
now title1 of page is “Experimental”;
now title2 of page is “Data”;
[/code]