Create new commands - beginner question

Hi. So I’ve been reading the manual and I want to create an object, a radio (walkietalkie/CB radio) the player can use to call police. I wanted to catch commands like “call police” or “call police on radio”.

I tried modifying an example in the manual for telephones, but couldn’t get it to work for me. (At all.)

My beginner’s question is: what is the usual way to add/define new commands the player can use? Is there a simple example somewhere I’ve missed?

The only thing I saw in the manual that looked good was the Activities: Reading a Command part. I could use a “After reading a command: if the player’s command includes “call police”;” but that seems clumsy?

thanks for any help…!

Yes, that’s not the way you want to go.

See the first section of the Understanding chapter (16.1) for several examples of how to create a new command for the player.

Thanks for the quick reply - solved my problem. For anyone who is interested/for the sake of completeness here is the solution that worked. I am sure it is ugly, ugly code but it produced the result I needed. Thanks again!

[code][ITEM - radio]

The radio is a device. It is carried by Dan. The description is “This is a small two-way police radio, like a cellphone. When it is switched on, you can call police with it.”

Understand “call police on [something]” or “call police with [something]” or “call the police on [something]” or “call the police with [something]” or “call police car on [something]” or “call police car with [something]” or “call the police car on [something]” or “call the police car with [something]” as calling police.

Calling police is an action applying to one thing.

Check calling police:
if the noun is not the radio, say “It’s certainly an interesting concept; but you can’t really call anyone on [a noun].” instead;
if Dan is carrying the radio, say “You don’t have a radio. Maybe someone else has one you could borrow?” instead;
if the radio is not carried, say “You don’t have the radio right now.” instead;
if the radio is switched off, say “You try to use the radio, but it doesn’t seem to be working. You give it a shake. ‘Hm,’ says Dan, peering over your shoulder. ‘Maybe you need to switch it on, first?’” instead;
if the Jogger Capture is not happening, say “The police radio is for emergencies only. Try something else.” instead.

Carry out calling police:
move Police Car to Smith Street;
move Jogger to Smith Street;
move Officer Jackson to Smith Street.

Report calling police:
say “You shout commands into the radio. ‘All units, all units! A suspect is fleeing along North Street!’”.
[/code]

Not so bad! The main thing I’d point out is that you can combine some of those lines by writing, e.g., “call police on/with [something]”, since a slash will tell Inform that two words are equivalent and either should be matched.

Thanks again and done (was wondering about that). I also found out how to solve the the issue. Here is the new more coherent version, for any fellow beginners about.

[code][ITEM - radio]

After reading a command:
while player’s command includes “the”, cut the matched text.

The radio is a device. It is carried by Dan. The description is “This is a small two-way police radio, like a cellphone. When it is switched on, you can call police with it.”

Understand “call police on/with [something]” or “call police car with/on [something]” as calling police.

Calling police is an action applying to one thing.

Check calling police:
if the noun is not the radio, say “It’s certainly an interesting concept; but you can’t really call anyone on [a noun].” instead;
if Dan is carrying the radio, say “You don’t have a radio. Maybe someone else has one you could borrow?” instead;
if the radio is not carried, say “You don’t have the radio right now.” instead;
if the radio is switched off, say “You try to use the radio, but it doesn’t seem to be working. You give it a shake. ‘Hm,’ says Dan, peering over your shoulder. ‘Maybe you need to switch it on, first?’” instead;
if the Jogger Capture is not happening, say “The police radio is for emergencies only. Try something else.” instead.

Carry out calling police:
award 15 points;
say “## 15 points! ##”;
move Police Car to Smith Street;
move Jogger to Smith Street;
move Officer Jackson to Smith Street.

Report calling police:
say “You shout commands into the radio. ‘All units, all units! A suspect is fleeing along North Street! A white male, a jogger! Catch him, quickly!’ A police car soon answers: ‘This is Officer Jackson, ma’am. We can see him. We will catch him! Meet us in Smith Street.’”.[/code]