How to delete entries from multidimensional list var?

  • 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 community!

    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.

pepper82

Member
Jan 26, 2017
272
1
18
Assuming I have a list variable like this:

{kits::%{_kitname}%::items::*}

it contains items

and I have a variable like this:

{kits::%{_kitname}%::items::%loop-index%::unique}

How would I delete the {kits::%{_kitname}%::items::%loop-index%::unique} variable?

I tried:
code_language.skript:
loop {kits::%{_kitname}%::items::*}:
  delete {kits::%{_kitname}%::items::%loop-index%::unique}

But this makes the index unusable until server restart, so that is a no go!

Also tried to remove the whole item:

code_language.skript:
loop {kits::%{_kitname}%::items::*}:
  remove loop-value from {kits::%{_kitname}%::items::*}

This did not work either. The {kits::%{_kitname}%::items::%loop-index%::unique} variable is still there.
[doublepost=1492516697,1492432335][/doublepost]Nobody?
 
When you loop over a list, the sublists aren't looped over. So if your list looked like this:

{example::uno} = 1
{example::two} = 2
{example::sublist::subVal1} = "tree"
{example::sublist::subVal2} = "doorknob"

Looping over {example::*} will only loop over {example::uno} and {example::two}, so the only two loop-indices you'll get are "uno" and "two", you won't loop over "sublist" as well. It's just how Skript works. If you want to loop over an entire list, including all of its sublists, I'd recommend looking at MundoSK's tree loop.
 
Simply put, Skript loops values, not indexes. Indexes without values aren't considered a part of the list.
 
So...
delete {kits::%{_kitname}%::items::%loop-index%::unique}
is the way to go?
 
Status
Not open for further replies.