There is looping built into jsonformirc. You might consider adding these items to hash tables before writing to ini, I don't know if mIRC will keep the file handle open between all the operations and so many writeinis could take much longer. It takes 10 seconds just to loop and assign variables.

This will loop over every property of every weapon:

Code
alias weapons.store {
  var %stats = $$CoD.Stats($1,$2,$3,$4)

  if (!$hget(cod.weapons)) { weapons.init }

  var %file = $shortfn($mircdirscripts\stats\UserStats.ini)

  var %ref = $json(%stats,data,lifetime,itemData)

  noop $JSONForEach(%ref,weapons.foreach %file).walk
}

alias weapons.foreach {
  var %target = $1, %ref = $2
  var %path = $json(%ref).pathLength
  var %weaponapi = $jsonpath(%ref,$calc(%path - 2))
  var %weapon = $weapons.enum(%weaponapi)
  var %prop = $jsonpath(%ref,%path)
  var %value = $round($json(%ref).value,2)

  echo -ag %target %weapon %prop %value
}

alias weapons.enum {
  if ($hget(cod.weapons,$1)) { return $v1 }
  return $1
}

alias weapons.init {
  hmake cod.weapons
  hadd cod.weapons iw8_sn_crossbow CrossBow
  hadd cod.weapons iw8_sn_kilo98 Kar98k
  hadd cod.weapons iw8_sn_miki14 EBR-14
}


But are these going to be read by something else which only supports INI? You could just save the json itself and use $json whenever you want to access something.

Last edited by Loki12583; 22/10/20 08:37 PM.