1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Reading a value from item's lore

Discussion in 'Skript' started by Allan Noyd, Oct 29, 2021.

Thread Status:
Not open for further replies.
  1. Allan Noyd

    Allan Noyd Member

    Joined:
    Apr 29, 2021
    Messages:
    33
    Likes Received:
    0
    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 (Text):
    1. command /storexp:
    2.     trigger:
    3.         player is holding water bottle named "Water Bottle"
    4.         set player's held item to water bottle named "<purple>%player's tab list name%'s Experience" with lore "<orange>%player's level%"
    5.         set player's level to 0
    It takes the lore as a string not as an integer. How can I go around this?
     
  2. oToghty

    VIP Supporter +

    Joined:
    Sep 1, 2020
    Messages:
    142
    Likes Received:
    5
    You need to parse it as an integer/number

    uncolored line 1 of lore of ... parsed as integer for example
     
  3. Allan Noyd

    Allan Noyd Member

    Joined:
    Apr 29, 2021
    Messages:
    33
    Likes Received:
    0
    Thank you, it worked! Final skript for anyone in the future:
    Code (Text):
    1. command /storexp:
    2.     trigger:
    3.         player is holding water bottle named "Water Bottle"
    4.         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%"
    5.         set player's level to 0
    6.        
    7. on consume of water bottle:
    8.     item's lore contains "<yellow>Consume to get:"
    9.     add uncolored line 2 of lore of item parsed as integer to player's level
    10.     set player's item to water bottle
     
Thread Status:
Not open for further replies.

Share This Page

Loading...