How to fix numbers in messages (When they appear with .0)

Started by aidanete on

Topic category: User side tutorials

Last seen on 11:16, 14. Oct 2021
Joined Dec 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to fix numbers in messages (When they appear with .0)
Mon, 11/04/2019 - 12:14 (edited)

I actually have found a fix for the numbers in messages.

First: Create a string variable, that will be the stringed version of the number you want. In my case the number variable I want to fix is i, so I will call this _i

Vars

Second: Imagine that i is 8 when you execute the procedure, and we want that to be displayed. Here is the procedure you should add

Vars2

Actually if you try to insert number variable i onto the "of" part of the "replace" block. You will notice that this strangely doesn't work. If you only put 1 part for "create text with" block, the game when compiling will crash, so put 2 and insert the number variable i and an empty text. The with part should have also an empty text.

Third: Put _i where you want to show the variable in text.

 

You can see this in action in my Additional Stuff mod in the latest version. The dice items shows up a random number between 1 and 6, the resulting number doesn't have .0.

Hope this helps you and see you next time :D

 

Edited by aidanete on Mon, 11/04/2019 - 12:14
Last seen on 17:49, 25. Mar 2021
Joined Jun 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Nice tutorial :)
Mon, 11/04/2019 - 13:27

Nice tutorial :)

Nice workaround, although a…
Mon, 11/04/2019 - 16:04

Nice workaround, although a bit hacky :D We plan to add support for number formating in the future updates too ;)

Last seen on 11:16, 14. Oct 2021
Joined Dec 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thank you very much! I had…
Thu, 11/07/2019 - 07:04

Thank you very much! I had the idea a few days ago and I liked it and I wanted to share.