Illegal commands

If a player enters a noun that does exist, but is invalid, this generates a response from the parser that I understand to be classified as an “illegal command.” For example, if the player enters “take down”, the response from the parser is “You must supply something more substantial.”

I know there are extensions for changing library messages, but what if I don’t want a library message change, but instead want to do some other functions here. What if I think that “take down” should be a valid option in some cases, and I would like to work with this? In this case, I’m not sure how to insert a before or instead rule here. I looked in the Standard Rules but couldn’t figure out where this behavior from the parser is coded for.

I believe this is controlled by a rule along the lines of “check doing something with a direction”.

I think the problem is that the definition of taking in the Standard Rules:

Taking is an action applying to one thing.

entails that taking only applies to things you can touch, and you can never touch directions. (Maybe it’s possible to change this? I wouldn’t try.)

What I would do is define a new action applying to visible things, have an understand line with directions for it, and then plug in your desired behavior:

[code]Direction-taking is an action applying to one visible thing. Understand “take [direction]” or “get [direction]” as direction-taking.

Report direction-taking: say “You take [the noun]. Don’t look for it in your inventory.”
Report direction-taking down: say “You get down. Ha ha.”; rule succeeds.[/code]

Note that there are lots of other synonyms for taking", like “pick up,” which you’d have to code in. Also, “get up” and “get down” are already defined and you might have to rip out the grammar for “get” and build it back up to take care of them.

You could also just make a new action with the understand grammar “take down” and a does the player mean line.

I could do those things, but what if I have a more generic issue with things like this, not just “take down” or even “take west” or anything like that… but that this, or something like it, could be a common problem?

I looked into “check taking a direction” in the Standard Rules, but couldn’t find that either. Is the code that decides an action is illegal written into the Inform application itself, not the Standard Rules? There must be a rule somewhere that is telling Inform to use that particular library message in that particular circumstance…

What sort of more generic issue?

The response “You must name something more substantial” is generated by the basic accessibility rule. This is early in action processing, but after the “before” rules. So this works:

Before taking north:
	instead say "North isn't a thing."

(An “instead” or “check” rule would not work for this, because the basic accessibility rule is checked before them.)

The reason for wanting it may actually be off topic, as the question is really more about understanding the behavior of the program. I just can’t figure out how or where Inform is deciding that “down,” in this example, is “insubstantial.” I don’t disagree with the decision, I just don’t see where in the code the instruction to consider a direction insubstantial for taking is defined.

Again, sometimes I may use something in a game, if I ever get good enough to make one, sometimes the question is more academic, but still helps me figure out how the heck this Inform thing works…

If I have to come up with an example… let’s say there are 2 items, each otherwise undescribed and unknown to the player, but they have been told that one is “up” and one is “down.” As part of the “puzzle” they have to select one. If the player types in “take down,” in this case, it might make sense to try to help them out. I realize there are holes in this example, and there may be entirely different ways to solve this puzzle… but I’d really rather not use this thread for that, at least not until the original question is answered… what if indeed the way I’d like to solve for this is to intercept the parser deciding “down” is invalid, and telling it that in this case it is not, and injecting special instructions at that junction?

I’m pretty sure that it’s written into the Inform 6 templates that get included in every Inform 7 project unless you specifically replace them. If you look at the basic accessibility rule in section 14 of appendix B (warning: giant PDF), the first clause appears to fire if the action requires a touchable noun and the noun is a direction, and it calls miscellaneous library message number 67, which is the “you must name something more substantial” error. So… I think it’d be hard to change that behavior (as opposed to just changing the message) without some pretty serious messing with I6.

Right, this certainly can stop this behavior, but I still think it’s stopping it by preventing it from ever happening before it even comes to it… what I mean is, this prevents the insubstantial check because it happens literally before the event could occur. What I’m still trying to figure out is how and where the “insubstantial check” itself occurs… if we do let it get to where “north” is being taken, how do we then prevent that message from displaying even though north is insubstantial? I hope I’m making sense now.

matt posted after I was composing the above… ok, so the behavior either can’t be changed, or it would be beyond me to understand. But, what about instead of intercepting the check, intercepting the printing of the message? Is there a before statement that would work like:

Before printing library message 67:

? Obviously the above doesn’t work, but I’m not sure how to write a before for a library message.

You could use one of the extensions that lets you change a library messages to stick a say phrase at the beginning of library message 67, and then have that say phrase run your stuff. So you would change the library message to “[do the fooing] Your message here.” and then include this:

To say do the fooing: [your code here]

It’s perhaps a bit hackish but it’s the least headachey thing I can think of to have some code run before a given message gets printed.

I guess you could call that hackish… but I wouldn’t… it’s really the only reasonable way to do it, thank you! I think that answers this iteration of dootdoot’s bizarre, Inform unfriendly questions!

As matt w, it’s part of the basic accessibility rule.

The cleanest way to bypass this is to define your action as requiring a visible (that is, “not necessarily touchable”) noun.