Settable machines?

I’m trying to make a settable machine and having some issues figuring out how to do it.

Climate is a kind of value. The climates are sun, rain, snow, and fog. The climate is sun.

The weather machine is in the workstation. The description of the weather machine is "The weather machine says that the weather is currently set to  [default value of climate]. Certain weathers can keep you hidden. You can set the machine to produce anything; just say SET MACHINE TO ..." 

Xetting it to is an action applying to two things. Understand "set [something] to [something]" as xetting it to.

First, I am using xetting as a placeholder verb because I am not quite sure how to override setting with understand the command X as something new.

Second, I am unsure how to make it so that a player can type “set the weather machine to …” and insert any text they want at the end. As I understand it something applies to objects in the game; I’m trying to make it so that the climate value can be set to anything.

In the IDE, if you go to Index tab and then click Actions, there’s a list of standard actions, including “setting it to.” If you click the magnifying glass next to that action, you can see more information about it:

The Standard Rules define this action in only a minimal way, blocking it with a check rule which stops it in all cases. It exists so that before or instead rules can be written to make it do interesting things in special cases. (Or to reconstruct the action as something more substantial, unlist the block rule and supply carry out and report rules, together perhaps with some further check rules.)


Typed commands leading to this action

“set/adjust [something] to [text]”

Rules controlling this action

check an actor setting something to block setting it to rule name unlist 1

I think the first thing I’d do is click the “unlist” icon to unlist the rule that blocks the action. I believe the action is, by default, set up to let you type any text you want at the end (hence the [text] in the typed command leading to the action).

Thanks, I am now able to have the story not reject the command.

Does this approach set a value or variable that I can access directly? For example, something along the lines of

say [the setting of the weather machine]

Or do I have to parse the player’s input (as seen in this chapter) and set my own value to that input?

I have searched the manual a few times but I can’t find anything relevant.

While you could use setting and compare the text input of the player to the weathers, another way is to make a new action as you have and set it to take a kind of value and specify the weather value.

"Weather Machine"

The lab is a room.

Weather is a kind of value. The Weathers are Rain, Sun, Snow.

The weather machine is here. The weather machine has a weather called set to weather. The description of the weather machine is "[set to weather of the weather machine]".

Xetting it to is an action applying to one thing and one value.

Understand "Xet [something] to [weather]" as Xetting it to.

Carry out Xetting the Weather machine to a weather(called the weather selected):
	now the set to weather of the weather machine is the weather selected.

Is there a specific square bracket phrase that returns the player’s text?

Edit: I did not see the part that was cut off by the scrollbar.

I’ve decided to go with an alternative approach, with various settable switches


The weather machine is here. The description of the weather machine is "This machine controls the weather. Some weathers are better for hiding than others. To choose a weather, type TURN ON/OFF (WEATHER) SWITCH."
The sun switch is a device that is part of the weather machine.
The rain switch is a device that is part of the weather machine.
The wind switch is a device that is part of the weather machine.
The fog switch is a device that is part of the weather machine.
The snow switch is a device that is part of the weather machine.

Is there any way to make it so that the command x switch does not display these names? That is, by blocking this rule in the relevant room?

parser clarification internal rule response (B): "Which do you mean, "

What do you want displayed instead? In that situation the player probably would benefit from a disambiguation prompt rather than not getting any feedback, I’d think. If that’s the case, the easiest thing would just be to assign a printed name to each switch reflecting what you’d like the player to see.

I’m trying to build a puzzle around it, so ideally those options are something they would have to gather.

Or I could just leave in the disambiguation prompt and consider it an easier puzzle.

You could give each switch a printed name that doesn’t give away what it does: first switch, second switch…switch 1, switch 2…blue switch, green switch… Optionally, once the player does something to identify the switch, you could change it to display “rain switch” instead of “blue switch” or whatever.

Or, do you not want the switches to be visible at all? Or do you want a response that describes all the switches, instead of just one? I’m not sure exactly what you want to happen when the player types “x switch.”

Going back to the original idea, using the SET command and a topic: the simplest way is like this:

Climate is a kind of value. The climates are sun, rain, snow, and fog.

The weather machine is in the Workstation.
The weather machine has a climate.

The description of the weather machine is "The weather machine says that the weather is currently set to [climate of weather machine]." 


Check setting the weather machine to:
	if the topic understood matches "[climate]":
		now the climate of the weather machine is the climate understood;
		instead say "You set the weather machine to [climate of weather machine].";
	else:
		instead say "That isn't a setting.";

The SET command is already defined to accept any text. That’s because the Standard Rules define it this way:

