Index in list

  • 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.

rustedst

Active Member
Apr 24, 2020
97
4
8
22
Istanbul, Turkey
So I have a really large list and I want to find the index of an element in that list. Like:
Code:
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:
set the {_i}th element of {exampleList::*} to {otherVariable}
but neither of them don't work.

Any ideas? Thanks
 
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:
{exampleList::1}
and next would be
Code:
{exampleList::2}
and you would set each of those to whatever you want.
Code:
set {exampleList::1} to "blalala"
set {exampleList::2} to "Man, I'm second :("

To do this easier you should create a loop to store the variables.
Code:
loop {_n} times:
  add 1 to {_l}
  set {exampleList::%{_l}%} to {variable}
 
Last edited:
Status
Not open for further replies.