How do I add Letter M when number reaches million

1 favourites
  • 10 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • SORRY FOR BAD ENLISH

    How do I add a M B T

    At the end of a Large number so it doesn't display too many 000000s

  • len(yourtext)=9=m

    len(yourtext)=12=b

    len(yourtext)=16=t

  • Maybe something like:

    score >= 1000000000000

    -> displayText = int(score/1000000000000) & "T"

    else score >= 1000000000

    -> displayText = int(score/1000000000) & "B"

    else score >= 1000000

    -> displayText = int(score/1000000) & "M"

    else

    -> displayText = score

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks everyone appreciate it

  • Sorry for ressurecting this thread. I followed OddConfection instructions and managed to display the numbers how i wanted them as well except for the numbers between 1Million and 10 Million.

    I would like to be able to display for example 1 million and 200 thousand as 1.2 M until it reaches 10 million, but i don´t seem to able to do that.

    Would anyone be kind enough to teach me?

    Thanks in advance.

  • Husui

    I've added in something so values over 10M are treated the same as before, but values between 1M and 10M are rounded to 1 decimal place.

    score >= 1000000000000

    -> displayText = int(score/1000000000000) & "T"

    else score >= 1000000000

    -> displayText = int(score/1000000000) & "B"

    else score >= 10000000

    -> displayText = int(score/1000000) & "M"

    else score >= 1000000

    -> displayText = int(score/100000)/10 & "M"

    else

    -> displayText = score

  • OddConfection

    Damn, thanks alot for your help now im one step closer to making my game come true.

    Thanks a million.

  • Good afternoon, I'm having difficulty getting M (million) K in my code, somehow simple, because I need it for more than one place, for example, I need the X value to be different from the Y value, but each one of them need to appear K or M if it passes a thousand or million, not 1,200,000.

    I would just appear for example 1.2M.

    Will I need to repeat the code in all the parts that will be made?

    What is the best way to do it? Thanks in advance

    I want some like this....

  • Good afternoon, I'm having difficulty getting M (million) K in my code, somehow simple, because I need it for more than one place, for example, I need the X value to be different from the Y value, but each one of them need to appear K or M if it passes a thousand or million, not 1,200,000.

    I would just appear for example 1.2M.

    Will I need to repeat the code in all the parts that will be made?

    What is the best way to do it? Thanks in advance

    You can use a Function to convert the number, then you just need to put a Function.Call(...) into your "Set Text" events.

    Here is an example capx: dropbox.com/s/ewwpxwd56xb6rhi/ConvertNumberToText%20Function.capx

    Add the Function object to your project if you haven't already done so, then copy and paste the Function-> On "ConvertNumberToText" event from the example into your project.

    Then everywhere you have Set text to CustoClicker replace it with Set text to Function.Call("ConvertNumberToText", CustoClicker)

    And everywhere you have Set text to Clickers replace it with Set text to Function.Call("ConvertNumberToText", Clickers)

    UPDATE

    I made a c3p example since the Function object has been replaced in C3

    dropbox.com/s/9tcry1jjyfomfkw/Number%20Function.c3p

  • > Good afternoon, I'm having difficulty getting M (million) K in my code, somehow simple, because I need it for more than one place, for example, I need the X value to be different from the Y value, but each one of them need to appear K or M if it passes a thousand or million, not 1,200,000.

    > I would just appear for example 1.2M.

    > Will I need to repeat the code in all the parts that will be made?

    > What is the best way to do it? Thanks in advance

    You can use a Function to convert the number, then you just need to put a Function.Call(...) into your "Set Text" events.

    Here is an example capx: dropbox.com/s/ewwpxwd56xb6rhi/ConvertNumberToText%20Function.capx

    Add the Function object to your project if you haven't already done so, then copy and paste the Function-> On "ConvertNumberToText" event from the example into your project.

    Then everywhere you have Set text to CustoClicker replace it with Set text to Function.Call("ConvertNumberToText", CustoClicker)

    And everywhere you have Set text to Clickers replace it with Set text to Function.Call("ConvertNumberToText", Clickers)

    THIS REALLY WORKS FOR ME

    Really Really THank You.

    =)

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