Author Topic: Issue with "for..." command  (Read 3341 times)

0 Members and 1 Guest are viewing this topic.

Offline GuadahTopic starter

  • Full Member
  • ***
  • Posts: 119
  • Activity:
    0%
  • Reputation Power: 3
  • Guadah has no influence.
  • Gender: Male
  • Who farted?!
  • Respect: +29
  • Referrals: 3
    • View Profile
    • L%N Website
Issue with "for..." command
« on: July 07, 2008, 07:15:36 PM »
0
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: [Select]
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

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Issue with "for..." command
« Reply #1 on: July 07, 2008, 07:22:57 PM »
0
You might consider using the #FINDINDEX for this function:

Code: [Select]
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

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.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline GuadahTopic starter

  • Full Member
  • ***
  • Posts: 119
  • Activity:
    0%
  • Reputation Power: 3
  • Guadah has no influence.
  • Gender: Male
  • Who farted?!
  • Respect: +29
  • Referrals: 3
    • View Profile
    • L%N Website
Re: Issue with "for..." command
« Reply #2 on: July 08, 2008, 01:23:23 PM »
0
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.

Tags: