Generating the second variable (essentially text, from a number)

I have the numerical star rating stored as a variable: %Variable%stars_how_many%

I wish to create a second variable called %Variable%stars_rendered_for_discord%

Is there a formula or technique to get every single combination? (0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0) Actually, come to think of it, the number could be anything between 0-5, i would need to round up or down to the nearest 0.5... I know how to do that using KM.

I can't think of a way to generate the new variable? Can I use a forumula to create the new variable?

Is there a way to represent 5x as xxxxx, or 3x as xxx ?

I'm sure there's a lot of ways to do this! If you already have the number rounded to the nearest .5, you could just use a TRUNC function in combination with pulling the decimal digit from the variable as an array with '.' as the custom separator, along with a few loops. This is using global variables, so you'd need to switch to local variables or clear them to use it repeatedly.

This also doesn't have any error checking, so it'll fail if you don't have a decimal in the variable, just a quick sketch of one way to approach it.

The 'Empty Stars' block, is a repeat action! I just renamed it.

It's set to execute (5-stars_how_many_whole) times, so if there are 5 full stars, it will execute 0 times.

In that if statement, if there is a .5 in the stars_how_many variable, the stars_how_many_dec, will be '5', so the condition will succeed, add a half star to the output variable, and increment the 'stars_how_many_whole' variable, so that the number of empty stars will be reduced by 1, since a half star should take the space of an empty star, which is calculated in the repeat action "Empty Stars"

Apologies if this was a little obtuse! I didn't do a lot of labeling, or any commenting, this was just a rough sketch. It might not be super clear what i was going for

4.6 Stars is rendering as 4 stars.. unless it's a weird bug

I think 4.5 stars would be more apt?

EDIT: i think it's because TRUNC(4.6) is 4?

EDIT 2: skimming over the code, it seems that if it had been 4.5 then it would have correctly rendered the half star at the end.. but the code doesn't look for that

You mentioned in your original post that you already knew how to round to the nearest .5, so i didnt' include any logic to do so. I think you're better off rounding the initial number to your taste, since adding the conditionals like you did here wouldn't round UP from 4.7, 4.8, 4.9 to 5 stars. Or just only taking increments of .5 as an input.