In Airport tutorial example, metalDetector.canTravelerPass() causes runtime error when returning a falsy value

I’m trying to follow the Airport example in the adv3lite tutorial, and I’m having a weird issue where having metalDetector.canTravelerPass() return a falsy value causes a runtime error with the message “wrong number of arguments” no matter what I do.
I can do almost 1:1 the code in the tutorial (minus mild formatting differences):

+metalDetector: Passage 'metal detector; crude; frame'
   "The metal detector is little more than a crude metal frame, just large enough to step through, with a power cable trailing across the floor. "
   destination = concourse

   isOn = true

  canTravelerPass(traveler) {
      return !isOn || !idCard.isIn(traveler);
   }

   explainTravelBarrier(traveler) {
      "The metal detector buzzes furiously as you pass through it. The security guard beckons you back immediately, with a pointed tap of his holstered pistol. After a brisk search, he discovers the ID card and takes it off you with a disapproving shake of his head. ";

     idCard.moveInto(counter);
   }
;

Or I can minimize it, so it’s false no matter what and has barely any other code added:

+metalDetector: Passage 'metal detector; crude; frame'
   "The metal detector is little more than a crude metal frame, just large enough to step through, with a power cable trailing across the floor. "
   destination = concourse

   canTravelerPass(traveler) { return nil; }
;

Either way, when I attempt to pass through it in a way that makes it return something falsy (including when I change it so it returns 0 instead of nil) I get this error:

Runtime error: wrong number of arguments
-->adv3Lite/travel.t, line 1815
   adv3Lite/travel.t, line 1580
   adv3Lite/action.t, line 1458
   adv3Lite/action.t, line 1432
   adv3Lite/action.t, line 1407
   adv3Lite/action.t, line 1276
   adv3Lite/action.t, line 109
   adv3Lite/action.t, line 1241
   adv3Lite/action.t, line 80
   adv3Lite/doer.t, line 415
   adv3Lite/doer.t, line 384
   adv3Lite/command.t, line 548
   adv3Lite/command.t, line 503
   adv3Lite/command.t, line 243
   adv3Lite/remapcmd.t, line 889
   adv3Lite/main.t, line 177
   adv3Lite/main.t, line 118
   adv3Lite/misc.t, line 124
   adv3Lite/main.t, line 70
   adv3Lite/main.t, line 24
   /usr/share/frobtads/tads3/lib/_main.t, line 217
   /usr/share/frobtads/tads3/lib/_main.t, line 122
   /usr/share/frobtads/tads3/lib/_main.t, line 31

And I get this same error whether I’m running it in FrobTADS, QTads, or Parchment.

I’m honestly at a complete loss here. I’m using adv3lite 2.2.2 if that makes any difference, and I’m writing + compiling from Linux (using the FrobTADS package on the AUR to compile).

Just to be extra sure the problem wasn’t somehow somewhere else in start.t, I stripped my overall code down to the barest of the bare minimum:

#charset "us-ascii"
#include <tads.h>
#include "advlite.h"

versionInfo: GameID
;

gameMain: GameMainDef
   initialPlayerChar = me
;

terminal: Room 'Terminal'
   north = securityGate
;

+me: Player 'you'
;

securityGate: Room 'Security Gate'
   north = metalDetector
   south = terminal
;

+metalDetector: Passage 'metal detector'
   destination = concourse

   canTravelerPass(traveler) { return nil; }
;

concourse: Room 'Concourse'
   south = securityGate
;

This still throws an error when attempting to pass through the metal detector. HOWEVER: when I use this code and try an older version of adv3lite (I tried both 2.1.1 and 2.0.0), then it works. The same is true if I use my original, entirely un-minified code. So I think this might be some sort of my-setup-specific regression in adv3lite 2.2.2?? I guess I’ll have to go open an issue on the Github for adv3lite in a moment or two.

I think you may need to change that to explainTravelBarrier(traveler, connector) {

EDIT: Or at least, that would be a short-term fix, but on further investigation I think an inadvertent change has crept into the library here and I need to reverse it. I’ll look into it further, but I think I know what needs to be fixed.

1 Like

This does turn out to be a library bug, I’ve just uploaded the fix to GitHub. The fix incorporates a compatibility switch for code that uses explainTravelBarrier(traveler, connector). So users who encounter this problem in their code can either download the fixed version from GitHub, or else use explainTravelBarrier(traveler, connector) on their TravelConnectors and override TravelConnector.explainTBParams to 2 to maintain compatibility with future releases.

3 Likes

Thanks! Yeah that seems to have fixed it. I appreciate it a lot!