Is System Wait meant to clear Function Parameters?

0 favourites
  • 4 posts
From the Asset Store
Basics sprites and tilesets to build a platformer game or prototype
  • 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

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

  • 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

  • Try Construct 3

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

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

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