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.

Index in list

Discussion in 'Skript' started by rustedst, Jul 11, 2021.

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

    rustedst Active Member

    Joined:
    Apr 24, 2020
    Messages:
    97
    Likes Received:
    4
    So I have a really large list and I want to find the index of an element in that list. Like:
    Code (Text):
    1. set {_i} to index of {variable} in {exampleList::*}
    this doesn't work. I don't wanna loop the list to use loop-index because it's too large.
    And then I wanna edit that element and change it. Like:
    Code (Text):
    1. set the {_i}th element of {exampleList::*} to {otherVariable}
    but neither of them don't work.

    Any ideas? Thanks
     
  2. AHappyLittleSloth

    Joined:
    Apr 22, 2020
    Messages:
    48
    Likes Received:
    4
    I have needed to do this before when I was still pretty new to skript. I've been away from minecraft for a while but I remember my work around was to create variables such as
    Code (Text):
    1. {exampleList::1}
    and next would be
    Code (Text):
    1. {exampleList::2}
    and you would set each of those to whatever you want.
    Code (Text):
    1. set {exampleList::1} to "blalala"
    2. set {exampleList::2} to "Man, I'm second :("
    To do this easier you should create a loop to store the variables.
    Code (Text):
    1. loop {_n} times:
    2.   add 1 to {_l}
    3.   set {exampleList::%{_l}%} to {variable}
    4.  
     
    #2 AHappyLittleSloth, Jul 11, 2021
    Last edited: Jul 15, 2021
Thread Status:
Not open for further replies.

Share This Page

Loading...