Reading a value from item's lore

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

Allan Noyd

Member
Apr 29, 2021
48
0
6
24
So I want to make a skript that allows players to type command that would transform all their levels into a water bottle (which is held as typing command). The water bottle has custom lore showing amount of levels stored and name including player's display name, so it can't be faked. Upon drinking the bottle, any player doing so will get the levels added to his current XP. So far I managed to do the command for making the bottle, but I can't figure out how to add the stored value.
Code:
command /storexp:
    trigger:
        player is holding water bottle named "Water Bottle"
        set player's held item to water bottle named "<purple>%player's tab list name%'s Experience" with lore "<orange>%player's level%"
        set player's level to 0
It takes the lore as a string not as an integer. How can I go around this?
 
So I want to make a skript that allows players to type command that would transform all their levels into a water bottle (which is held as typing command). The water bottle has custom lore showing amount of levels stored and name including player's display name, so it can't be faked. Upon drinking the bottle, any player doing so will get the levels added to his current XP. So far I managed to do the command for making the bottle, but I can't figure out how to add the stored value.
Code:
command /storexp:
    trigger:
        player is holding water bottle named "Water Bottle"
        set player's held item to water bottle named "<purple>%player's tab list name%'s Experience" with lore "<orange>%player's level%"
        set player's level to 0
It takes the lore as a string not as an integer. How can I go around this?
You need to parse it as an integer/number

uncolored line 1 of lore of ... parsed as integer for example
 
You need to parse it as an integer/number

uncolored line 1 of lore of ... parsed as integer for example
Thank you, it worked! Final skript for anyone in the future:
Code:
command /storexp:
    trigger:
        player is holding water bottle named "Water Bottle"
        set player's held item to water bottle named "<purple>%player's tab list name%'s Experience" with lore "<yellow>Consume to get:" and "<orange>%player's level%"
        set player's level to 0
        
on consume of water bottle:
    item's lore contains "<yellow>Consume to get:"
    add uncolored line 2 of lore of item parsed as integer to player's level
    set player's item to water bottle
 
Status
Not open for further replies.