Ilyarin2008-01-02 11:27:52
Nevermind, I found a solution. Seems I was doing it in a really convoluted way anyway, though I haven't managed to find out just why cmud was doing what it was.
I replaced the code with the following, if anyone is interested.
  $herbPriority = %sort($herbPriority)
  $affliction = %item(@herbPriority,%item($herbPriority,1))
  herb %word($herbAffs.$affliction,1)
===
Post:
I'm not really sure why this is happening, so if anyone could help me I'd appreciate it a lot. The alias is intended to return the most prioritised affliction and try to eat the herb that cures it. However, it just seems to return the last affliction that the script is parsing. What follows is the code, and what is printed out in the window. Clearly it shows that only stupidity is getting inside the #if statement, so how are the local vars getting set if the other ones aren't getting inside?
  $priority = 0
  #loopdb $herbPriority {
    #if ($priority == 0 or $priority > %val) {
      #echo %val, %key.
      #echo ---
      $priority = %val
      $affliction = %key
    }
    #echo $priority, $affliction
  }
  herb %word($herbAffs.$affliction,1)
===
I'm going to go ahead and make this a little more confusing. Just for the fun of it! I tweaked the script a bit to see if I could get any more information and I'm now really confused. To me this says that as soon as a loop starts, it is setting the values of $priority and $affliction. I never told it to do that!
  $priority = %numitems(@herbPriority)
  #loopdb $herbPriority {
    #echo START
    #echo $priority, %val
    #if ($priority > %val) {
      #echo %val, %key.
      #echo ---
      $priority = %val
      $affliction = %key
    }
    #echo $priority, $affliction
    #echo FINISH
  }
  herb %word($herbAffs.$affliction,1)
gives
I replaced the code with the following, if anyone is interested.
CODE
  $herbPriority = %sort($herbPriority)
  $affliction = %item(@herbPriority,%item($herbPriority,1))
  herb %word($herbAffs.$affliction,1)
===
Post:
I'm not really sure why this is happening, so if anyone could help me I'd appreciate it a lot. The alias is intended to return the most prioritised affliction and try to eat the herb that cures it. However, it just seems to return the last affliction that the script is parsing. What follows is the code, and what is printed out in the window. Clearly it shows that only stupidity is getting inside the #if statement, so how are the local vars getting set if the other ones aren't getting inside?
CODE
  $priority = 0
  #loopdb $herbPriority {
    #if ($priority == 0 or $priority > %val) {
      #echo %val, %key.
      #echo ---
      $priority = %val
      $affliction = %key
    }
    #echo $priority, $affliction
  }
  herb %word($herbAffs.$affliction,1)
QUOTE
1, stupidity.
---
1, stupidity
28, lovers
98, haemophilia
2, brokennose
herb applyArnicaHead
---
1, stupidity
28, lovers
98, haemophilia
2, brokennose
herb applyArnicaHead
===
I'm going to go ahead and make this a little more confusing. Just for the fun of it! I tweaked the script a bit to see if I could get any more information and I'm now really confused. To me this says that as soon as a loop starts, it is setting the values of $priority and $affliction. I never told it to do that!
CODE
  $priority = %numitems(@herbPriority)
  #loopdb $herbPriority {
    #echo START
    #echo $priority, %val
    #if ($priority > %val) {
      #echo %val, %key.
      #echo ---
      $priority = %val
      $affliction = %key
    }
    #echo $priority, $affliction
    #echo FINISH
  }
  herb %word($herbAffs.$affliction,1)
gives
QUOTE
START
105, 1
1, stupidity.
---
1, stupidity
FINISH
START
28, 28
28, lovers
FINISH
START
98, 98
98, haemophilia
FINISH
START
2, 2
2, brokennose
FINISH
herb applyArnicaHead
105, 1
1, stupidity.
---
1, stupidity
FINISH
START
28, 28
28, lovers
FINISH
START
98, 98
98, haemophilia
FINISH
START
2, 2
2, brokennose
FINISH
herb applyArnicaHead
Murphy2008-01-02 15:44:06
Your problem all along was that you're an epic failure.
Ilyarin2008-01-02 15:52:47
You always have been a funny man.