Function bug

Bugs will be moved here once resolved.

Post » Fri Jul 15, 2016 3:49 am

Problem Description
When using a function, if there is any 'wait' statement within the function, the parameters get wiped.

Attach a Capx
https://drive.google.com/file/d/0B3O5N3 ... sp=sharing

Description of Capx
Run the capx, and upon launching it will show an alert with the parameter 0 which is set to "Test" ... it waits for one frame, then shows it again... this time it's wiped.

Expected Result
I'm pretty sure the parameters shouldn't get wiped... maybe by design?

Affected Browsers
  • Chrome: YES
  • FireFox: YES
  • Internet Explorer: YES

Operating System and Service Pack
Windows 10 64bit

Construct 2 Version ID
Latest - 231
B
47
S
15
G
3
Posts: 201
Reputation: 4,625

Post » Fri Jul 15, 2016 5:38 am

Action wait will hang the remain events, then the function returns ( pop function stack, so parameters was gone )
B
108
S
26
G
258
Posts: 4,430
Reputation: 145,179

Post » Fri Jul 15, 2016 9:39 am

Closing as by design. After the function call ends, the parameters are no longer available. It's like trying to access the function parameters in the next event - you're not in a function call any more.
Scirra Founder
B
387
S
230
G
87
Posts: 24,248
Reputation: 192,238

Post » Fri Jul 15, 2016 10:03 am

A workaround solution is
1. create an official array object at function start
2. storing current parameters into this array object
3. this array object will be keep after action:wait.
4. get parameter value from this array object.
5. remember destroy this array object while leave function.

Here is my plugin to wrap these actions into an action.
B
108
S
26
G
258
Posts: 4,430
Reputation: 145,179

Post » Fri Jul 15, 2016 10:11 am

Besides that this solution is perfect, i cringe by the idea of encouraging the use of 'wait'.

Using 'wait' brings you for kinda sure to the forum for help.
B
33
S
18
G
27
Posts: 2,436
Reputation: 20,336


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 1 guest