How to use function variables when function contains waits

Get help using Construct 2

Post » Mon Jul 20, 2015 5:22 am

I have a little problem writing functions with System.Wait in them. For example this works just fine:




but simply adding a wait like


shows this:


and this is because, as I understand, the function parameters are no longer accessible from the point after the Wait, and hence are 0. If we use local variables, the same problem occurs. The scope of the local variables seems to behave similar to the Function parameters, except now the string is blank, so there is nothing to see.


Making the local variables static sort of solves this problem but brings in another issue. Separate calls to the function have access to the same variables, which can lead to unexpected results:


(I've added a random to the Y value to demonstrate that there were two calls that essentially are using the values from the second call.)


One solution might be to pull the wait out of the function. However, if the wait is variable and a part of the function parameters, pulling this out means I have to do the wait before every single call to the function, which is bad design.

My question is, is there a workable way to hold function call specific data between waits that don't interfere with other calls to the function? Function scope variables (that would be passed through to the events after waits) would be very nice to have, and in fact function signatures (with parameter guidance like inbuilt functions) and autogenerated variables in the "On <function>" event would be awesome.

Capx used: ... .capx?dl=1
Posts: 33
Reputation: 710

Post » Sun Aug 23, 2015 9:37 am

Hi, did you find solution? I am strugling with the same problem.
Posts: 3
Reputation: 408

Return to How do I....?

Who is online

Users browsing this forum: totoe and 21 guests