Problem with Set Text

Just started using Construct 2? Post your questions here

Post » Mon Aug 22, 2016 3:36 pm

Hi,

I'm doing the BobblePop tutorial in LevelZero and I'm having a problem with Set Text actions.
I'm supposed to create two actions, one for Score and one for Lives. So I do the one for
Score and the action reads Set text to "Score:" &Score, and it works when I run the game.
Then when I try to set up the Set Text action for Lives, I get to the box for Parameters for
Lives: Set text. I put in "Lives:" &Lives. The Objects with Expressions box starts flashing,
and on the Parameters box I get the message, 'Lives needs an expression after it. Lives is
an expression name and you need a dot and an expression name after it.' What's my problem
here?

Thanks,
Willow
B
7
S
1
Posts: 6
Reputation: 387

Post » Mon Aug 22, 2016 4:32 pm

Did you name your text object "lives"?

I'm assuming "lives" should be a variable, or that you haven't set up the "lives" variable yet.
Mistakes were made.
B
53
S
27
G
114
Posts: 1,699
Reputation: 64,446

Post » Mon Aug 22, 2016 4:57 pm

There is indeed an object named 'Lives'.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Mon Aug 22, 2016 5:24 pm

You can have a variable and object named the same. If you reference the object, it will ask for a "." and parameters in the expression. If you reference the variable, it can stand as is. When typing in "lives", make sure you pick the one that is the variable.

Image

Edit: As a best practice - never name two things the same thing. So use LivesText, or LivesVariable instead if necessary for example.
Last edited by oosyrag on Mon Aug 22, 2016 6:33 pm, edited 1 time in total.
Mistakes were made.
B
53
S
27
G
114
Posts: 1,699
Reputation: 64,446

Post » Mon Aug 22, 2016 6:11 pm

Ha ! @oosyrag now that is clear, where was you when i did exactly that thing ?
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Tue Aug 23, 2016 12:55 am

Thanks oosyrag, I had NOT set up a "Lives" variable and that did the trick.
B
7
S
1
Posts: 6
Reputation: 387


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 2 guests