I have created this script for you that will work as your own identifier "$readyml()" to read files "yml".
But I'm not sure that it will work as effectively if there is another data structure that is different from the one you provided in the example.

Try testing this script code with your file:
Code
alias readyml {
  if (!$1) || (!$2) { echo -a 10* ERROR incorrect parameters: $eval($readyml(filename, section [,N]),0) | halt }
  if (!$exists($1)) { echo -a 10* ERROR file does not exist: $1 | halt }
  var %s $read($1,ntw,$+($2,:)), %r $readn
  if (!%s) { echo -a 10* ERROR section does not exist: $2 | halt }
  if ($readyml_section($1,%r)) {
    if ($3 != $null) {
      if ($3 == 0) return $hget(yml_sect,0).item
      if ($3 > 0) {
        if ($3 > $hget(yml_sect,0).item) { echo -a 10* ERROR there are items in the section: $v2 | halt }
        return $hget(yml_sect,$3)
      }
    }
    else { var %i 1 | while (%i <= $hget(yml_sect,0).item) { echo -a $hget(yml_sect,%i) | inc %i } | halt }
  }
}
alias -l readyml_section {
  .hfree -sw yml_sect | var %p $1, %r $2, %n 1
  while ($true) {
    var %c $calc(%r + %n), %i $read(%p,%c)
    if ($right(%i,1) == :) || (%i == $null) || (%c > $lines(%p)) { return $true }
    if ($left(%i,1) == -) .hadd -m yml_sect %n %i
    inc %n
  }
}


Syntax: $readyml(filename, section [,N])


Test1 - (get all items of a section): //echo -a $readyml(test.yml, BlacklistedBlocks)
Quote
- BEDROCK
- OBSIDIAN
- DIAMOND
- DIORITE

Test2 - (get 3rd item of section): //echo -a $readyml(test.yml, BlacklistedBlocks, 3)
Quote
- DIAMOND

Test3 - (get the number of section items): //echo -a $readyml(test.yml, BlacklistedBlocks, 0)
Quote
4

Test4 - (get the 5th item of the section): //echo -a $readyml(test.yml, BlacklistedBlocks, 5)
Quote
* ERROR there are items in the section: 4


🌐 https://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples