call method

Object? call()

Attempts to find the metamethod '__call' and if found, executes its closure. Otherwise this throws an error.

Implementation

Object? call() {
  uses++;
  return switch (skipSemanitcs) {
    true => () {
      return LuaObject.noSemantics('${id}_metamethod__call');
    },
    false => switch (fieldValueAs<Function>('__call')) {
      final Function func => func(),
      _ => throw 'No metamethod "__call" on "$id".',
    },
  };
}