The Foxaroo tinkering around with Inform7

I’m adding an achievement for the first player who uses a light source in a dark room. What condition(s) would work to trigger this?

I’ve tried “After looking in a dark room”, but that fails to determine if the player has the light source turned on.

I want to avoid a condition triggered by the player simply turning on the light, because they might do so before they are in a dark location. Also, they may not have realised that the object is intended to help them see in the dark, and receiving an achievement might give that away.

The key bits here are that if in darkness tests whether the player has light to see by and if the location is dark tests whether the location is dark by default, not whether there’s light to see by at the moment. So, something like this…

used light achievement is initially false.

after doing anything when used light achievement is false and not in darkness and location is a dark room: now used light achievement is true;
say "let there be light.";
continue the action;

Naturally this would have to be adjusted if some other action than the one you want to recognize as an achievement could end up creating light as a side effect.

Thanks Zed, it worked.

With your help I’ve been able to cover myself in two ways:
(See the posts above for my system of awarding achievements)

  1. When the player moves into a dark location while carrying a light source
After going somewhere:
	If the location of the player is dark and the player carries a lit object:
		Award Achievement "LIGHT";
	continue the action.
  1. When the player turns on their light source after moving to a dark location
Carry out energising:
	now the noun is lit;
	say "The [noun] now is lit.[Paragraph break]";
	if the player is in a dark room:
		Award Achievement "LIGHT".

isn’t this a case you said you didn’t want to reward, though? them having turned it on elsewhere?

Correct. I didn’t want the achievement awarded if the player simply turned on the light source when they were not in a dark location. Hence my code includes “if the player is in a dark room”.

I’ve tested both approaches and they each work as desired.

My game debuted during the work social yesterday, but (as often happens when the designer and player are different people) they typed a command in an unexpected way and it revealed a bug.

My code stands as:

After going north from XYZ Accounting Department:
	Hide the White Door;
	Say "The door vanishes behind you, and you are transported to a time long ago, in a galaxy far away.";
	Award Achievement "BREACH";
	Continue the action.

Most unfortunately, the first player who picked a door instead typed “Walk through the white door”. This didn’t worry me because I expected the code to work nonetheless, but to my surprise it failed to trigger. The player moved to the next location as expected, but all of the above lines failed to execute. Then of course the other three players mimicked the command and the code for each of their doors failed as well.

Now I’m trying to figure out the syntax for creating rules that will work for “Walk through {the particular door}”, and so far Inform has rejected all of my attempts.

The below attempt below resulted in a run time overflow error:

Instead of going through the white door:
	[Etc]

I also tried a different tactic and changed the original line to:

Before entering Science Fiction Realm:
	[Etc]

This failed to trigger at all; whether “Go north” was used or “Walk through white door”.

Any advice?

When you type “ACTIONS” while testing in the IDE, you can see which actions are triggered by your commands.

In this case, “N” will lead to “going north”, while “WALK THROUGH DOOR” and “ENTER DOOR” will lead to “going the door”.

So, you can cover that action by adding a rule for “After going the white door […]”, not “After going through the white door […]”. (EDITED to insert: But the syntax “going through the door” does actually work, too, as @Draconis explains in the next post below.)

After going north from XYZ Accounting Department:
	say "The door vanishes behind you, and you are transported to a time long ago, in a galaxy far away.";
	continue the action;

After going the white door from XYZ Accounting Department:
	say "The door vanishes behind you, and you are transported to a time long ago, in a galaxy far away.";
	continue the action;

Or we might like to avoid the code repetition here, because of course we’d have to keep it in sync now. So, this should also work:

After going north from XYZ Accounting Department:
	say "The door vanishes behind you, and you are transported to a time long ago, in a galaxy far away.";
	continue the action;

Check going the white door from XYZ Accounting Department:
	try going north instead.
1 Like

As StJohnLimbo says, the possible actions here include “entering the white door” (which becomes “going the white door”), as well as “going north”.

Whichever of these the player types, the action becomes “going”, and a suite of action variables are set to the various objects involved in going. These are the objects you can test with “from”, “to”, “through”, “by”, “with”, and so on. (Okay, actually just those five.)

However, the noun is left unchanged. So the best solution is to test those variables instead of the noun:

After going through the white door from the XYZ Accounting Department:

Because “through” and “from” should always be accurate, no matter what the noun ends up being. (Similarly “to” for the destination, “by” for the vehicle, and “with” for anything you’re pushing ahead of you.)

1 Like

Thanks, that’s indeed better!

It’s weird, because I could’ve sworn I tried the “going through” variant and it didn’t seem to trigger, but I must’ve inadvertently done something else at that time.

Much appreciated StJohnLimbo and Draconis,

I’ve re-worded the rules as suggested and tested them with the four types of commands (each one I could think of), and they all triggered correctly.

I really need to use the Actions command more often. Thanks for the prompt.

XYZ Game Skein

I’m very glad to have people who are still interested in the art of Interactive Fiction. The game session at work proved hilarious for all the wrong reasons. It went for 90 minutes (30 longer than planned) and they only managed to solve 1 puzzle (with a teensy bit of prompting from me). They were trying commands like “Feed cake to [player]” when there isn’t any cake in the game, and “Goes into kitchen” - that’s how they typed it. Two of the characters spent several turns typing “Hug [player]”. I didn’t even know ‘Hug’ was set up in Inform.

I started to feel depressed though when one of them said that he didn’t know what the word ‘Expedience’ meant. I suspect the number of words in the average person’s vocabulary has taken a sharp downturn in this age of excessive CGI, YouTube, and phone zombies… :frowning:

1 Like