Trying to set a Text object to a private variable, returns 0

For questions about using Classic.

Post » Tue Jun 16, 2009 2:41 am

Basically, what I'm trying to do is set it up so the name of the room the player is in is displayed on the HUD. I have several tiled background objects that act as floors, and they all have a private variable named RoomName.

I want to make it so that when the player overlaps the floor, the variable RoomName for that object is displayed on the HUD, but for some reason no matter what I do, it always displays 0, even when I set the default text for it to something else.

Any idea what I'm doing wrong?
B
4
G
3
Posts: 31
Reputation: 964

Post » Tue Jun 16, 2009 3:05 am

Hard to say. You should post your .cap so someone can take a look.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Tue Jun 16, 2009 3:32 am

I have a Text object with the default text set to Lobby

Then, I have a tiled background object, with the RoomName varable set to Storage Room

And then, on the "On overlapping object" event for the player with the tiled background, I have it setting the value of the Text object to the RoomName of the tiled background.

If that doesn't help, I'll post the .cap
B
4
G
3
Posts: 31
Reputation: 964

Post » Tue Jun 16, 2009 7:29 am

Setting the value? Or setting the text? They're two different things.

Anyway, it's working for me:
http://files.getdropbox.com/u/529356/rooms.cap

If you can't figure out what's wrong from that .cap then you should post yours.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Tue Jun 16, 2009 11:48 am

use the set text action.
set it to object('roomname') without string "quotes"
should work fine
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

Post » Tue Jun 16, 2009 12:11 pm

Here's the cap file.

http://www.mediafire.com/?kykye2zjizm

And yes, sorry. It's setting the text, not the value.

Also, your .cap file says it was made in a later version of Construct, even though I'm using the most up to date version from the website. Is there a beta out or something?
B
4
G
3
Posts: 31
Reputation: 964

Post » Tue Jun 16, 2009 12:30 pm

[quote="Pythagoras":1j0mj8yl]Also, your .cap file says it was made in a later version of Construct, even though I'm using the most up to date version from the website. Is there a beta out or something?[/quote:1j0mj8yl]

Oops! Sorry about that :P

Yes, there is a new unstable release out:
viewtopic.php?f=2&t=3842

But even though it's labeled "unstable" it's actually pretty stable.




Anyway, here's your problem:



Your variable type is "Number." Set that to "Text" and you'll be good to go.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Tue Jun 16, 2009 1:05 pm

Hmm, I changed it to text, but it still only returns 0. I wonder what else I'm doing wrong.
B
4
G
3
Posts: 31
Reputation: 964

Post » Tue Jun 16, 2009 3:24 pm

it works fine for me, although I had to change it to text, and add a default value



I just changed roomname to text and typed "hello" next to roomname and it worked fine
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Tue Jun 16, 2009 9:52 pm

Ah, I just figured out why It wasn't working.

2 things, the variable was set to number rather than text, and I was checking the collisions for the purely visual animated part of the player, rather than the square mask I'm using for collisions.
B
4
G
3
Posts: 31
Reputation: 964

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests