I want the player to throw a cane down in front of the Snake Door which will remove the danger of the snakes present and allow passage through the door. As that I’ve had a few similar tasks occur before, I just replicated the coding but some reason it didn’t work here.
This is the error I got:
You wrote ‘Understand “cast a/the/-- cane down” as casting the cane’ : but ‘understand … as …’ should be followed by a meaning,
Casting the Cane down is an action applying to nothing.
Understand "cast a/the/-- cane down" as casting the cane.
Report casting the cane:
say "You throw the cane down on the ground."
Throwing the Cane down is an action applying to nothing.
Understand "Throw a/the-- cane down" as casting the cane.
Report Throwing the cane:
say "You throw the cane down on the ground."
The Snake Door is a locked door. It is scenery. It is north of the Snake Way and south of the Dark Chamber.
The description of the Snake Door is "This door to the north not only has snakes wiggling around its base but has several snake depicted in its wood grain."
Instead of casting the cane down when the locked Snake Door is in the location:
Say "The Cane begins breaking up into multiple segments revealing that the stick also doubles as a mechanical snake. The machine begins chomping through all the live snakes until they’re a mess of dead twitching bloody bodies. Now you can descend to the end of the tunnel where you find a door to the north.";
Now the Snake Door is unlocked.
Hiya! A couple things are going on here, but the main one is that the compiler is trying to grapple with three different actions here: “casting the cane down” and “throwing the cane down”, which you’ve defined, and “casting the cane” which you’re using but haven’t actually defined. You want a single action with a couple different syntaxes the player can type, and that’s what the Understand commands do. But those ways of phrasing the action should always be in quotation marks, since they’re about what the player types – when “talking” to the compiler, you need to stick to the formal definition, which is what comes before “is an action applying to” whatever.
The other wrinkle is that you’ve defined casting the cane down as an action applying to nothing, which means the player can do it whenever and wherever they want, regardless of whether or not they’re currently carrying the cane (or if it even exists in the world). So they could cast it down in one room, move to another and do it again, etc. You probably want to make this an action applying to one carried thing to take advantage of Inform’s built-in world modeling and avoid potential weirdness. Finally, you probably want to make the grammar apply to multiple objects, not just the cane – I find that when I’m playing a game, I often get confused if I try an action and get a default “I don’t understand that” response from the parser, so probably won’t try it later when I get the right object or the time is right.
I took a crack at cleaning this up a bit, so see below for that! You might also want to include a few other alternate syntaxes – in particular, to my mind “CAST DOWN THE CANE” seems just as reasonable as “CAST THE CANE DOWN”. Oh, and the description says the player only finds the door after casting down the cane, but by default the player will be able to see the door even when it’s locked. So you might want to clean that up as well.
Casting down is an action applying to one carried thing. Understand "cast a/the/-- [thing] down" as casting down. Understand "throw a/the/-- [thing] down" as casting down.
Carry out casting down:
Try dropping the noun instead.
The Snake Door is a locked door. It is scenery. It is north of the Snake Way and south of the Dark Chamber. The description of the Snake Door is "This door to the north not only has snakes wiggling around its base but has several snake depicted in its wood grain."
The cane is in the Snake Way.
After casting down the cane when the locked Snake Door is in the location:
Say "The Cane begins breaking up into multiple segments revealing that the stick also doubles as a mechanical snake. The machine begins chomping through all the live snakes until they’re a mess of dead twitching bloody bodies. Now you can descend to the end of the tunnel where you find a door to the north.";
[Do you want to remove the cane from play, or can the player pick it up again? If the former, you'll need some code here, probably moving it to nowhere]
Now the Snake Door is unlocked.
Thank you, that worked. And thanks for the other suggestions. I figured at some point I’d have to address some of the issues of more accepting commands. Best to get it done now.
BTW, what does “Try dropping the noun instead.” function as/do?
So I put that in as the Carry Out rule, which is meant to be what the action actually does (Check rules are meant to be about gatekeeping to make sure the action is allowed, and Report rules are meant to be about displaying text to the player so they know what just happened).
Here, I thought that if a player cast down an object other than the cane, or cast down the cane somewhere other than in front of the locked door, the effect should just be to drop the object. I could have done this manually – like "move the noun to the location; say “Dropped.” But it’s cleaner to just redirect the casting down action to the already-existing Drop action. The “try” command is helpful for this, since it allows you to trigger an action from within a rule (there’s also “try silently”, which allows you to trigger the action while suppressing reports, if you want to do something without the default responses). This is in Section 7.4 of Writing with Inform.