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.

Solved Check lore

Discussion in 'Skript' started by NewbyZ, Aug 19, 2017.

Thread Status:
Not open for further replies.
  1. NewbyZ

    NewbyZ Member

    Joined:
    Jan 26, 2017
    Messages:
    75
    Likes Received:
    2
    How can I detect the line in which the lore contains a text?

    Example lore:
    1º line: Test
    2º line: Hello
    3º line: Test

    Any way to detect that "Hello" is on the second line?

     
  2. Best Answer:
    Post #5 by ShaneBee, Aug 20, 2017
  3. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    command /giveitem:
    trigger:
    give player a diamond hoe named "test" with lore "test||hallo"

    command /lore:
    trigger:
    set {_lore} to lore of player's tool
    set {_lore::*} to split {_lore} by "||"
    if {_lore::2} is "hallo":
    send "&aSucces"
     
  4. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    Code (Skript):
    1. If the 2nd line of the lore of the player's tool is "lore here":
    I believe this would work if memory serves, not at home to test
     
    Purplebelt1 likes this.
  5. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    What I look for is to know in which line is x text, not knowing if in x line is x text.
     
  6. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    So, you have two items:

    The first one has the following lore:
    Code (Text):
    1. Hi
    2. how are you
    3. today
    The second one has the following:
    Code (Text):
    1. Hi
    2. today
    3. how are you
    And you want to know in which line "today" is, right?

    So, after executing the code, the first item would return that today is on line 3, and the second one, that it's on line 2.
    ...Correct? Is that what you want?

    You can split code using the following syntax:
    Code (Skript):
    1. set %variable% to %text% split at %text%
    For example,
    Code (Skript):
    1. set {_split::*} to "lore line 1||lore line 2||lore line 3" split at "||"
    I'm not sure how this works if the delimiter is present more than once.
    If it's consistent, it will create {_split::1} with the text "lore line 1", {_split::2} with the text "lore line 2", and {_split::3} with the text "lore line 3".

    Assuming it works this way, as i have no clue if it's the case (can't access a mc server with Skript right now), the code would be as it follows:

    Code (Skript):
    1. #{_item} contains the item whose lore you want to check
    2. set {_split::*} to lore of {_item} split at "||"
    3. set {_found} to false
    4. loop {_split::*}:
    5.     "%loop-value%" contains "today"
    6.     set {_found} to "%loop-index%"
    7.     stop loop
    8. {_found} is false:
    9.     message "The string 'today' was not found on the item's lore."
    10.     stop
    11. message "The text 'today' was found on the line %{_found}%"
     
    Wynnevir and NewbyZ like this.
  7. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    234
    Nice! Thanks :emoji_grinning:
     
Thread Status:
Not open for further replies.

Share This Page

Loading...