Alternatives/Different ways to write this logic...
I need to write a function, that when inputed with an ID, will output the player associated with that ID. (ID's are stored in a scoreboard.)
For example:
Scoreboard called playerid that contains the following:
Continue to help postSteve: 8665, Alex: 2485, Equinox: 8776
If I were to run the command /function namespace:id_to_player {id:8665}
It should output Alex
This is the code I've come up with:
(Reason for tag is to make the output only display for the player that ran the cmd)
json $scoreboard players set $payee payee $(id) tag @s add .this execute as @a if score @s playerid = $payee payee run tellraw @a[tag=.this] {"selector":"@s","color":"aqua"} tag @s remove .this
Although it works as intended, it seems a little repetitive and un-optimized.
Is there a better way to do this?
Sometimes seeing other people's perspectives can help.
[Info: 1.20.6]