Understand "set [something] to [text]" as setting it to.

The value arrives as the topic understood variable. (“Topic” is a little bit confusing, but it generally means a free text input that can be matched.)

This line is the magic:

if the topic understood matches "[climate]":

This checks topic understood against a matching token which is any climate value. It sets climate understood if successful.

By the way, your original code had the line “The climate is sun.” That doesn’t actually do anything. Climate is a kind of value, not a value; there is no the climate. In my example, I’ve deleted that line and given the weather machine a climate property.

@zarf That is definitely what I was aiming for initially. How exactly do I trigger different outcomes based on the setting though? I’ve tried something like:

Check setting the weather machine to:
	if the topic understood matches "[climate]":
		now the climate of the weather machine is the climate understood;
		instead say "You set the weather machine to [climate of weather machine].";
	else if the topic understood matches "fog":
		say "It's foggy.";
		increase the score by 1;
	else:
		instead say "That isn't a setting.".

But the …matches fog part does not seem to work. I am not surprised it is wrong but I am not sure where to look.

This line

now the climate of the weather machine is the climate understood;

sets the variable “climate of the weather machine” to be whichever climate value the player just typed. So now you can test “climate of the weather machine.”

So you could do something like this:

The block setting it to rule is not listed in the check setting it to rulebook.

Check setting to:
	if the noun is not the weather machine:
		say "[The noun] [aren't] something you can set." instead.
		
Check setting the weather machine to:
	if the topic understood matches "[climate]":
		now the climate of the weather machine is the climate understood;
		say "You set the weather machine to [climate of weather machine].";
	else:
		instead say "That isn't a setting.".
		
Carry out setting the weather machine to:
	if the climate of the weather machine is snow:
		say "It begins snowing.";
	else if the climate of the weather machine is rain:
		say "It begins raining.";

(and so on)

Edit:

I suspect the reason

else if the topic understood matches "fog":

in your code doesn’t seem to work, is that that line of code is never reached. If the topic understood does happen to match “fog,” then it will also match “[climate]” in this earlier line, because “fog” is a valid climate setting:

if the topic understood matches "[climate]":

and any code after this line

instead say "You set the weather machine to [climate of weather machine].";

will never run, because “instead” stops the action.

Thanks, that is another piece toward a working solution. How would you combine this with the “for the first time” so that this is only done the first time the player types that in:

say "It begins snowing.";
decrease the score by 1;

Is it even possible with check/carry out? I am only familiar with for the first time in relation to instead.

You mean if the player types “set machine to snow” twice in a row, or something like that? You could add a check to see if the machine is already set to that:

Check setting the weather machine to:
	if the topic understood matches "[climate]":
		if the climate of the weather machine is the climate understood:
			say "The machine is already set to [climate of the weather machine]." instead;
		now the climate of the weather machine is the climate understood;
		say "You set the weather machine to [climate of weather machine].";
	else:
		instead say "That isn't a setting.".

I’m trying to prevent the player from choosing the same setting twice over the entire game (due to the the scoring part).

Your solution would allow player to enter a different setting, then go back and trigger the first setting again, if I understand it correctly?

I suppose I could add settings to a list once they are entered and check the new entry against that. (as in chapter 21 of the docs. )

Right.

That makes sense to me. Something like this, maybe?

The weather machine has a list of climates called completed-climates.
		
Check setting the weather machine to:
	if the topic understood matches "[climate]":
		if the climate understood is listed in completed-climates:
			say "Sorry, you can never use that setting again." instead;
		now the climate of the weather machine is the climate understood;
		say "You set the weather machine to [climate of weather machine].";
		add the climate of the weather machine to completed-climates;
	else:
		instead say "That isn't a setting.".

Edit:

Another way to organize it:


The weather machine has a list of climates called completed-climates.

Check setting to:
	if the noun is not the weather machine:
		say "[The noun] [aren't] something you can set." instead.
		
Check setting the weather machine to:
	if the topic understood matches "[climate]":
		if the climate understood is listed in completed-climates:
			say "Sorry, you can never use that setting again." instead;
		else:
			continue the action;
	else:
		instead say "That isn't a setting.".
		
Carry out setting the weather machine to:
	now the climate of the weather machine is the climate understood;
	add the climate of the weather machine to completed-climates;
	
Report setting the weather machine to:
	say "You set the weather machine to [climate of weather machine].";
	if the climate of the weather machine is snow:
		say "It begins snowing.";
	else if the climate of the weather machine is rain:
		say "It begins raining.";
2 Likes

That works perfectly, thanks for your help!

1 Like