What about instead of checking explicitly if the the left button is a modifier, check if the right button is NOT a modifier?
As you've no doubt already seen, here are the other event modifiers defined in sci.sh:
(define emRIGHT_SHIFT 1)
(define emLEFT_SHIFT 2)
(define emSHIFT 3)
(define emCTRL 4)
(define emALT 8)
(define emSCR_LOCK 16)
(define emNUM_LOCK 32)
(define emCAPS_LOCK 64)
(define emINSERT 128)
(define emLEFT_BUTTON 1)
(define emRIGHT_BUTTON 3)
So you're checking for modifier == 1, which logically means if you're holding shift, or have numlock, scroll lock, or caps lock on, or insert turned on, then the result will NOT be 1. and so the logic check will fail. I've never checked that in code, if numlock, scroll lock, or caps lock are properly detected or cause havock with right-clicking.
I have checked that a right-click is the same as holding shift and left clicking. So that's also something that may be messing with your debugging... seemingly random, but maybe you're accidentally pressing caps lock every other time you type or something.