Function Parameters

This forum is currently in read-only mode.
  • Hello.

    I was going to try to make my events cleaner by making all the instances where I play sound be run through a function, since I always have at least three actions for playing sound (autoplay, frequency, position and sometimes volume changes) so I thought I'd make it into one neat line.

    But then you have to add parameters with an action each for functions, so I'd end up with as many actions, plus one to execute the function...

    Is this because starting the Function is a string? Couldn't the parameters be added in a field below where you enter the name, seeing as you can write Function.Fishvolley(X, Y, Z) inside expressions anyway?

    I'm fine without that support, I just hate lots of clutter.

  • I agree, a field to put parameters would be helpful. However, one way to kind of clean it up at the moment is to have a global variable dedicated to calling functions, calling the function in a "Set global variable" action with all of the parameters.

  • I think it's because the object doesn't have a fixed number of parameters. So the only way to have variable number of parameters is to take them one by one.

    Yeah it's cluttery, but I can't think of a better way.

  • What about the way of just writing "(12, 596, 271... )" in that extra field?

    I guess it conflicts with the rules of the expression editor somehow. But then make that some expression you can retrieve from the Function plugin like "Function.SetParam(12, 596, 271... )", maybe?

    EDIT: Linkman2004, that was a clever way of doing it, although it doesn't seem to be able to remember what sound to play... can you not use strings as parameters, or can you not load a resource using an expression?

    EDIT THE SECOND: Apparently I have to name the sample by index number (its place in the resource list).

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • you can have a function with numbers and strings, well i use it and it seems to work

    i just use a textobject , here in example "functiontext" is the textobject

    -> functiontext: Set text to Function.createsquad(base.ImagePointX("point"),base.ImagePointY("point"),1,5,10,"attacker")

  • Yes, the problem was getting XAudio2 to play a resource by a name that I gave it.

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