In the 3.x function API use:
lookupvar('varname')
In the 4.x function API use:
closure_scope.lookupvar('varname')
Here is the specification for the 4.x API.
https://github.com/puppetlabs/puppet-specifications/blob/master/language/func-api.md
Also consider looking up the $facts hash instead of directly looking up
individual facts like $clientnoop. This to be future proof. (See the
link you posted regarding details).