new actions

I’m having a bit of trouble with new actions. I’m making a mini game that takes place in probably three or four rooms. Just a short one. It’s a break from my bigger longer project… I’m trying to make an action for cutting rope that binds the player. It’s pretty simple…

CuttingRope is an action applying to nothing. understand "cut the rope", "cut rope", "cut the rope","cut bindings", "cut rope with glass", "cut the rope with glass", "cut the rope with the glass", " cut the bindings", "cut the bindings with glass", "cut the bindings with the glass", "slice the rope", and "slice the bindings" as CuttingRope.

the problem I’m facing is that if the player types 'cut the rope they get this message ‘Cutting that up would achieve little.’

how ever if they type ‘cut rope’ or any of the other understands I got in there it works fine, lol.

The library already has a “cutting” action. You’re half-overriding it.

It’s better form to use the existing action, in an “instead” or other action rule. That way, the library takes care of all the synonyms properly.

Two comments:

First, the cutting action is already defined by the library. It would be easier to use this action than to define a new one. However, if you do that, you’ll still need to define a new “cutting it with” action to handle the commands ‘cut rope with glass’ and so forth.

If you do it your way, you’ll need to begin by saying,

Understand the command "cut" as something new.

Second, defining an action the way you’re doing it, by manually listing all of the grammar you want (including and not including ‘the’, for example) is a bad idea. Sorry to be so blunt, but don’t do it this way. Study how to create new actions, and use the standard methods.

The Inform manual is a bit dodgy on this point. Chapters 7 and 12 contain a lot of information, but page 12.7 still begins, “It is not often that we need to create new actions,” and that’s dead wrong (as well as needlessly discouraging). You might want to download my Handbook (musicwords.net/if/i7hb.htm), which has a chapter explaining how to do it.

I have some grammar to support cutting in my WIP. I’ll share a bit of it with you:

[code]Section - Attacking it With

[If you have no combat, you can simplify this to “Cutting it With.”]

attacking it with is an action applying to two things. [You might want to make it one thing and one carried thing]

Understand “off/up/apart/open” and “in/into two/twain/pieces” as “[apart]”

Understand “attack [something] with/using [something preferably held]” as attacking it with.
Understand “cut [something] with/using [something preferably held]” as attacking it with.
Understand “cut [apart] [something] with/using [something preferably held]” as attacking it with.
Understand “cut [something] [apart] with/using [something preferably held]” as attacking it with.
Understand “break [apart] [something] with/using [something preferably held]” as attacking it with.
Understand “break [something] [apart] with/using [something preferably held]” as attacking it with.
Understand “beat [something] with/using [something]” and “beat [something] up with/using [something]” and “beat up [something] with/using [something]” as attacking it with.

Check attacking something with something:
Try attacking the noun instead;

Section - Blades and Cutting

A blade is a kind of thing.

Check cutting (this is the cutting with blades rule):
If the player encloses a blade (called the item):
say “(with [the item])[command clarification break]”;
try attacking the noun with the item instead;
say “You don’t have [if the noun is a person]a weapon[otherwise]anything[end if] to cut with.” instead.

The cutting with blades rule is listed instead of the block cutting rule in the check cutting rulebook.

Understand “cut [apart] [something]” and “cut [something] [apart]” as cutting.

Check attacking something with a blade:
say “You [if the noun is a person]wouldn’t[otherwise]can’t[end if] cut [the noun].” instead;
[/code]

++ to that.

And that.

:laughing: I downloaded the handbook the first time you offered it back in my first post here, needing help with the basics, or something like that, lol…

it’s been a big help, but learning to create actions is something that I’ve failed to learn…I guess I find it confusing…

I don’t understand how to write them like…

action applying to two things, and understand do [something] with [something] as hahaha.

how does inform know what all these somethings are, and how am I suppose to know what I’m writing when it looks so confusing? hahah

It takes a while to get used to it, especially what to call the actions in different contexts. But here’s how I think of it.

What the player experiences as an “action” has two parts: The first part is the command that they type in. That’s the part handled by the parser. The second part is what the player-character actually does, and what happens next. That’s the part handled by the world model.

So:

Parser --> grammar line (“Understand … as [action-name]”)
World model --> action ("… is an action applying to …")

You can create an action with no grammar lines, and that might even be useful – that’s what Simple Chat does with actions like “providing links” and “finding responses.” But when you write a grammar line, it has to be understood as an action.

What are grammar lines exactly? They’re a bit like a big rulebook that the parser follows. When the player types a command, the parser compares the command to each line in order. As soon as a line matches with some combination of noun and second noun, it chooses that action and starts looking for the best match of objects.

There are a few other confusing cases, like command synonyms. Command synonyms are much more restricted than other types of “Understand” statement. You might expect command synonyms to map as an action, but you’d get an error if you tried that. Command synonyms link command words together, so both sides of the “understand the commands … as …” must contain single words in quotes, with no other Understand tokens.

Then there’s the confusion of actions that take a second noun. When you define an action, and when you refer to the action-name in the “abstract,” you have to use the placeholder “it” to show the separating words between noun and second noun. But whenever you refer to the action later, you must use “something” (or a more specific description of an object) rather than “it.”

Examples:

Action definition:

attacking it with is an action applying to one thing and one carried thing. [Using the word "carried" here will generate an implicit take.]

Grammar line:

Understand "attack [something] with [something preferably held]" as attacking it with. [The "preferably held" token causes the parser to look for already held items during disambiguation.]

Command synonyms:

[code]Understand the command “kill” as something new. [This removes the word “kill” from any set of synonyms that it belonged to before, as well as any grammar line that used that set of synonyms.]

Understand the commands “cut” and “break” as “attack”. [This creates a set of synonyms that includes “cut”, “break”, and “attack”. They will be considered as exactly the same word in every grammar line that uses one of them as the command word.][/code]

Action descriptions and specific action processing rulebooks:

[code]Instead of attacking something with: [This is the minimum description that the compiler needs to always understand that you mean the “attacking it with” action.]

Check attacking something with a blade: [This rule will be automatically placed in the “check attacking it with” rulebook.]

Carry out attacking a person with something: [This rule will be automatically placed in the “carry out attacking it with” rulebook.]

Report an actor attacking something with: [This rule will be automatically placed in the “report attacking it with” rulebook.][/code]