BindExternalFunction1<T1> method
void
BindExternalFunction1<T1>(})
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 BindExternalFunction1<T1>(String funcName, Object? Function(T1 t1) func,
{bool lookaheadSafe = false}) {
BindExternalFunctionGeneral(funcName, (List<Object> args) {
assert(args.length == 1, 'External function expected one argument');
return func.call(TryCoerce<T1>(args[0]));
}, lookaheadSafe: lookaheadSafe);
}