Hey! Im really bad at explaining but its supposed to when i mine it just adds 1 experience and when i mine it just works and updates the xp but when i go after 127 it goes into minus (-127) and then counting like -126 -125 -124 and this keeps happening. Can someone help? Heres my full code:
[doublepost=1625674486,1625598718][/doublepost]Hello? Anyone? If its not clear please tell me.
[doublepost=1625760818][/doublepost]bump
[doublepost=1625837547][/doublepost]bump
[doublepost=1626016973][/doublepost]Okay very helpfull..............
Code:
function setItemTag(item: item, tag: string, value: object) :: item:
set {_nbt} to nbt compound of {_item}
set tag "tag;custom;%{_tag}%" of {_nbt} to {_value}
return item from nbt {_nbt}
function getItemTag(item: item, tag: string) :: object:
set {_tag} to tag "custom;%{_tag}%" of nbt of {_item}
return {_tag}
function removeItemTag(item: item, tag: string) :: item:
set {_nbt} to nbt compound of {_item}
delete tag "tag;custom;%{_tag}%" of {_nbt}
return item from nbt {_nbt}
on break:
if event-block is stone:
if player is holding a diamond pickaxe:
set {_level} to getItemTag(player's tool, "level")
set {_xp} to getItemTag(player's tool, "xp")
set {_xpneeded} to getItemTag(player's tool, "xpneeded")
if {_xp} is less than {_xpneeded}:
set player's tool to setItemTag(player's tool, "xp", {_xp}+1)
set {_xp} to getItemTag(player's tool, "xp")
set 2st line of player's held item's lore to "&aExperience: &2%{_xp}%&a/&2%{_xpneeded}%"
stop
if {_xp} is {_xpneeded}:
set player's tool to setItemTag(player's tool, "xp", 0)
set player's tool to setItemTag(player's tool, "xpneeded", {_xpneeded}*1.25)
set player's tool to setItemTag(player's tool, "level", {_level}+1)
set {_level} to getItemTag(player's tool, "level")
set {_xp} to getItemTag(player's tool, "xp")
set {_xpneeded} to getItemTag(player's tool, "xpneeded")
set 1st line of player's held item's lore to "&9Level: &b%{_level}%"
set 2st line of player's held item's lore to "&aExperience: &2%{_xp}%&a/&2%{_xpneeded}%"
message "&aYou leveled up! (%{_level}%&a)"
stop
[doublepost=1625760818][/doublepost]bump
[doublepost=1625837547][/doublepost]bump
[doublepost=1626016973][/doublepost]Okay very helpfull..............
Last edited: