#Is it possible to convert a number in a tag into a score using a macro?
1 messages · Page 1 of 1 (latest)
use /execute store result score <target> <score> run data get entity <target entity> number.5
the /execute store command allows you to store a value to a scoreboard or data tag, by grabbing the output or success state of the following command
Are you talking tag as in added with the /tag command? Or like a proper NBT tag like Health:40.0f?
im pretty sure NBT tag
I could really see it either way
It would be weird to know the NBT path formatting like that without knowing that execute store exists
And plus, no entities natively have NBT that would equate to {number:{5:<integer>}}, and I don't see why a marker that supports arbitrary NBT would be given such data
smart observation
in that case @junior canopy, what kind of tag are you referring to here? is it a tag added by /tag? or do you mean an NBT tag? is "number.5" stored in Tags:["number.5"] or {number:{5:<some value>}}?
I'm under the impression it's /tag tags
In that case, that's possible but not easy
If the entity has multiple tags you'd have to iterate over all tags - copy the Tags list to storage, and while that list is not empty, copy and remove the last bit into some other storage path; eventually you'll get a tag of the form number.x
When that happens you can detect that with data modify ... string to cut the first 7 characters, and execute if data storage ... to check that it is indeed number.
Now stop the loop, and get the substring that starts after the first 7 characters with data modify ... string again; you get a string that only contains the number you want to save
Finally use that in a macro after scoreboard players set
Yeah
This question has been inactive for some time, so it's going to be closed for inactivity. If you still need it, please disregard this message.