How do I call a function with a variable as part of the name?

0 favourites
  • 3 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • In C2 we could just "call function("name"&str(var)) and it would call the function.

    I see the static functions in the "add function" section, no way to set a variable in the name.

    c3_callFunction("Populate_Feed_1"); as a js way of calling it (is it possible to add a variable here?

    I've tried every combination surrounding what I think should work to no avail.

    expample: c3_callFunction("Populate_Feed_"&str(localVars.feed_message_number));

    The only thing I've found that works it to mimic the static call


    Not sure if this is just a syntax issue, or if it's not possible anymore.

    Thanks in advance.

  • Try this:


    or with a global variable:


  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Awesome, ty ever so much! Bookmarked this page.

    On a side note: I assume most people would use function.params to handle things like this and just have 1 really long function with many conditions?

    Other than length of code (mine way will be more lines of code and more functions, but all copy/paste) is there any real advantage in speed, functionality? ie, recursive vs multiple functions*

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