#NBT help

1 messages · Page 1 of 1 (latest)

formal hill
#

Hey, I m new to NBTs things and I tryed to make a code example for my other scripts, using example listed in skhub, and here's my current code but it does not broadcast {_n}, please tell me how can I do that:

    set {_i} to {_p}'s held item
    if nbt compound of {_i} does not have nbt tag "lucky":
        set double tag "lucky" of nbt of {_i} to 3.14
        set {_n} to double tag "lucky" of nbt of {_i}
        remove {_i} from {_p}
        give {_p} {_i}
        broadcast {_n}```
vital ermine
#

You probably need to use int tag instead of double tag, since you are setting it to an integer

formal hill
#

I am setting it to double value

#

@vital ermine am I doing smth wrong

dusk bison
#

you need to use custom nbt
set double nbt tag "lucky" of custom nbt of {_i}...

lethal wadi
#

function luckEnchant(p:player): set {_i} to {_p}'s tool if double tag "lucky" of custom nbt of {_i} is not set: set double tag "lucky" of custom nbt of {_i} to 3.14 set {_n} to double tag "lucky" of custom nbt of {_i} remove {_i} from {_p}'s inventory give {_i} to {_p} broadcast "%{_n}%"

#

this is how I would do it

#

nbt's are changed, to access a custom nbt value and to set one you have to specify it as custom

#

I also didnt test the code so it might not work. 😛

dusk bison
#

Yeah thats the way you should normally do it and that should work

formal hill
#

alr ty fox and tiblolha

formal hill
#
    set {_i} to {_p}'s tool
    if double tag "lucky" of custom nbt of {_i} is not set:
        set double tag "lucky" of custom nbt of {_i} to 3.14
        broadcast 1
    add 3.00 to double tag "lucky" of custom nbt of {_i}
    set {_n} to double tag "lucky" of custom nbt of {_i}
    broadcast {_n}``` can anyone tell me why this won't add 3 to the nbt
lethal wadi
#

What is it broadcasting?

pastel solar
#

working fine for me

#

oh i see

#

wow so this is really weird (i dont use nbt much) but i changed it to:

function luckEnchant(p:player):
    if double tag "lucky" of custom nbt of {_p}'s held item is not set:
        set double tag "lucky" of custom nbt of {_p}'s held item to 3.14
        broadcast 1
    add 3.00 to double tag "lucky" of custom nbt of {_p}'s held item
    set {_n} to double tag "lucky" of custom nbt of {_p}'s held item
    broadcast {_n}

and this worked for me. not really sure why tho

dusk bison
#

It is cause op is setting the nbt to the item in the var and not to the players held item