Check: local var stack not big enough

  • Problem Description

    Using a timer to edit local variable works once but then repeat calls fails with the "Check: local var stack not big enough" message in the console. Seems to work if I make the variables global instead of local.

    Attach a Capx

    dl.dropboxusercontent.com/u/71308871/c2-timer-local-variable/timerlocalvariable.capx

    Description of Capx

    A sprite has a Timer behavior that decrements a local variable and updates it's display in a text box every second.

    Steps to Reproduce Bug

    • Preview project

    Observed Result

    Runs properly once, but further calls show message in the console

    Expected Result

    Variable gets decremented and text gets updated

    Affected Browsers

    • Chrome: (YES)
    • FireFox: (YES/NO)
    • Internet Explorer: (YES/NO)

    Operating System and Service Pack

    Windows 10

    Construct 2 Version ID

    Release 216 (64-bit)

  • I don't think this is a bug. Non-static local variables are reset to their initial value when they are "run" (i.e. imagine an "every tick" event in the same position resetting the variable). So first of all a local variable is not suitable for a countdown that needs to remember its old value. Secondly that message is just a debug note. I've removed it for the next build since it doesn't really matter. It's a bit unusual to access local variables from a trigger, because local variables only really "exist" for the normal run of evaluated events within their group - and triggers fire outside of that. So it's taking a "this variable doesn't exist" code path (which previously logged a debug message), and falling back to returning the initial value.

    Making the variable static also works, since that stops it resetting every tick and makes its lifetime permanent.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ah, I see. Thanks for the thorough explanation and the static fix. Still working on shifting my head from vanilla JS to this setup.

    Thanks for the awesome program!

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