this is probably easy to find in the documentation, but I don’t know by which words to search.
How do I let the player execute a command? Like, the player inputs “use string on stick”, but I have already coded everything for “tie string to stick”, so I want to use that routine by calling it through the proper command as if the player had typed it. Like
<<tie string stick>> in Inform 6.
Thanks and kind regards,
try tying the string to the stick;
Do you have a generalized “use” action? If so you can just write a carry out rule as zarf indicates. If you just want the grammar to be parsed as the tying action, you can do that with an understand instruction:
Understand "use [string] on [stick]" as tying it to. [or whatever your tying action is called]
Since “use” as a verb doesn’t have the same inherent directionality that “tying” does, you’d probably also want
Understand "use [stick] on [string]" as tying it to (with nouns reversed).
This sort of points to the reason why you might want to be wary of opening the can of worms that is the “use” action, though. From a design perspective, it risks incentivizing the player to adopt a lawnmowering approach of rubbing everything on everything else without really thinking much about what they’re doing, which can reduce some of the charm of IF. On a less precious note, too, coding an omnicompetent “use” command seems like it could be tricky to do properly, given the wide range of potential applications and grammars it could wind up being expected to work for.
Hmm. That sounded like exactly what I was looking for, but…
Problem. You wrote 'try using the string on the stick' , but 'using the string on the stick is too vague to describe a specific action. It has to be an exact instruction about what is being done, and to what. For instance, 'taking the box' is fine, but 'dropping or taking something openable' is not. See the manual: 7.4 > 7.4. Try and try silently I was trying to match this phrase: try (using the string on the stick - action) I recognised: using the string on the stick = a described action
You’ll have to give more of your source code, then. Are
stick not defined objects?
They are. It must have something to do with the way I define “use”. Which is -
Understand the command "use" as something new. Using is an action applying to two things. Understand "use [something] with [something]" and "use [something] on [something]" as using.
Code compiles when I try other verbs but “using” causes an error.
Possibly what’s going on is that Inform wants a preposition and pronoun in its action definitions when an action applies to two things, so it understands where the nouns go.
(Also, you don’t need the “the command” part - that’s used when you’re overriding one of Inform’s built-in commands, but there’s no use of “use” in the standard rules so far as I’m aware. And you can combine your two definitions with a slash to indicate that either with or on should work).
Try this instead:
Using it on is an action applying to two things. Understand "use [something] with/on [something]" as using it on.
(I’m on my phone so haven’t tested this, but pretty sure it should work!)
That worked! Thanks a lot!