I need help with some code.

Hey I need help with some code. What i want is when a player enters a room called “Drain Pipe” I want them to be killed but I don’t know how to kill a player when they enter a room or do a specific action. Also does anyone have any kind of puzzle that they can give me an example of as well as an example of a door with a lock?

~Thanks~

Section 11.6 of the Recipe Book has extensive treatment on endings and death. What you want looks something like this:

After entering Drain Pipe: say "The current here is calm enough that you're able to tread water. Unfortunately, it is immediately downstream from the peanut-butter factory, and you are deathly allergic."; end the story saying "You have died";
But you might not want an ‘after’ rule, since that will do all the normal behaviour first: you might prefer an Instead rule, like this specific-action example:

Instead of jumping when the current scene is Dance Contest and the dramatic intensity is 11: say "You attempt a dynamic split-pike-to-somersault. But when you are meant to be crunking, this level of gymnastic precision looks aloof and pedantic. Also you flub the landing and do your knee a mischief. The chorus of disapproval mounts, and cannot be quelled."; end the story saying "You will never live this down";

You wrote ‘After entering Drain Pipe’ , which seems to introduce a rule taking effect only if the action is ‘entering Drain Pipe’. But that did not make sense as a description of an action. I am unable to place this rule into any rulebook.

It gave me that message but i don’t understand it :confused:

Ah, yes, apologies. That’s because Drain Pipe is a room, not an enterable object. It should be ‘after going to Drain Pipe’.

Problem. In ‘After going to Drain Pipe’ , I tried to read a description of an action - a complicated one involving optional clauses; but ‘Drain Pipe’ wasn’t something I recognised.

See the manual: 12.10 > Action variables


Problem. In the sentence ‘After going to Drain Pipe’ , ‘Drain Pipe’ seems to be intended as something the player might be going to, but it doesn’t make sense in that context.

See the manual: 7.14 > Going by, going through, going with


Problem. You wrote ‘After going to Drain Pipe’ , which seems to introduce a rule taking effect only if the action is ‘going to Drain Pipe’. But that did not make sense as a description of an action. I am unable to place this rule into any rulebook.

See the manual: 7.1 > Actions

It gave me more then before :confused:

That should work. Can you post the relevant section of your code so that we can see what the problem is?

(In general, posting the code is much more helpful than posting the error messages. My best guess is that you haven’t defined Drain Pipe yet, and you need to move the after-going code to after you’ve defined Drain Pipe.)

[code]

Drainpipe is below bathroom.

After going to Drain Pipe:
say “How did you even… What Anyway that was a really stupid idea.”;
end the story saying “You have died”;[/code]

Thats all the code i have that relates to drainpipe.

Spell check. You wrote Drain Pipe and Drainpipe. Those are two different objects for Inform.

Aha "-_- Whoops

funny how the little things get ya. inform is really picky :stuck_out_tongue: gl with your project.

To be fair, I don’t know of any programming language that will ignore whitespace in the middle of variable names. :slight_smile: