How do I write out numbers but not add them
MattButlerStudios
Member Posts: 486
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
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 "*"
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.
@RThurman are the "" required also?
www.mbstudios.co | Free Stuff
No, they are not required. (Just an old habit of mine.)
@RThurman thanks a lot for this response. You answered my question exactly!
www.mbstudios.co | Free Stuff
Here is a quick demo.
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
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!
Thanks for the responses guys. I really appreciate this great support forum that gamesalad has!
www.mbstudios.co | Free Stuff
I tried to see what I personally could figure out and do with this information, and this is what I came up with -
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).