Official ScriptUO EasyUO Scripts > Script Debug

Issue with "for..." command

(1/1)

Guadah:
I'm attempting to write out a sub while using the for command.  What I have is a bag full of ore, and I count how much is in the bag, then set the number to %count.
Then use this line:
for %i 1 %count

It should repeat as many times as I have ore in the bag, at least thats how I understood the information on EasyUO.

Here is the sub I have written so far.  My issue is it repeats the sub twice, then moves on.

--- Code: ---sub id_ore
finditem %ore_type C_ , %ResourcesChest
set %count #findcnt
for %i 1 %count
    {
    finditem %ore_type C_ , %ResourcesChest
    set #ltargetid #findid
    set #ltargetkind 1
    if #findcol = %iron_color
       {
       set %iron_ore #ltargetid
       ignoreitem #ltargetid
       }
    if #findcol = %dull_color
       {
       set %dull_ore #ltargetid
       ignoreitem #ltargetid
       }
    if #findcol = %shad_color
       {
       set %shad_ore #ltargetid
       ignoreitem #ltargetid
       }
    if #findcol = %copp_color
       {
       set %copp_ore #ltargetid
       ignoreitem #ltargetid
       }
    if #findcol = %brnz_color
       {
       set %brnz_ore #ltargetid
       ignoreitem #ltargetid
       }
    if #findcol = %gold_color
       {
       set %gold_ore #ltargetid
       ignoreitem #ltargetid
       }
    if #findcol = %agap_color
       {
       set %agap_ore #ltargetid
       ignoreitem #ltargetid
       }
    if #findcol = %veri_color
       {
       set %veri_ore #ltargetid
       ignoreitem #ltargetid
       }
    if #findcol = %valo_color
       {
       set %valo_ore #ltargetid
       ignoreitem #ltargetid
       }
    }
return
--- End code ---

TrailMyx:
You might consider using the #FINDINDEX for this function:


--- Code: ---sub id_ore
  finditem %ore_type C_ , %ResourcesChest
  if #FINDCNT >= 1
  {
    for #FINDINDEX 1 #FINDCNT
    {
      set #ltargetid #findid
      set #ltargetkind 1
      if #findcol = %iron_color
      {
        set %iron_ore #ltargetid
        ignoreitem #ltargetid
      }
      if #findcol = %dull_color
      {
        set %dull_ore #ltargetid
        ignoreitem #ltargetid
      }
      if #findcol = %shad_color
      {
        set %shad_ore #ltargetid
        ignoreitem #ltargetid
      }
      if #findcol = %copp_color
      {
        set %copp_ore #ltargetid
        ignoreitem #ltargetid
      }
      if #findcol = %brnz_color
      {
        set %brnz_ore #ltargetid
        ignoreitem #ltargetid
      }
      if #findcol = %gold_color
      {
        set %gold_ore #ltargetid
        ignoreitem #ltargetid
      }
      if #findcol = %agap_color
      {
        set %agap_ore #ltargetid
        ignoreitem #ltargetid
      }
      if #findcol = %veri_color
      {
        set %veri_ore #ltargetid
        ignoreitem #ltargetid
      }
      if #findcol = %valo_color
      {
        set %valo_ore #ltargetid
        ignoreitem #ltargetid
      }
    }
  }
return

--- End code ---

One benefit of this is you don't have to ignoreitem in this loop since the "for" loop already has the number of items and the appropriate #FINDIDs will appear as your loop index changes.

What is this supposed to do exactly?  It's not quite clear from your code.

Guadah:
I have a bag full of ore, 4 types of each ore.  I want it to search through the bag, and label each piece, so I can pull it out by %iron_ore or %valo_ore later in the script.

Navigation

[0] Message Index

Go to full version