skript-yaml icon indicating copy to clipboard operation
skript-yaml copied to clipboard

Delete value from list

Open oskarkk opened this issue 3 years ago • 2 comments

It seems that there is no straightforward way to find and remove value from yaml list. It would be great if there was an effect equivalent to:

function deleteFromYamlList(file: text, listnode: text, value: text):
  set {_list::*} to yaml list {_listnode} from {_file}
  loop {_list::*}:
    if loop-value is {_value}:
      set {_n} to loop-index parsed as number
      delete yaml index {_n} of list {_listnode} from {_file}

oskarkk avatar Mar 22 '22 06:03 oskarkk

Gotcha, I'll see what i can do ^.^

Sashie avatar Apr 07 '22 01:04 Sashie

That will be possible in next version Here is an example code:

command /delindex:
	trigger:
		load yaml "plugins/test.yml" as "test"
		set yaml list "Test.index" in "test" to "a", "b" and "c"
		save yaml "test" #Setting Values
		wait 5 seconds
		loop yaml list "Test.index" in "test":
			add 1 to {_amount}
			if loop-value is "c": #Will delete last value
				delete index {_amount} from list "Test.index" in "test"
				save yaml "test"

wallace4BR avatar Nov 19 '22 15:11 wallace4BR