[Solved] Function starts giving Wrong Results

0 favourites
  • 4 posts
From the Asset Store
Every game developer starts with an idea, and it can come from anything:
  • 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

    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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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,

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)