[adv3lite] Nil references with commands and NPCs and commas.

Using version 1.1.

With my current project, I first ask an NPC something. Then I type “z,z,” - note that last trailing comma.

And then it gives me a nil object reference runtime error.

If I run the game without first speaking or interacting with an NPC, then do “z,z,” I get “Sorry; multiple objects aren’t allowed with that command.” I also get this result if I look at an object in the location and then do “z,z,”. In fact, just entering a single comma at the command prompt gives me the “Sorry; multiple objects aren’t allowed with that command.” message. Note that the crashing only (so far as I’ve tested) seems to affect NPC interaction.

Anyone else encountered this?

The nil obj reference on bad input appears to be a library bug, and I can’t help solve that.

However, as a workaround, you could just suppress trailing commas from command entries.

I’ve tested this (briefly) and it appears to work…

// remove trailing comma StringPreParser doParsing(str, which) { local strBuff = new StringBuffer(); strBuff.append(str); if(str.endsWith(',')) strBuff.deleteChars(-1); return toString(strBuff); } ;

I get this…

When just a comma is entered, I still get the Sorry, multiple objects… message, but at least its not a crash.


Like Jerry, I can’t reproduce the run-time error, but then this may because I’ve already fixed a related bug in my version of the code and Jerry may have downloaded the fix from GitHub.

I’ve now fixed the terminal comma issue too. Parser.parse() now begins:

        /* tokenize the input */
        local toks;
            /* run the command tokenizer over the input string */
            toks = cmdTokenizer.tokenize(str);
            /* Dispose of any unwanted terminal punctuation */
            while(toks.length > 0 && getTokType(toks[toks.length]) == tokPunct)
                toks = toks.removeElementAt(toks.length);

This should remove any amount of terminal punctuation from the end of a command before the parser tries to interpret it.

Any plans on releasing an updated version of the library?

If all goes according to plan, downhill with a following wind, I hope to get version 1.2 released this coming weekend. This assumes I’m not blown off course by other commitments, or by having to fix a whole lot of other things between now and then, so I’m not making any promises!

Thanks Eric, shall keep an eye out! And also modified my local copy of advlite to have your fix in it. Works well, though now curiously enough “,” (and other such separation characters) results in a look action being performed.

Strangely enough, this is the expected behaviour. A command that consists of nothing but punctuation is equilavent to an empty command (i.e just like pressing the return key at the command prompt without first typing anything else), and the default response of the adv3Lite library to empty command is to perform a LOOK command. You can change this behaviour by putting the following in your code:

modify Parser
    autoLook = nil

Then the response to an empty command will be “I beg your pardon?”