Can't reference numbered layouts

0 favourites
  • 4 posts
From the Asset Store
Jump on numbers in the proper order and reach the sun!
  • Problem Description

    I am unable to reference a numerically named layout using the value of a global number variable.

    Attach a Capx

    ht*tp*s:/*/*drive.google.com/file/d/0B7IHutHbyg8dMkhYYlNWbHNtWDQ/view?usp=sharing

    (dunno how to invoke a download automatically, you can download from an icon at the top of the page)

    Description of Capx

    There is a "main" layout which should be the layout you run, it has a button which takes you to a "UI" layout that has a globalised text object for demonstration purposes, The "main" layout has an event sheet, and "UI" has a separate event sheet. There is also a layout called "1", which has a green square on it so you know when the layout is open due to it's presence.

    Steps to Reproduce Bug

      Run layout from "Main" Click button

    Observed Result

    Starting the Main layout and clicking the button takes you to UI layout, then nothing happens. Text is present as expected but process stops there. Debug mode shows that the global value WAS incremented to expected value. (1)

    Expected Result

    Starting the Main layout and clicking the button takes you to the UI layout, showing the text object, the global variable "CurrentLevel" is incremented from 0 to 1, then the level 1 layout should load, showing the green square alongside the text brought over from the UI layout.

    Affected Browsers

    • Chrome: YES
    • FireFox: YES
    • Internet Explorer: YES

    Operating System and Service Pack

    Windows 10 (Home) Latest updates are installed.

    Construct 2 Version ID

    release 227 (64-bit)

    I theorise that this is due to the global number variable being just that, a number, rather than a string, which the name of the layout is, the difference in datatypes is making C2 frown upon my event sheet, despite visibly the number and the string look the same, they are, on a computer-y level, different things.

  • You're right that it should be a string. You can convert a number to a string with the str() expression.

    Go to layout: str(CurrentLevel)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You're right that it should be a string. You can convert a number to a string with the str() expression.

    Go to layout: str(CurrentLevel)

    Thank you very much, I'll get to putting this in now!

    hey that's twice you've helped me now!

  • Closing as not a bug - you need to give a layout name as a string, not a number.

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