[Solved] Function starts giving Wrong Results

Bugs will be moved here once resolved.

Post » Mon Aug 29, 2016 12:53 am

Solved:
trouble-operating-returnvalue_p1064184?#p1064184

Problem Description
After triggering a chain of functions that does literally nothing, the one function that does an actual thing quits giving the right result.

Attach a Capx
https://filebin.net/g3iiun5rydcxsar7
Image

Description of Capx
A function "Zéro" changes its return value twice: first to 100, then under a specific condition to 0. the final result is displayed onscreen.
When pressing Space, a function "Wreck" is called, it then calls another function which does nothing.

Expected Result
The condition to change Zéro()'s result 0 should always be right and thus, the function Zéro() should always return 0


Steps to Reproduce Bug
After running the project, simply press Space to call Wreck().
-> The result of Zéro() changes to 100, and remains this way.

Observed Result
- The event 2 needs to be comparing Function.ReturnValue in order for the bug to happen.
- The function called by Wreck() doesn't need to exist, but there need to be at least two chained calls.

Affected Browsers
  • Chrome: (YES)
  • FireFox: (YES)
  • Edge: (YES)

Operating System and Service Pack
Windows 10

Construct 2 Version ID
r233
Last edited by Estecka on Tue Aug 30, 2016 11:53 am, edited 2 times in total.
B
7
S
3
G
3
Posts: 56
Reputation: 2,240

Post » Mon Aug 29, 2016 12:34 pm

Way i understood functions so far .... Function.ReturnValue has only a meaning outside the function, and it is the return from the last function call. Its gets set on 'leaving the function'.

If i am correct, then you can not use it that way. Have to make a local variable and, evaluate that one, and set the return based on the outcome.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Mon Aug 29, 2016 3:14 pm

Exactly. That's how functions work.
You can change the return value during the function's events
but when you call a function, the expected return value is
the last operation that happened to it in a function block,
B
48
S
13
Posts: 111
Reputation: 3,864

Post » Wed Aug 31, 2016 12:47 pm

Closing as @99Instances2Go is right, the return value is set by the last completing function, it does not access the current function's return value.
Scirra Founder
B
395
S
231
G
88
Posts: 24,367
Reputation: 193,684


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 2 guests