Beginning a scene when a value reaches x. drinking...

I’m having a rough time creating a mechanism for getting drunk. What am i doing wrong here? drinking a beer increments “drinks”, which is a value of DrinksDrunk. The idea is that when the player has had 6 drinks, a scene begins (he goes to the hospital). I would like the number of drinks to trigger other events as well (such as ‘falling off your bike’), but i’m getting a runtime error:
[i]>drink beer
mmm beer.

*** Run-time problem P59: You can’t implicitly repeat through the values of this kind: a problem arising from a description which started out here - “Passing out begins when The number of drinks is greater than 3”.[/i]

here’s the code in question:

Sodapop is a kind of thing.
beer is a kind of thing.

10 beers are in the Stairwell.

Understand “drink [something]” as drinking.

DrinksDrunk is a kind of thing. It has a number called drinks. The drinks of a DrinksDrunk is usually 0.

Things have a number called point value. The point value of a thing is usually 0.
Beer has a point value 1.
Sodapop has a point value 0.

Instead of drinking:
now the noun is nowhere;
if the point value of the noun is 0, say “[printed name] means nothing to you” instead;
if the point value of the noun is 1, say “mmm beer.” instead;
increment drinks;

Passing out is a scene.

Passing out begins when
The number of drinks is greater than 3.

when passing out begins:
say “Yay! You are super winner!”;
move player to Hospital.

Could you wrap your code in code tags so we can see the indentation?

However, a more usual way to do this would be:

drinks-drunk is a number that varies. drinks-drunk is 0.

A thing can be alcoholic. A thing is usually not alcoholic.

Instead of drinking something alcoholic:
  say "You down [the noun].";
  now the noun is nowhere;
  increment drinks-drunk.

passing out is a scene. Passing out begins when drinks-drunk is greater than three.

I would use Sequitur’s code. However, in your own code, the phrase

The number of drinks is greater than 3.

doesn’t really mean anything to Inform. The number you are trying to assess is called “the drinks of DrinkDrunk”, not “the number of drink.”

Also, that instead rule is going to allow the player to drink and thereby absolutely anything – including herself, which would lead to a run-time error.

Thanks so much for that sequitur!

in the interim i’d set up a system using the scoring system, but this is much better. now i’ve got the drinks-drunk system working nicely, including avoiding the drinking of things like mittens (see below). My next task is to see if i can make “drink all the beer”, “drink 6 beers”, etc., work. As it stands, the parser responds with: You can’t use multiple objects with that verb. can i create a new action? ala:

Understand “drink the beers” as multiply-drinking . Multiply-drinking is an action applying to all visible beers.

i know there’s something missing here. Again, much apreesh for the help!

the code:

a thing can be drinkable.
A thing is usually not drinkable.

sodapop is a kind of thing.
beer is a kind of thing.

sodapop is drinkable.
beer is drinkable.

A thing can be alcoholic. A thing is usually not alcoholic.
beer is alcoholic.

3 sodapops are in the kitchen.
13 beers are in the kitchen.
20 beers are in the VFW.
6 beers are in your house.

Empty bottle is an object.
There are 100 empty bottles.

Understand “drink [something]” as drinking.

[Understand “drink the beers” as multiply-drinking . Multiply-drinking is an action applying to all visible things.]

Instead of drinking something not drinkable:
say “You obviously can’t drink [the noun]”

Instead of drinking something not alcoholic:
say “You drink [the noun]. [The noun] means nothing to you”;
now empty bottle is in the location of the noun;
now the noun is nowhere;
rule succeeds.

drinks-drunk is a number that varies. drinks-drunk is 0.

Instead of drinking something alcoholic:
now empty bottle is in the location of the noun;
now the noun is nowhere;
If drinks-drunk is 0:
say “Mmm, you needed that.”;
If drinks-drunk is 1:
say “Sudsy, you feel steadied.”;
If drinks-drunk is 2:
say “It makes you feel warm and safe inside.”;
If drinks-drunk is 3:
say “Mmm, you love this beer.”;
If drinks-drunk is 4:
say “Let’s make it a nice day.”;
If drinks-drunk is 5:
say “Anything could happen today!”;
If drinks-drunk is 6:
say “Beer is great.”;
If drinks-drunk is 7:
say “Really smoothing out this hangover.”;
If drinks-drunk is 8:
say “Great god, Dionysus, in thy name I do drink this beer.”;
If drinks-drunk is 9:
say “So thrilling.”;
If drinks-drunk is 10:
say “I AM Dionysus.”;
If drinks-drunk is 11:
say “I should find someone to have sex with.”;
If drinks-drunk is 12:
say “Let’s do drugs!”;
increment drinks-drunk.

