Strange behaviour from new verb

I’m trying to define a new verb

Unplugging is an action applying to one thing.
Understand "unplug something" as unplugging.

Instead of unplugging something when the noun is not the radio:
	say "You can't unplug that."
	
Instead of unplugging the radio:
	say "The loud music stops playing.";
	now the radio is switched off.

My game compiles with no errors, but whenever I try to unplug the radio or anything else, I get the response

I don't understand that sentence.

I must be doing something wrong, but I can’t figure out what. Any assistance would be greatly appreciated!

Cheers,
C. Scott Davis

You need to say:

Understand “unplug [something]” as unplugging.

The square brackets mark “something” as a token - like, a placeholder for where the player can provide input, in this case the name of a thing - rather than literally just the text “something”.

2 Likes

There are a couple of things going on. In the first case you need to bracket off “something” or else the action will look for a noun that is literally named “something.”

Understand "unplug [something]" as unplugging.

Second, since “switched off” is already defined in the standard rules, you need to state that the radio can be switched on/off first.

The radio can be switched on.

As a recommendation, I’d use carry out unplugging instead of instead of unplugging since the player is completing an action.

e: ninja’d

2 Likes

Would saying that it is a device have the same effect?

I get confused by this sort of thing! My instinct would be to write:

Carry out unplugging:
	say "You can't unplug that."
	
Instead of unplugging the radio:
	say "The loud music stops playing.";
	now the radio is switched off;

But is this the ideal?

Carry out unplugging:
	say "You can't unplug that."
	
Carry out unplugging the radio:
	say "The loud music stops playing.";
	now the radio is switched off;
	stop;
2 Likes

Yes, “device” is a built-in kind that can be switched off. It would be beneficial for managing multiple things that can be switched on. The important thing is that it be declared for the radio (since this custom verb uses it) one way or another. However, there’s a gap because a device can be turned off without being unplugged. I’ll leave that as a to-do.

I use “check” as a tool to evaluate whether an action can occur. As a literal check. “Carry out” is executed later, so if you have an “instead” or “stop” in the “check” phase, the action ends before “Carry Out” happens.

Using “check” and your device suggestion does allow for a more general use of “unplug.” Again, the action doesn’t actually account for the device being physically unplugged, which I think would be desirable in a final version of a game.

Note that the devices could be defined together, but I like keeping things separate.

An alternative would be to redirect unplugging to built-in “switching off”, but that doesn’t account for the physical state of being unplugged, either.

(let me know if you can’t read/play the below snippet)

2 Likes

Things get complicated pretty quickly when you add new concepts. Surely, the radio also has a switch and loud music should only occur if it’s both plugged in and switched on. So suddenly this balloons to something more like:

Lab is a room.


The radio is a fixed in place thing in the lab.
The radio can be switched on.
The radio is switched on.
The radio can be plugged in.
The radio is plugged in.

The description of the radio is "[if the radio is plugged in and the radio is switched on]Loud music blares from the radio[else]The radio just sits there[end if]."

For writing a paragraph about the radio when the radio is plugged in and the radio is switched on: say "Loud music blares from the radio."

Plugging it in is an action applying to one thing.
understand "plug [thing] in" as plugging it in.
understand "plug in [thing]" as plugging it in.


check plugging it in when the noun is plugged in: instead say "[The noun] [are] already plugged in.".

carry out plugging it in: now the noun is plugged in.
After plugging the radio in when the radio is switched on: say "Loud music resumes.".
report plugging it in: say "[The noun] [are] now plugged in.".

Unplugging is an action applying to one thing.
understand "unplug [thing]" as unplugging.
check unplugging when the noun is not plugged in: instead say "[The noun] [are] not plugged in.".
carry out unplugging: now the noun is not plugged in.
After unplugging the radio when the radio is switched on and the action is not silent: say "The radio falls silent."
Report unplugging: say "[The noun] [are] now unplugged.".

After switching on the radio when the radio is plugged in: say "Loud music resumes.".
After switching off the radio when the radio is switched on and the radio is plugged in: say "The radio falls silent."


test me with "switch off radio / switch on radio / unplug radio / switch off radio / switch on radio / plug in radio / switch off radio / unplug radio / plug in radio / unplug radio / switch off radio / plug in radio"

Probably has errors still, it was only cursorily tested. For a real project, where the responses are the same I’d want to define them in one place and have all relevant rules use the same thing so I’d be free to update it without having to remember to do it in two places.

And then things get more complicated still if the radio can be taken 'cause you’d have to worry about in which rooms it could be plugged in.

4 Likes

I just added a failure message about all plugging/unplugging in my project. I haven’t had a tester try to unplug the tv yet, but might as well head it off.

2 Likes