Redefining "run"

Hello everyone.

I’m new to this forum, and to writing Interactive Fiction. To get started, I’m trying to write a hamster simulation in Inform 7.

I’ve hit a problem trying to implement running in a hamster wheel. I’ve tried implementing the “run” command as follows:

The Wheel is above the Cage Floor. "You love to take this for a spin."

Understand "run" as running. Running is an action applying to nothing.
Report running:
    if the location is The Wheel, say "Wheee! Running is such fun."

But when I try it, here’s what happenes:

So clearly, the built in understanding of “run” is overriding the one that I’ve tried to supply.

How do I fix that?

I found the answer to my own question while I was waiting for the moderator to approve my posting.

The key phrase is understand “___” as something new. My code now looks like this:

[code]
The Cage Floor is a room. “There’s a wheel above you.”

The Wheel is above the Cage Floor. “You love to take this for a spin.”

Understand the command “run” as something new.
Understand “run” as running.
Understand “run [a direction]” as going.
Running is an action applying to nothing.
Before running:
if the location is not The Wheel, try going instead.
Report running:
say “Wheee! Running is such fun.”[/code]

Yep. I’d just like to add that instead of using “Before running”, we would use check running (Which checks every time you do an action to make sure that it’s valid)

Check running: Unless the location is The Wheel, try going instead.

It has the same effect more or less, but following conventions eliminates confusion and makes your code easier to be understood.

Actually I would rather use a before or an instead rule to redirect actions. Check rules should be used when the action is flat-out refused (Check running: unless the location is The Wheel, say “No running here!” instead.) Check rules are considered so late that other rules can easily interfere and make responses look illogical.

(There are no hard and fast rules; others might disagree.)