[PASSING OUT]
passing out is a scene. Passing out begins when drinks-drunk is greater than 12.

when passing out begins:
say “At some point, you lost consciousness. Hard to say what happened exactly, but now you’re in the hospital.”;
move player to Hospital.

sorry i left the tabs out in all those block. they’re there.

If you want the tabs to show up, use the code tags. You can either press the “code” button above the box where you type the text (if you use “Full Editor” mode) or you can type {code} and {/code} by hand–except replace the {} with [].

Anyway, if you want an action to be able to apply to multiple objects you have to put in an understand line with [things] instead of something, like this:

Understand "drink [things]" as drinking.

This will yield an output something like this:

That is, for each thing on the list of things to be drunk, it executes a separate drinking action. This is the behavior that you get for something like the taking action (which has an understand line like “take [things]” in the Standard Rules); if you type “take all” then it executes a separate taking action for everything in sight. (Everything not excluded from “all,” but that’s another story.)

If you want to wrap this all up in one thing… that’s complicated. Basically you would have to access the “multiple object list,” which is the list of the things the player specified (e.g., a list of six beers), and do something with it, and you’d also have to make sure that you only executed the appropriate action once per turn. There’s an example called “The Facts Where These” in the documents (I think) that does this for buying, and one called “The Left Hand of Autumn” that does it for examining I think.

But it sounds like, for your purposes, the ordinary behavior with a “drink [things]” line might work. You’d probably want to write something that ensured that the player couldn’t drink any more after passing out, as a command like “drink everything” might well enable the player to exceed the drunk score before the scene-changing mechanics had a chance to work.

By the way you can make that if statement much less unwieldy by using a switch statement:

if drinks-drunk is: -- 1: say "this message"; -- 2: say "that message"; -- 3: say "'the other message" [and so on]

This even allows for an “otherwise” and I think it might allow for “> 12:” but I’m not sure about that one.

the drink [things] method works well. i added some teletype from erik temple’s extension so there’s some delay while those multiple beers get chugged.

i’ll make that a switch statement, thanks matt.

now that i have a ‘drinks-drunk’ value, i’m looking forward to modeling some more complex physical/emotional states - withdrawl, euphoria, general idiocy. eventually i’ll get to an actual story.

This is what tables are for, I think. Despite the rather clunky code, it becomes a lot more compact.

[code]“Twelve Days of Drinking”

A beer is a kind of thing.
14 beers are in the Bierstube.
Yourself can be shitfaced.

Instead of drinking a beer (called the booze):
choose row (first non-blank entry in Table of Mazlov’s Hierarchy of Beers) in the Table of Mazlov’s Hierarchy of Beers;
say the message entry;
say line break;
blank out the whole row;
now the booze is off-stage;
if the Table of Mazlov’s Hierarchy of Beers is entirely empty, now the player is shitfaced.

Instead of drinking a beer when the player is shitfaced, end the story saying “You collapse into a beer-filled stupor.”

To decide which number is the first non-blank entry in/of (x - a table name): decide on the number of blank rows in x plus one.
To decide whether (x - a table name) is entirely empty: decide on whether or not the number of blank rows in x is the number of rows in x.

Table of Mazlov’s Hierarchy of Beers
message (text)
“Mmm, you needed that.”
“Sudsy, you feel steadied.”
“It makes you feel warm and safe inside.”
“Mmm, you love this beer.”
“Let’s make it a nice day.”
“Anything could happen today!”
“Beer is great.”
“Really smoothing out this hangover.”
“Great god, Dionysus, in thy name I do drink this beer.”
“So thrilling.”
“I AM Dionysus.”
“I should find someone to have sex with.”
“Let’s do drugs!”

Bierstube is a room.[/code]