User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11

Thread: How do I make it so a string displays two digits instead of one.

  1. #1
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)iOS Export Module (Steam)

    Join Date
    Nov 2022
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I make it so a string displays two digits instead of one.

    Mainly cause I wanna emulate a digital clock, and try making visible timers. I have grown quite reliant on strings so I can make better scores or times and such.

    I want-
    10:07

    not

    10:7


    Thank you for your time, the system I made relies on multiple counters using the Str$ function in selecting an alterable string. It tells the string to update constantly based on the values of the counter.

  2. #2
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Volnaiskra's Avatar
    Join Date
    Jan 2014
    Location
    www.sprykegame.com
    Posts
    3,090
    Mentioned
    133 Post(s)
    Tagged
    0 Thread(s)
    The following methods will turn 7 into 07 (without turning 77 into 077).

    1. (Probably the easiest method). Use the Set Leading Zeros and N Digits After Decimal Point extension:





    Use the Set Leading Zeroes expression, as shown below. As you can see, the first parameter is the input string, which in the above example is Str$(7). The second parameter is how many digits you want it to be (in your case, you want it to be 2 digits long):






    2. The extensionless method. What this does is prefixes a "0" to your text, and then trims it to exactly 2 digits. So "77" becomes "077" then is immediately trimmed to "77". While "7" becomes "07" then remains untrimmed because it's already only 2 digits:





    You can just type it, or find the expression here:






    Although both methods are similar in length, the benefit of the extension method is that you don't need to remember how to formulate it. It also arguably makes your code a bit more readable in future, because the purpose of the code will become obvious as soon as you notice which extension it uses. Whereas when you look at Right$("0" + Str$(7), 2) in 18 months, you might not immediately recognise what it's for.

  3. #3
    Clicker Install Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)Firefly 3D Module (Steam)
    defisym's Avatar
    Join Date
    Jun 2017
    Location
    Asia
    Posts
    562
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    If you know Cpp then you can use printf or std::format to handle it. It's much easier than tweaking events in fusion.

  4. #4
    Clicker Fusion 2.5 Mac
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jan 2015
    Location
    Australia
    Posts
    310
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    Another extensionless method:


    add the number to 100 so that it always has a zero in front, convert it to a string with Str$, then use Right$ to only pick the last two digits

    edit: ah, didn't properly read the previous posts, this is basically the same as the Volnaiskra's second solution

  5. #5
    Clicker

    Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)Firefly 3D Module (Steam)

    Join Date
    Jun 2006
    Location
    Killeen, TEXAS
    Posts
    1,193
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    ive done clocks many times; they way ive done it is like whats suggested above; tho i check the seconds; eg:

    if seconds <10 then secondSTRING$=right$("0"+str$(seconds),2)
    if seconds >=10 then secondSTRING$=str$(seconds)

    same with minutes >59 - i set back to 0, and add the hour.. etc

    time$= hoursSTRING$+":"+minutesSTRING$+":"+secondsSTRING$ <- these are just ALTstrings

    seconds, minutes etc; are just hidden counters or a stored value.

  6. #6
    Clicker

    Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleFirefly 3D ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)Firefly 3D Module (Steam)
    pradeep's Avatar
    Join Date
    Dec 2013
    Location
    India
    Posts
    427
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Raccoon_Guy View Post
    Mainly cause I wanna emulate a digital clock, and try making visible timers. I have grown quite reliant on strings so I can make better scores or times and such.

    I want-
    10:07

    not

    10:7


    Thank you for your time, the system I made relies on multiple counters using the Str$ function in selecting an alterable string. It tells the string to update constantly based on the values of the counter.
    I used in my app
    Time Hr:Min:Sec
    DD:MM:YYYY
    Code in 7 lines
    clickstore.clickteam.com : String Displays Two Digits.
    Digital clock on String objet and Surface object
    Attached files Attached files

  7. #7
    Forum Moderator

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export ModuleInstall Creator Pro
    nivram's Avatar
    Join Date
    Jul 2006
    Location
    Bandon, Oregon
    Posts
    6,837
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pradeep View Post
    I used in my app
    Time Hr:Min:Sec
    DD:MM:YYYY
    Attachment 31941
    The link you specified is not valid.

    Marv
    ​458 TGF to CTF 2.5+ Examples and games
    http://www.castles-of-britain.com/mmf2examples.htm

  8. #8
    Clicker

    Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleFirefly 3D ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)Firefly 3D Module (Steam)
    pradeep's Avatar
    Join Date
    Dec 2013
    Location
    India
    Posts
    427
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by nivram View Post
    The link you specified is not valid.

    Marv
    check again plz

  9. #9
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export Module
    VBEinc's Avatar
    Join Date
    Oct 2015
    Posts
    751
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pradeep View Post
    check again plz
    Worked for me! Nice!
    Honestly though, I think this should just be something in fusion without having to recode it in Strings or at Least. Make it so the Digital clock can be over other object instead of being forced to the background, forcing users to use strings or counters to show the clock over graphics.

  10. #10
    Clicker

    Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleFirefly 3D ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)Firefly 3D Module (Steam)
    pradeep's Avatar
    Join Date
    Dec 2013
    Location
    India
    Posts
    427
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    clickstore.clickteam.com : String Displays Two Digits.
    Digital clock on String objet and Surface object
    Code in 7 lines

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Replies: 0
    Last Post: 20th July 2018, 02:45 PM
  2. > 16 significant digits?
    By Bipolar_Games in forum Multimedia Fusion 2 - Technical Support
    Replies: 7
    Last Post: 14th July 2012, 05:43 AM
  3. Make String Bigger?
    By RickyRombo in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 3rd July 2009, 04:59 AM
  4. Limiting digits
    By MechatheSlag in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 27th February 2009, 07:20 AM
  5. Force 2 Digits
    By sns2015 in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 26th September 2008, 11:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •