Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Converting from scoreboard to width #1

Open
NeunEinser opened this issue Apr 2, 2021 · 0 comments
Open

[Question] Converting from scoreboard to width #1

NeunEinser opened this issue Apr 2, 2021 · 0 comments

Comments

@NeunEinser
Copy link

NeunEinser commented Apr 2, 2021

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant