ink icon indicating copy to clipboard operation
ink copied to clipboard

External Function with 5 parameters

Open jeuazarru opened this issue 5 years ago • 4 comments

Hello Everyone, I use a lot of External Functions in my ink code, without problems. But the last one I defined, has 5 parameters... And I don't know if that is a problem, but it doesn't work.

Here is my C# definition: OBJECT.story.BindExternalFunction("EvaluarSkill", (string accionaevaluar, string personaje, int dificultad, string versus, string tipo) => { return EvaluarSkill(accionaevaluar, personaje, dificultad, versus, tipo); });

The C# error that I get is: "the delegate 'Func' cannot take 5 elements" or "the delegate 'Func' cannot take 5 arguments" in Unity

The C# function EvaluarSkill has 5 parameters, that is not the problem, and the EXTERNAL definition in ink has also 5 parameters

I have 20 EXTERNAL functions defined in the same way and all others work, except this one.

Can Anyone help me?

Thanks a lot!

jeuazarru avatar Jul 29 '20 21:07 jeuazarru

Re-reading the documentation it seems that I need to use BindExternalFunctionGeneral instead of BindExternalFunction, if I need this number of parameters. Anyone has an example on how to use it? I don't understand how to pass this "object array" from Ink to Unity. If anyone has an example on how to define and call the function in Ink, and how to declare it in Unity, it will be very helpful. Thanks a lot!

jeuazarru avatar Jul 30 '20 16:07 jeuazarru

Solved! got help from a friend with better C# skills that mine.

I did this: (in case it is helpful to somebody else) ThisRun.RunCars[ThisRun.CurrentCar].story.BindExternalFunctionGeneral("EvaluarSkill", (object[] parametros) => { return EvaluarSkill(parametros[0].ToString(), parametros[1].ToString(), (int) parametros[2], parametros[3].ToString(), parametros[4].ToString()); });

On ink side it works in the same way of traditional external functions, no need to change the code

I am worried that this forum has little movements and sometimes nobody answers community questions. That harms the potential growth of Ink engine, as there is little documentation, and no other place where to find resources. Maybe you should set up a small fee to get help or some way to support the developers who are getting into Ink and need help.

I believe also that the problem of pure external functions is something that really needs to change, but that is my vision. Parsing parameters from the text or using tags is messy. Regards!

jeuazarru avatar Jul 30 '20 17:07 jeuazarru

Hello I have the exact issue as you, but I am struggling to understand your solution. I get these two errors. Screenshot 2022-09-12 162709

Akua12 avatar Sep 12 '22 20:09 Akua12

Hello I have the exact issue as you, but I am struggling to understand your solution. I get these two errors. Screenshot 2022-09-12 162709

Can you copy the code you are trying to do ? On one side, the ink function you are trying to bind, and on the other side, how you are trying to bind it in C#?

Are you sure that's good to reactivate a thread from two years ago, and of another ink version?

Selsynn avatar Sep 12 '22 20:09 Selsynn