Can't reference numbered layouts

Bugs will be moved here once resolved.

Post » Sat Apr 30, 2016 9:27 pm

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
[list=]
Run layout from "Main"
Click button
[/list]

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.
B
11
S
3
Posts: 4
Reputation: 850

Post » Sat Apr 30, 2016 10:06 pm

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)
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,650

Post » Sun May 01, 2016 11:01 am

ramones wrote: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! :D
B
11
S
3
Posts: 4
Reputation: 850

Post » Mon May 02, 2016 1:30 pm

Closing as not a bug - you need to give a layout name as a string, not a number.
Scirra Founder
B
397
S
236
G
88
Posts: 24,412
Reputation: 194,514


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 1 guest