switch attached to a lua callback