private int distanceGetValue (LuaCallFrame callFrame, int nArguments) {
        double a = LuaState.fromDouble(callFrame.get(0));
        String b = (String)callFrame.get(1);
        double dist = ZonePoint.convertDistanceTo(a, b);
        callFrame.push(LuaState.toDouble(dist));
        return 1;
    }
Distance object's fake GetValue or __call method

Called from Lua code: dist:GetValue("metres") or dist("ft"),
where 'dist' is double, converts the number to specified units
and returns as double.
main/src/main/java/cgeo/geocaching/wherigo/openwig/WherigoLib.java