BindExternalFunction4<T1, T2, T3, T4> method

void BindExternalFunction4<T1, T2, T3, T4>(
  1. String funcName,
  2. Object func(
    1. T1 t1,
    2. T2 t2,
    3. T3 t3,
    4. T4 t4,
    ), {
  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 BindExternalFunction4<T1, T2, T3, T4>(
    String funcName, Object Function(T1 t1, T2 t2, T3 t3, T4 t4) func,
    {bool lookaheadSafe = false}) {
  BindExternalFunctionGeneral(funcName, (List<Object> args) {
    assert(args.length == 4, 'External function expected four arguments');
    return func.call(TryCoerce<T1>(args[0]), TryCoerce<T2>(args[1]),
        TryCoerce<T3>(args[2]), TryCoerce<T4>(args[3]));
  }, lookaheadSafe: lookaheadSafe);
}