[scarpet][suggestion]add a function to modify the criterion of the scoreboards.
Harveykang opened this issue · 11 comments
I just want to keep the data from the scoreboard of the previous version, but I don't want it to continue scoring, so the program needs to change its criteria to dummy
we should just modify so call to scoreboard_add(objective, criterion?)
for known objective modifies it instead of doing nothing.
potentially deprecate scoreboard_add and replace with scoreboard_set() so the name makes more sense.
I started working on this for a PR, but i found that the criterion
field in the ScoreboardObjective
class is final, and doesnt have a method to assign it, so changing it is definetly not intended. It could be done by just saving all the values and settings of it, delete it, and just constructing a new one, but that definetly not good. And if it really needs to be done, re-creating an objective could be done in scarpet too (or just have two objectives in the first place, with one being dummy, and swap values between it)
I thought adding a dedicated function can improve the efficiency of running, but it's ok without adding. Anyway, thank you for your work :)
If this got implemented into scoreboard_set/add
, it would do exactly the same as if you would recreate the objective with scarpet, and in both ways its not ideal... the efficiency wouldnt be much better either, i can imagine. idk, it just doesnt feel right to do it like that, but im not the one to decide that, gnembon is
I believe you should be able to un-finalize a variable - not sure about that, you can try on the fabric discord.
@Harveykang do you mind checking if this version from the fix provided by @replaceitem does what you expect from it - I don't have an example of a complicated scoreboard to verify that's all there is to it.
https://github.com/gnembon/fabric-carpet/suites/1681215839/artifacts/31451640
for me, it's perfect! ;)
maybe could return 2 when changed the criterion successfully? - although I don't know if that's useful
Hmm youre right, there is no way of knowing if it changed, will add that it returns null if nothing changed (returning numbers isnt normally done to show success, only 1, 0 and null)
well, there are still three logical values, true, false and null. null
can be returned if nothing changed. false
can be returned if nothing new has been added, but only modified and true
if a new objective has been added.
Its all arbitrary, but in this case it covers all the basis.