en_us.t defines a ‘drink’ verb, but it requires an object (‘drink wine’). The bare command ‘drink’, entered during a game, causes a run-time error – “wrong number of arguments”.
The line in en_us.t that the error pops up on is in the code for modify TAction, in the announceDefaultObject method. The line is:
local nm = obj.getAnnouncementDistinguisher().theName(obj);
What may or may not be relevant is that my own code adds a new DrinkFrom action and a new DrinkItFrom action. Somehow the parser is stumbling over this stuff. I don’t think it’s relevant, because when I replace the grammar for my new actions with gibberish and then type ‘drink’ in the game, the same error pops up.
How would I fix the code so as to get a standard “What do you want to drink?” query from the parser?
If you could fire this up in the debugger, when you get to this point, see what obj.getAnnouncementDistinguisher() gives you. I’m guessing that’s the culprit - that object probably doesn’t have a theName() defined, thus the argument mismatch (undefined → implicitly zero arguments vs one argument fromthe caller).
(To look at this in the debugger, just run it in Workbench and trigger the error - the debugger will stop at the point where the error is triggered. Type ‘obj.getAnnouncementDistinguisher()’ into the watch window to evaluate that.)
I wish I was sure what “the debugger” is. I opened the Watch Expressions window and copied that string into the Expression field, but all I get for Value is “(error: wrong number of arguments”, and we knew that already.
Interestingly, if I start with the default introductory game, I don’t get this error in response to ‘drink’, but I do get it in response to ‘sit’.
In my own game, I get it in response to either ‘drink’ or ‘sit’ – and I’ve commented out all of my custom stuff relating to the command ‘drink’, leaving only the library code.
The one thing I did to the library code was hack en_us.t to add ‘sip’ as a fourth synonym. The code appears error-free:
The library code for the ‘sit’ command is only a tiny bit more complex; it includes the bare command ‘sit’ with no object as SitAction. As that command does trigger the error, I can only guess that we’re seeing a library bug here.
I’m happy to help test it further, but I’m not really a tyro at using the debugging tools. Here’s the stack trace (or whatever it’s called) in the interpreter after I shift-F11 to get out of the error:
Unrelated to the problem at hand, but I guess you’d like to know that you don’t need to hack the base files for this (it gets messy and causes problems when you upgrade to a new TADS version.) You can simply use a “modify” statement to change the syntax of existing verbs:
I could be totally wrong, because this stuff is well outside my comfort zone, but I think I see where the bug is, and how to fix it.
In en_us.t, the modify TAction block has the announceDefaultObject method. The second line in this method is:
local nm = obj.getAnnouncementDistinguisher().theName(obj);
But when I look up getAnnouncementDistinguisher() in the LRM, I see that it’s supposed to be called with an argument – (lst). This does seem to be a bug in en_us.t. And indeed, when I change the line to this:
local nm = obj.getAnnouncementDistinguisher([]).theName(obj);
…the run-time error vanishes with the morning dew. How sweet! Whether this fix may have side effects, I’ll leave for wise minds to say.
That is indeed the problem - that ‘modify TAction’ was some old code that I missed. Instead of an empty list, the actual argument should be gActor.scopeList():
local nm = obj.getAnnouncementDistinguisher(gActor.scopeList()).theName(obj);