How do I call a function from an Array?

0 favourites
  • 3 posts
From the Asset Store
Voice call plugin based on webrtc protocol for construct 3
  • I have a dialog system using an array that allows the player to select a response (for example Dialog.At(4, 1) == "Take the left path"). And when they select that a function will be called (Dialog.At(5, 1) == "LeftPath").

    I map all the dialog functions and I can call them with a string. But how would I pass the parameters (also in the array for example Dialog.At(6, 1) == "Steep")?

    The "forward parameters" isn't clear to me how it works. I also considered diving into scripting but wasn't sure that's the best way either. I don't see how to access the array from scripting.

    Any help or advice would be appreciated. Thank you!

  • Yeah, the new function maps are very confusing, especially when you need to pass parameters. Have you seen the official "Function maps" template? It explains in detail how to do it.

    As a workaround you can use a global variable instead of the parameter. Set this variable to Dialog.At(6, 1) before calling the function, and read it inside the function.

    To call the function from a script you can try something like this:

    runtime.callFunction("MyFunction", runtime.objects.MyArray.getAt(6,1));

    And another option, which I should probably not be mentioning, is to use the old Function plugin. It is deprecated, but it's much more flexible and allows to call functions by name and pass any number of parameters.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Yeah using the old function system was tempting, but both the scripting and the global variable solution sounds promising. Thanks for the suggestions!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)