Slippery business with arrays

0 favourites
  • 3 posts
  • EDIT: Never mind! See second post for my dummy solution. <img src="smileys/smiley17.gif" border="0" align="middle" />

    Specifically, with concatenating values from arrays. Look at this small capx: there's two events, one initializing three values in an array and one displaying values in a text object. It isn't behaving quite the way it should, unless I'm just not seeing what's happening here...

    Array (0,0) is 5

    Array (1,0) is 2

    Array (2,0) is 3

    I tried displaying "Array.At(0,0)&Array.At(1,0)", thinking I'd get "5" and "2" concatenated together, but instead I get... drumroll please... 1. <img src="smileys/smiley5.gif" border="0" align="middle" /> It just says "1". Why is that?

    dl.dropbox.com/u/19702035/arrayconcat.capx

    Oddly enough, that's not even what I was trying to test with this small capx. I was going to try to display "Array.At(0,0)&Array.At(Array.At(1,0),0)", with the expected result of "53", but I didn't even get that far. (In my larger project, trying to do something like that makes the game not load in previews. In this capx, it comes out to... "1". <img src="smileys/smiley18.gif" border="0" align="middle" />)

  • AH. I see what's happening there. It's taking & to mean the logical AND rather than the concatenation I was expecting. Adding &""& in the middle seems to fix that problem.

    Uhh... yeah. That solves that. <img src="smileys/smiley9.gif" border="0" align="middle" />

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • The proper way to do that is

    str(Array.At(0,0))&Array.At(1,0)

    You have to convert integer type into string type for the concatenation to work. Once you have a base string, all that is concatenated to it will be converted.

    Also the bitwise operation 5 & 2

    in binary looks lik 0101 & 0010 = 0000 not 1

    1 probably means "it's not null or false" or something like that.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)