BindExternalFunction2<T1, T2> method

void BindExternalFunction2<T1, T2>(
  1. String funcName,
  2. Object? func(
    1. T1 t1,
    2. T2 t2
    ), {
  3. bool lookaheadSafe = false,
})

Bind a dart function to an ink EXTERNAL function declaration.

funcName EXTERNAL ink function name to bind to func The dart function to bind. lookaheadSafe The ink engine often evaluates further than you might expect beyond the current line just in case it sees glue that will cause the two lines to become one. In this case it's possible that a function can appear to be called twice instead of just once, and earlier than you expect. If it's safe for your function to be called in this way (since the result and side effect of the function will not change), then you can pass true. Usually, you want to pass false, especially if you want some action to be performed in game code when this function is called.

Implementation

void BindExternalFunction2<T1, T2>(
    String funcName, Object? Function(T1 t1, T2 t2) func,
    {bool lookaheadSafe = false}) {
  BindExternalFunctionGeneral(funcName, (List<Object> args) {
    assert(args.length == 2, 'External function expected two arguments');
    return func.call(TryCoerce<T1>(args[0]), TryCoerce<T2>(args[1]));
  }, lookaheadSafe: lookaheadSafe);
}