Solved Check 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.

NewbyZ

Member
Jan 26, 2017
75
2
0
25
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?
 
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"
 
So, you have two items:

The first one has the following lore:
Code:
Hi
how are you
today

The second one has the following:
Code:
Hi
today
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_language.skript:
set %variable% to %text% split at %text%
For example,
code_language.skript:
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_language.skript:
#{_item} contains the item whose lore you want to check
set {_split::*} to lore of {_item} split at "||"
set {_found} to false
loop {_split::*}:
    "%loop-value%" contains "today"
    set {_found} to "%loop-index%"
    stop loop
{_found} is false:
    message "The string 'today' was not found on the item's lore."
    stop
message "The text 'today' was found on the line %{_found}%"
 
  • Like
Reactions: Wynnevir and NewbyZ
Status
Not open for further replies.