SambaPOS already stores these local state variables by default. You can access these with setting access syntax.
CURRENTUSER Stores current user name
ENTITYSCREEN Stores current entity screen name
DEPARTMENT Stores active department name
NUMBERPAD Stores current numberpad value
ISLOCKED Useful to determine if there is an active ticket.