I7: Slightly Better Time Machine

Hello again,

My apologies if this is a rather simple question. I created a new action called “tune the [something]” that was to simulate some kind of time traveling phenomenon. All it did was, in the carry out section of the action, just move the player from one room to another. The route was static or sequential, that is, it would always move the player from room A, to B, to C, to D, and then finally back to A. I got it to work.

Next, I wanted to make something slightly more sophisticated, and allow the user to decide on where to go by modifying the action to accept a second parameter … some number. For example, “tune the [something] to 1” would move the user to room A. “tune the [something] to 2” would move the user to room B, and so on.

So I tried to modify my original action into the following:

Tuning is an action applying to two things.
Understand "tune the [something] to [something]" as Tuning.
[e.g "tune the dial to 3" - to go to the moon]
Check tuning:
	if the noun is not the dial, say "That's not really something you can tune." instead.
	if the second noun is a not a number, say "That's not even valid!" instead.

Carry out tuning:
	if the time machine is in the Lab:
		move the time machine to On top of a Train;
	otherwise if the time machine is in On top of a Train:
		move the time machine to On the Moon;
	otherwise if the time machine is in On the moon:
		move the time machine to Land of the Lost;
	otherwise if the time machine is in Land of the Lost:
		move the time machine to the Lab;

Report tuning:
	say "You tune the dial carefully to the next crudely written mark.";
	try looking;

Problem seems to arrive at line 6,

if the second noun is a not a number, say "That's not even valid!" instead.

which I suspect is a result of my less than perfect understanding of how to handle two parameters. Or perhaps a less than perfect understanding on how to properly form conditions. Or both. I’ve consulted Chapter 7, section 10 regarding first and second noun but that does not really seem to clear things up.

Any help or pointing to the relevant documentation would be helpful.

Hi,

See Chapter 16.6. Actions applying to kinds of value, as well as the example there, “Saftey.”

One thing you need to look out for is the wording of the action. When using two nouns (regardless if whether or not one is a kind of value) you need to add a placeholder in the definition of the action for inform to properly understand your rules. For example “tuning is an action applying to one thing and one number” won’t cut it; you need something like “tuning it to is an action…” The “it to” tells inform how you want to word your rules so you can code something like “Instead of tuning the radio to 123: …” Also, if you need to refer to the value, you use " understood" where is whatever kind of value you’re using (such as “number understood” in this case). Here’s a very stripped down example:[code]Lab is a room. The time machine is in the lab.

Tuning it to is an action applying to one thing and one number.
Understand “tune [something] to [a number]” as tuning it to.

Report tuning it to:
say “You tune [the noun] to [the number understood].”[/code]

Hi Skinny Mike,

Thank you for pointing me in the right direction, the example was helpful both in style and syntax. I got the action to work, and in case anyone is interested here is my solution. It is a bit verbose.

Tuning it to is an action applying to one thing and one number.
Understand "tune the [something] to [a number]" as Tuning it to.
Check tuning:
	if the noun is not the dial, say "[the noun] is something you can tune." instead;
	if the player is not in the time machine, 
		say "Maybe you should enter the time machine first?" instead;
		
Report tuning:
	say "You tune [the noun] carefully to [the number understood].";

After tuning the dial to 1:
	say "A magical mist surrounds you and suddenly transports you to ...";
	move the time machine to the Lab;
	try looking;

After tuning the dial to 2:
	say "A magical mist surrounds you and suddenly transports you to ...";
	move the time machine to On top of a Train;
	try looking;

After tuning the dial to 3:
	say "A magical mist surrounds you and suddenly transports you to ...";
	move the time machine to On the Moon;
	try looking;

After tuning the dial to 4:
	say "A magical mist surrounds you and suddenly transports you to ...";
	move the time machine to Land of the Lost;
	try looking;

Instead of tuning the dial to a number greater than 4:
	say "That's not a valid number!";

Instead of tuning the dial to a number less than 1:
	say "That's not a valid number!";

It seems like it can be shortened somehow or more “elegantly” put together, but for now I am just happy I can even get it to work, at all.

Just a side note: it’s not advisable to write the word “the” in an action’s grammar. It would mean that the players must use “the” in their commands: commanding something like TUNE DIAL TO 1 would give a rather confusing and unhelpful error message. The parser will automatically disregard articles in the commands, so if you write ‘Understand “tune [something] to [a number]” as tuning it to’ the game will understand TUNE DIAL, TUNE THE DIAL and TUNE A DIAL all the same.

Thanks for the heads up Nitku,

Hmm, I think I did read about the parser automatically stripping articles of definition. It sounds rather familiar. I shall keep that in mind when I write future actions.

FYI, the ‘After’ part of the code could be streamlined like this.

After tuning the dial: say "A magical mist surrounds you and suddenly transports you to ..."; if the number understood is: -- 1: move the time machine to the Lab; -- 2: move the time machine to On top of a Train; -- 3: move the time machine to On the Moon; -- 4: move the time machine to Land of the Lost; try looking;