Function Parameters

For questions about using Classic.

Post » Wed Dec 30, 2009 5:56 am

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.
B
5
S
2
G
3
Posts: 234
Reputation: 1,818

Post » Wed Dec 30, 2009 6:02 am

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.
Moderator
B
98
S
37
G
19
Posts: 1,584
Reputation: 17,817

Post » Wed Dec 30, 2009 7:06 am

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.
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Wed Dec 30, 2009 10:15 am

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).
B
5
S
2
G
3
Posts: 234
Reputation: 1,818

Post » Wed Dec 30, 2009 3:58 pm

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")
B
2
G
3
Posts: 72
Reputation: 994

Post » Wed Dec 30, 2009 4:39 pm

Yes, the problem was getting XAudio2 to play a resource by a name that I gave it.
B
5
S
2
G
3
Posts: 234
Reputation: 1,818


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests