1

In C programming, I can print numbers with leading 0's like this:

int scoreboard_value_example1 = 214;
int scoreboard_value_example2 = 132424;

printf("%05d, ",scoreboard_value_example1);
printf("%09d",scoreboard_value_example2);

// Output : 00214, 000132424

But I wonder that minecraft has leading 0's output too. If it has, can you tell me how to output like this by tellraw?

m4ndeokyi
  • 23
  • 5

1 Answers1

1

There is definitely not a built-in way to do this. I thought a while about what workarounds there might be, but I've found none, except the obvious:

/execute if score <selector> <objective> matches 100..999 run tellraw <selector> [{"text":"000"},{"score":"<selector>","objective":"<objective>"}]
/execute if score <selector> <objective> matches 1000..9999 run tellraw <selector> [{"text":"00"},{"score":"<selector>","objective":"<objective>"}]
/execute if score <selector> <objective> matches 10000..99999 run tellraw <selector> [{"text":"0"},{"score":"<selector>","objective":"<objective>"}]

...and so on. There just is no proper String handling in Minecraft, you can't crop Strings, search in them, etc., concatenation is pretty much the only standard String actions that works.

1.13 improved number handling a lot, let's hope that one of the next versions does the same for Strings!

Fabian Röling
  • 20,534
  • 6
  • 38
  • 75
  • Someone actually came up with some complicated magic stuff for string handling, maybe this could be used here, but it's definitely not easier: https://youtu.be/lm7nVRARKI0 – Fabian Röling Feb 15 '20 at 14:41