Problem with BEGIN END stuff

Hello, something is happening that makes no sense. When I put conditions in text i.e. “[if player is in bed]xxxx[otherwise]vvvv[end if].” It works. But if I type this:

if player in bed begin;
say “XXX”;
end if.

Then it doesn’t work. WTF?

And how do I make stuff invisible when someone’s in a container in a room? Like a bed? I can stop the item showing up in the room description, but if the user examines it the item description pops up. I don’t want to make the bed into a seperate room… hence the above code attempts.

You left out “is” in your second piece of code. Put that in, and it should work.

if player is in bed begin; say "XXX"; end if.

I’m not exactly sure what effect you want to achieve here, but you could do something like:

Instead of doing something to the shoes while the player is in the bed: say "You can't see what's under the bed while you're in the bed."
Of course, you’ll still need your code to keep the shoes from showing up in the room description.

Well, I tried that code with the “is” and it still didn’t work. Your other suggestion should work, but I wish someone would tell me why my if code doesn’t work. Here is the exact code:

If the player is in the bed begin; Instead of examining the ink bottle, say "What are you talking about?"; end if.

Here is the error:

Problem. You wrote 'Instead of examining the ink bottle, say "What are you talking about?"' : but this is a phrase which I don't recognise, possibly because it is one you meant to define but never got round to, or because the wording is wrong (see the Phrasebook section of the Index to check). Alternatively, it may be that the text immediately previous to this was a definition whose ending, normally a full stop, is missing?

But that makes NO sense! I tried the “Instead” stuff on its own and IT WORKED!!

Edit: now that I’m here, is there some easier way of tagging a moment, or a container, so that no objects will be visible? For example, making the room dark if some condition is present?

Edit 2: I’ve thought of making the room dark then lighting the bed, but a) I want to print a description and b) I don’t want the game to say the bed is lit.

OK, I have the solution. But why don’t my ifs work?

Bridgette,

Hello!

“If (condition) then (do something)” is an example of a phrase in I7. It is not a complete legal command in and of itself. You must put it in some sort of context. Here is an example of a legal (but not good) way to do this:

Every turn: if the player is in bed, say "This bed is comfortable!".

You can’t just use “if” on its own, just like you can’t have “now the player is in bed” without telling inform when you want that to happen. The language isn’t like, for example, BASIC, where the commands just get executed in order. The advantage is that in most cases, the order in which blocks of code are written doesn’t matter. I hope that makes sense.

Skinny Mike

No, that didn’t work. Thanks anyway though.

Every turn:
While player is in bed begin;
instead of examining say "What are you talking about?";
end while.

I don’t get it. I copy pasted this from the manual:

Rule for printing room description details: stop.

But it still prints it. It didn’t give an error.

The problem is that your code is inside out. “Instead of…” is the beginning of a rule, and you can’t put a rule inside an if block (in fact, you can’t put a rule inside anything). “If…”, on the other hand, being a phrase, can’t stand alone; it has to go inside a rule or some other kind of block of code.

So what you actually need to do is:

Instead of examining the ink bottle: if the player is in the bed begin; say "What are you talking about?"; end if.

You can make it simpler by doing this instead:

Instead of examining the ink bottle when the player is in the bed: say "What are you talking about?".

Thanks. It was disturbing that it kept not working, and frustrating. I spent literally 7 hours today learning I7, I’m almost competent.

What about this not working? It’s exactly word for word like it is in the documentation.

Rule for printing room description details: stop.

You are probably using it for something it’s not designed to do. “Printing room description details” only controls text like “(empty)” or “(in which is a pen)” - the item is still listed in the room description. If you want things not to be listed in the room description at all, you’d have to use something like:

Rule for listing nondescript items: stop.

To have this happen only when the player is in bed:

Rule for listing nondescript items when the player is in the bed: stop.

Or, to just hide one thing:

Before listing nondescript items when the player is in the bed: now the ink bottle is not marked for listing.

Bridgette,

Oops, that was a bad example. The code I posted does work, just not in a way that would be useful for your stated purpose. (Every turn rules fire at the end of each turn.) Sorry about that. Emerald’s explanation and code are much better.

The only thing I want to add is that your confusion about phrases is not uncommon. One thing to keep in mind, in the documentation, snippets of code which are just phrases are not capitalized, while commands which can stand on there own generally are. For example:

The Lab is a room.
Temperature is a number that varies.
Instead of eating the fish:
say “Gross.”.

are okay by themselves, while phrases like:

say “Boo.”
if the boat is sinking…
move the player…
let t be the temperature.

(not capitalized) are not. This is just a convention of the docs, which I don’t believe is explicitly mentioned. In your actual code, capitalization doesn’t matter (in almost all cases) and you are free to do as you please. It’s just helpful when you racking your brains trying to figure out why certain syntax seems to work sometimes and not others.

Skinny Mike

Wow, y’all are so helpful. Thanks Emerald, now I feel like superman.

Now all I have to do is learn how to write good prose.

Edit: I figured it out, but it’s dumb. I had to do this:

[code]Before listing nondescript items when player is in bed:
change ink to not marked for listing.

Before listing nondescript items when player is in bedroom:
say “An ink bottle with a pen in it sits on a stack of books.”;
change ink to not marked for listing.[/code]

I was trying to do this:

[code]
Before listing nondescript items when player is in bed:
change ink to not marked for listing.

The ink bottle is in the bedroom. “An ink bottle with a pen in it sits on a stack of books.” The description is…[/code]

Seems like a bug.

Okay, the problem here is that because of “An ink bottle with a pen in it sits on a stack of books.”, the ink bottle doesn’t count as a nondescript item. You’re going to have to use the “writing a paragraph about” activity instead.

This is probably the best way to do it:

[code]The ink bottle is in the bedroom. The description is “…”

Rule for writing a paragraph about the ink bottle:
if the player is not in the bed,
say “An ink bottle with a pen in it sits on a stack of books.”[/code]