How do I write out numbers but not add them

I am making a game in which I hit a button and a number is added to a table. The number however, when added should not be added to the existing value (EX: 1+3=4) but placed next to it (1+3=13). How can I make this happen?

Comments

  • fadamionfadamion Member, PRO Posts: 309

    are you saying you want something like. ..1..3 i believe in the mac version. im not entirely sure as i just came from windows and its was "*"

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    The table cell type should be 'text' rather than a number.

    Then you change the table cell value using this formula:

    tableCellValue( game.Table 1 ,1,1).."3"

    Notice the two dots before the "3". This tells it to concatenate the following "3" to the previous number in the cell.

  • MattButlerStudiosMattButlerStudios Member Posts: 486

    @RThurman‌ are the "" required also?

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    @MattButlerStudios said:
    RThurman‌ are the "" required also?

    No, they are not required. (Just an old habit of mine.)

  • MattButlerStudiosMattButlerStudios Member Posts: 486

    @RThurman‌ thanks a lot for this response. You answered my question exactly!

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    Here is a quick demo.

  • SocksSocks London, UK.Member Posts: 12,822
    edited June 2014

    @MattButlerStudios said:
    I am making a game in which I hit a button and a number is added to a table. The number however, when added should not be added to the existing value (EX: 1+3=4) but placed next to it (1+3=13). How can I make this happen?

    Besides the method @RThurman suggests you could also use a simple bit of maths which is:

    (*10)+N

    So in your example the variable N is 3, so we start with 1, multiply it by 10 to get 10 and then add 3, so we get 13.

    Or if we had 8+7 . . . . 8x10 (=80) +7 (=87).

    Or if we had 9+9 . . . . 9x10 (=90) +9 (=99).

    Or if we had 2+6 . . . . 2x10 (=20) +6 (=26).

    . . . . etc

    Although this method, unlike the one suggested by @RThurman doesn't do N numbers bigger than 9 . . . . well, actually it does, but it becomes a little more involved as for every additional digit on the N side of the equation you need to multiply the first part by an additional x10 . . . so 122 + 76 would need to be (*100)+N . . . .

    But as another quick and easy method (*10)+N might be useful in some situations :smile:

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    edited June 2014

    @MattButlerStudios said:
    RThurman‌ thanks a lot for this response. You answered my question exactly!

    You are welcome. Glad its working for you.

    @Socks -- great solution! That way it remains an integer. (Although GameSalad seems to handle attribute type conversion just fine.) Instant steal for me!

  • MattButlerStudiosMattButlerStudios Member Posts: 486

    Thanks for the responses guys. I really appreciate this great support forum that gamesalad has!

  • SlickZeroSlickZero Houston, TexasMember, Sous Chef Posts: 2,870

    @Socks said:
    (*10)+N

    So in your example the variable N is 3, so we start with 1, multiply it by 10 to get 10 and >then add 3, so we get 13.

    Or if we had 8+7 . . . . 8x10 (=80) +7 (=87).
    Or if we had 9+9 . . . . 9x10 (=90) +9 (=99).
    Or if we had 2+6 . . . . 2x10 (=20) +6 (=26).

    . . . . etc

    Although this method, unlike the one suggested by @RThurman doesn't do N numbers >bigger than 9 . . . . well, actually it does, but it becomes a little more involved as for >every additional digit on the N side of the equation you need to multiply the first part by >an additional x10 . . . so 122 + 76 would need to be (*100)+N . . . .

    But as another quick and easy method (*10)+N might be useful in some situations :smile:

    I tried to see what I personally could figure out and do with this information, and this is what I came up with -

  • SocksSocks London, UK.Member Posts: 12,822
    edited June 2014

    @RThurman said:
    Socks -- great solution! That way it remains an integer. (Although GameSalad seems to handle attribute type conversion just fine.) Instant steal for me!

    Yeah, GameSalad deals with text attributes in a very flexible sort of way, I was surprised to discover a while back that you can thrown a text attribute (if it is a number) into an equation and it will handle it as a number just fine - so as a simple example adding two text attributes, let's say 50 and 62, will return 112 (which itself can be stored in another text attribute if you want) - which is great, as I'd instinctively expect some sort of error message, saying invalid attribute or something like that, I'd would have thought a text attribute would not be recognised as a number, but as text (even if it was a number).

  • SocksSocks London, UK.Member Posts: 12,822

    @SlickZero said:
    I can count to potato

    :smile:

Sign In or Register to comment.