Bug in arithmatic on Params when recursing with function

0 favourites
  • 5 posts
From the Asset Store
Match same tiles with each other as fast as you can and earn more score during a limited time!
  • Problem Description

    There is a problem with passing function parameters recursively with arithmetic. I suspect it is a type problem but it isn't solved using int() or str().

    Attach a Capx

    https://1drv.ms/u/s!AjosfNFG8jCjmOQsrzbXcG6GDcnkfA

    Description of Capx

    The capx has a simple function that shows the it's param value on a text, waits, and then recurses adding 1 to it's param. It doesn't work. It should show 0, 1, 2, 3... instead it shoes 0, 1, 1, 1, 1

    There is another version that stores it's param value as a global and then passes the global instead of the param directly. That one works fine.

    Steps to Reproduce Bug

    • The functions run automatically at start.

    Observed Result

    It should show 0, 1, 2, 3...

    Expected Result

    instead it shoes 0, 1, 1, 1, 1...

    Affected Browsers

    • Chrome: ?
    • FireFox: YES
    • Internet Explorer: YES
    • Edge: YES

    Operating System and Service Pack

    Windows 10

    Construct 2 Version ID

    233

  • You can't use Wait in a function. That puts those actions aside and keeps running, so you will have returned from the function before the parameters are accessed.

  • [quote:1ppftphy]You can't use Wait in a function. That puts those actions aside and keeps running, so you will have returned from the function before the parameters are accessed.

    I understand what you are saying but the manual gives no indication that the function doesn't remember the parameters during a wait. The section about the wait action specifically mentions that picked instances are remembered during the wait. Construct 2 allows the use of waits in functions and I can imagine a way that the function would work that it would remember them.

    I still consider this is a bug unless the documentation clarifies not to use waits in a function or to not expect the function to remember its parameters/local variables.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • What if you call some other function within the wait?

  • Closing as this is currently by design: the function call ends immediately after the trigger, and clears its parameters, so if you wait any amount of time the function call has ended and no parameters are available.

    People do keep running in to this so I added a note in the tutorial: https://www.scirra.com/tutorials/56/how-to-use-the-system-wait-actions

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