Carpet

Carpet

2M Downloads

Unable to change display name of scoreboard objectives without using "run('scoreboard ...')" function

James103 opened this issue ยท 3 comments

commented

Currently, if you want to change the display name of a scoreboard objective, you have to do the following:
run('scoreboard objectives modify test displayname {"text":"NAME"}');

Even though Scarpet has its own functions in the scoreboard family to handle many other scoreboard use cases, it is this use case that is not handled, which is changing the display name for the function. I suggest adding a Scarpet function for that, named scoreboard_display_name(objective, display_name) or something similar, which takes in the objective name and either a String or FormattedText for the new display name, and changes the display name of the objective. For example, the above could instead be written as follows:
scoreboard_display_name('test', 'NAME');.

Another example:
Before: run('scoreboard objectives modify test displayname {"text":"NAME", "bold":"true"}');
After: scoreboard_display_name('test', format('b NAME'));

commented

I am currently doing a PR on this, and i was thinking it may be good to sort all the scoreboard functions out a bit.
Currently, scoreboard_add (which will be renamed to scoreboard_set in #717) can also change the criterion of an objective, which is why #672 wanted to change the name to scoreboard_set.
Now that changing display name could also be added, and scoreboard_display can change scoreboard display slot, i think something like a scoreboard_modify function that can change the criterion, display name, display slot and rendertype.
scoreboard_modify(objective,'criterion','dummy')
scoreboard_modify(objective,'display_name',format('r text'))
scoreboard_modify(objective,'display_slot','sidebar')
scoreboard_modify(objective,'render_type','hearts')
I think the scoreboard_add function is very confusing at this point, and moving the criterion changing to an individual function will help with that i think.

commented

Maybe it should be called scoreboard_property to match team_property, and also allow querying

commented

these are good ideas. Would make sense to organize these