Is System Wait meant to clear Function Parameters?

Bugs will be moved here once resolved.

Post » Sun Jun 05, 2016 2:08 am

Problem Description
When calling a function with a parameter set, using a wait inside the function clears it's parameters.
Is this normal?

Attach a Capx
http://aff-gamer.com/waitParam.capx

Description of Capx
This demonstrates that a parameter zeros after a system wait.

Steps to Reproduce Bug
  • new project with 1 global variable, 1 button, 2 text boxes and functions object
  • global variable should equal any number other than 0
  • on start set text.text to global variable
  • on button clicked call function with param(0) set to global variable
  • on function {
  • - set text2.text to function.param(0)
  • - wait 1.0 seconds
  • - append text2.text with function.param(0)

Observed Result
After a system wait, function param always returns 0.

Expected Result
I didn't expect to loose my parameter after a system wait.

Affected Browsers
  • Chrome: (YES)
  • FireFox: (unsure)
  • Internet Explorer: (YES)

Operating System and Service Pack
Windows 10

Construct 2 Version ID
227 64bit
personal licence
B
7
S
1
Posts: 43
Reputation: 513

Post » Sun Jun 05, 2016 4:58 am

It's a known "feature" that function parameters only exist for the function call, and not into the next tick.
The reasoning is the same function can be called multiple times with different params, within the same tick.
Best solution is to store the data in a global.
Image ImageImage
B
172
S
50
G
182
Posts: 8,439
Reputation: 115,097

Post » Mon Jun 06, 2016 11:48 am

per tick, gotcha, ty. It's now officially known to me also. :)
I'm moved my pauses (using wait for signal within it's own function) and refined my code.
I got to many globals already man
B
7
S
1
Posts: 43
Reputation: 513

Post » Mon Jun 20, 2016 2:38 pm

Closing as not a bug. As @newt described, "Wait" doesn't itself clear the function parameters, it's just by the time the next action runs the function call has ended.
Scirra Founder
B
402
S
238
G
89
Posts: 24,632
Reputation: 196,031


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 1 guest