Skip to content

[Question] Converting from scoreboard to width #1

@NeunEinser

Description

@NeunEinser

So, in the readme you say using "font": "spaces:default" you can avoid a lookup table when having a score and wanting to have a dynamic width.

How exactly does that work though?
Let's say I have calculated I need a width of 134 spaces. So, I'd need to convert the 134 to 5568 (numbers in any order).

Is there an elegant formular for that? Or do you literally just do this in a loop until you get to 0?

execute if score foo bar matches 1..2 run scoreboard players add result bar 9
execute if score foo bar matches 1..2 run scoreboard players remove foo bar 1

execute if score foo bar matches 3..7 run scoreboard players add result bar 8
execute if score foo bar matches 3..7 run scoreboard players remove foo bar 3

execute if score foo bar matches 8..20 run scoreboard players add result bar 7
execute if score foo bar matches 8..20 run scoreboard players remove foo bar 8

execute if score foo bar matches 21..54 run scoreboard players add result bar 6
execute if score foo bar matches 21..54 run scoreboard players remove foo bar 21

execute if score foo bar matches 55..143 run scoreboard players add result bar 5
execute if score foo bar matches 55..143 run scoreboard players remove foo bar 55

execute if score foo bar matches 144..376 run scoreboard players add result bar 4
execute if score foo bar matches 144..376 run scoreboard players remove foo bar 144

execute if score foo bar matches 377..986 run scoreboard players add result bar 3
execute if score foo bar matches 377..986 run scoreboard players remove foo bar 377

execute if score foo bar matches 987..2583 run scoreboard players add result bar 2
execute if score foo bar matches 987..2583 run scoreboard players remove foo bar 987

execute if score foo bar matches 2584.. run scoreboard players add result bar add 1
execute if score foo bar matches 2584.. run scoreboard players remove foo bar add 2584

scoreboard players operation result bar *= 10 const
execute unless score foo bar matches 0 run function <this>

(and if it's negative start with -9 and add 6764 to foo bar)

Or is there a better way that I am not seeing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions