Darkness.....

Hello,

I have recently started playing around with Inform7 and i must say its great! I have now 2 problems for my test fiction that i’d like to resolve but couldn’t find a solution by myself, so i’m here asking for your help :smiley: .

  1. I’d like to make the game darkness hazardous, in a manner that when walking around in the dark you have like 1 out of 2 chances to die and customize the death message.

  2. I’d like to implement a timed lantern based on turns and have the object oil (that can be stored in a jug for example) to refill it. I currently found a tutorial and did this: but it didn’t work. (Maybe also adding other messages like at 50 power and at 20 power).

A Lantern is here. The Lantern is a device. The lantern is switched off.

After switching on the lantern:
    now the lantern is lit;
    continue the action.

After switching off the lantern:
    now the lantern is unlit;
    continue the action.

The lantern has a number called the power. The power of the lantern is 100.

Every turn when the lantern is lit:
    now the power of the lantern is the power of the lantern – 1;
    if the power of the lantern < 1
        say “Your lantern slowly dies...”;
        now the lantern is unlit.

Thanks in advance! This is my first post btw, hope that will be the beginning of a nice journey :slight_smile:

That last bit looks like it’s from Carolyn’s “Adventure” tutorial. If you haven’t worked through that I recommend it, it’s a good introduction to I7.

What specifically isn’t working for you?

It gives me these problems, all associated with the power lantern thing. The hazardous darkness i still didn’t found an answer. If i remove the power part the game compiles correctly.
Schermata 2015-01-26 alle 17.35.36.png

Looks like you forgot one colon. It compiles this way:

Every turn when the lantern is lit:
	now the power of the lantern is the power of the lantern – 1;
	if the power of the lantern < 1:
		say “Your lantern slowly dies...”;
		now the lantern is unlit.

Note that this leaves the lantern unlit but still switched on. The player can also continue switching the lantern on; it dies immediately, but it makes the power go negative.

I tried copying your code but it still gives me these problems…

Also I found the dark terminus count code used in zork which goes:

[code]Rule for printing the description of a dark room: say “It is pitch black. You are likely to be eaten by a grue.” instead.
Rule for printing a refusal to act in the dark: say “It is too dark in here to see.” instead.
The going action has a number called the dark terminus count.
Setting action variables for going:
now the dark terminus count is 0;
if in darkness, increase the dark terminus count by 1.
The last carry out going rule:
if in darkness, increase the dark terminus count by 1.
After going:
if the dark terminus count is 2, set off the grues instead;

To set off the grues:
say “Oh no! You walked directly into the slavering fangs of a lurking grue!”;
end the story.[/code]

Prolem is, when i compile it does exactly what I want, which is nice, but when i walk around it just changes the room on the status bar without giving a description. If i use Look then it describe the room as it should but when i go around it doesnt describe anything.
Schermata 2015-01-26 alle 18.22.29.png

Hi bonsaycow,

Just compiled this myself and it’s compiling just fine. Doublecheck?

[code]A Lantern is here. The Lantern is a device. The lantern is switched off.

After switching on the lantern:
now the lantern is lit;
continue the action.

After switching off the lantern:
now the lantern is unlit;
continue the action.

The lantern has a number called the power. The power of the lantern is 100.

Every turn when the lantern is lit:
now the power of the lantern is the power of the lantern – 1;
if the power of the lantern < 1:
say “Your lantern slowly dies…”;
now the lantern is unlit.[/code]

Ooooh, I just realized I missed the very first line… didn’t tell that power is a number… Many thanks for the help! Do you know how to fix the problem I have with the Dark Terminus counter?

I haven’t tested it, but you’ve got an “instead” in an “after going” rule. This short-circuits the normal “look after going” behavior.

Oh I see, I changed that so that it was After looking, not going, so that it works the same but only after the automatic looking that follows the going action. Thanks to everyone!

Just for completeness’ sake, the problem wasn’t the “instead” in the After going rule–the line with “instead” in it only fires if the dark terminus count is 2. The problem was that After rules block the Report rulebook from running unless they include “continue the action” (technically this is because the after rulebook has “default outcome success”; see §19.11 of Writing with Inform). And this After rule runs after every going action, since its header is just “After going.”

So another way to fix things would be to move the condition to the header of the rule:

After going when the dark terminus count is 2: set off the grues.

Now this rule will only “fire” when the dark terminus count is 2; otherwise the rule will be skipped, so it won’t block the Report rules from running.