Quick Q: Combining variable and string in same field

Get help using Construct 2

Post » Mon Apr 28, 2014 4:39 pm

I have added an option of change different graphics for different themes.
SettingGraphic = 1, 2, 3 etc

and then I make animations in the sprite like these "1Solid", "2Solid" etc...

It works well to do like this: (Set Animation action)
SettingGraphic & "Left"

But NOT this: (pick by Evaluate condition)
TileSprite.AnimationName= SettingGraphic & "Left" - giving type mismatch or other objections.

I hope it is still possible to do this, but formatting it other way?
B
58
S
18
G
13
Posts: 447
Reputation: 10,735

Post » Mon Apr 28, 2014 4:56 pm

Not tested anything but guessing you'll have to convert the number to a string.

TileSprite.AnimationName= str(SettingGraphic) & "Left"
B
46
S
23
G
7
Posts: 459
Reputation: 6,763

Post » Mon Apr 28, 2014 6:11 pm

@Minor

No it would still spit out type mismatch.
Last edited by helena on Mon Apr 28, 2014 6:20 pm, edited 1 time in total.
B
58
S
18
G
13
Posts: 447
Reputation: 10,735

Post » Mon Apr 28, 2014 6:14 pm

I made a solution by adding a variable, and in an event above the actual event, feed the variable with the combined values. But I would prefer to do it in one parameter line. If it is possible.
B
58
S
18
G
13
Posts: 447
Reputation: 10,735

Post » Mon Apr 28, 2014 6:22 pm

You can use "pick by comparison" that allows you to build a string. Looks like "pick by evaluate" is only for numbers.
You do not have the required permissions to view the files attached to this post.
B
46
S
23
G
7
Posts: 459
Reputation: 6,763

Post » Mon Apr 28, 2014 6:42 pm

@Minor

I used the Evaluate for String, but it could be that it can't be too convoluted.

Your suggestion of using Comparison, it works nicely. Thank you.

Cute little sprite icon by the way. :)
B
58
S
18
G
13
Posts: 447
Reputation: 10,735


Return to How do I....?

Who is online

Users browsing this forum: ksiads, Magistross, mtnboy22, Rable and 4 guests