Creating code that is actioned when player goes in direction

I am converting an old adventure to Inform7

One of the players commands that is acted on is Go South.
So if the player is in a certain location and tries to Go South then some text is displayed.

But the problem is if the player types S or walk South instead of Go South.

I have tried Understand “S” or Go South instead of Go South.

But the problem is that when The player wants to Go South when the player is not in a certain location when nothing happens so it has removed the built in going south command from inform7.

Any suggestions would be welcome thanks.

Regards Brian.

You should try this:

Instead of going south in [whatever the location is]: [stuff you want to happen]

As you’ve found out, just trying to do something special for the string “go south” is a bad idea, because there are so many synonyms around. When in doubt, it’s much better to try to find the action (going south) and do something that works on that.

A key subtlety here is that “Instead of going south in Special Location” and “Instead of going south from Special Location” have different behaviors; see section 7.13 of the documentation.

One problem I’ve found when using…

Instead of going south:
If player is in clearing1, say “it’s not safe to go that way.”.

Is that when each time the player wants to go south from any location then nothing happens.

So if I was to type
Instead of going south from clearing1

Would that solve the problem of nothing happening when ever the player wants to so south from any location?

You need to use:

Instead of going south when the player is in clearing1: say "It's not safe to go that way."

or just:

Instead of going south in clearing1: say "It's not safe to go that way."

The difference is that these rules don’t fire at all unless the condition is true, so they won’t replace the normal going south action in other locations.

If you really wanted, you could even do it like this:

Instead of going south:
	if the player is in clearing1:
		say "It's not safe to go that way.";
	else:
		continue the action.

That way, the normal behavior of an “instead” rule (stopping the action) is overridden if the condition fails. However, it’s usually better to just make the rule specific enough that it only fires when you do want to stop the normal processing of the action.

It would, but as the documentation in section 7.13 says, it won’t work unless you’ve defined a room (or door) that’s south of clearing1. That’s the difference between “going south from clearing1” and “going south in clearing1”; with “in,” the rule will apply even if clearing1 doesn’t have a south exit; with “from” it won’t.