How do I concatenate variables?

Get help using Construct 2

Post » Mon Jun 06, 2016 9:55 pm

Hi!,

So, I have 2 vars, example:

x=2
y=1

And I want z to be x and y, one besides the other, not a sum:

z=21

I've been using &, but it is for string concatenation and gives me an error. (z always equals 1 that way).

Thanks!
B
25
S
8
Posts: 81
Reputation: 1,691

Post » Mon Jun 06, 2016 10:34 pm

set z to int(x&y)
B
91
S
31
G
102
Posts: 5,233
Reputation: 67,252

Post » Mon Jun 06, 2016 10:43 pm

R0J0hound wrote:set z to int(x&y)


Tried it and not working :cry:
B
25
S
8
Posts: 81
Reputation: 1,691

Post » Mon Jun 06, 2016 10:58 pm

Okay, use this instead:
str(x)&str(y)

The "&" operator is both string concentration and logical and. If both values are numbers then logical and is used otherwise string concentration is used.
B
91
S
31
G
102
Posts: 5,233
Reputation: 67,252

Post » Mon Jun 06, 2016 11:17 pm

R0J0hound wrote:Okay, use this instead:
str(x)&str(y)

The "&" operator is both string concentration and logical and. If both values are numbers then logical and is used otherwise string concentration is used.


Thanks, it is working now!
B
25
S
8
Posts: 81
Reputation: 1,691


Return to How do I....?

Who is online

Users browsing this forum: Cubus32, tarek2 and 7 guests