Tracking down compile errors...

by Unknown

Back to Mechanic's Corner.

Unknown2008-07-24 16:19:41
When I try to run the following alias, CMUD doesn't seem to want to enter the if final if branches for sipping the appropriate potion. In a test case, the division of the hp by max hp returned ~0.44 with the sip value set to 0.80. The prioritization switch was transversed OK but it would not enter the if branch, despite 0.44 being less than 0.80. Could someone please take a look and tell me what may be wrong? Running CMUD 2.33.

CODE
#if (@gmonsip=1) {

#if (@syssipbal=1) {
  #switch (%item(@syssippriority, 1)=~"hp") {
    #if ((@syshp/@sysmhp)<=@syssiphp) {sip health
    #var syssipbal 0}
  } (%item(@syssippriority, 1)=~"mp") {
    #if ((@sysmp/@sysmmp)<=@syssipmp) {sip mana
    #var syssipbal 0}
  } (%item(@syssippriority, 1)=~"ego") {
    #if ((@sysego/@sysmego)<=@syssipego) {sip bromide
    #var syssipbal 0}
}}

#if (@syssipbal=1) {
  #switch (%item(@syssippriority, 2)=~"hp") {
    #if ((@syshp/@sysmhp)<=@syssiphp) {sip health
    #var syssipbal 0}
  } (%item(@syssippriority, 2)=~"mp") {
    #if ((@sysmp/@sysmmp)<=@syssipmp) {sip mana
    #var syssipbal 0}
  } (%item(@syssippriority, 2)=~"ego") {
    #if ((@sysego/@sysmego)<=@syssipego) {sip bromide
    #var syssipbal 0}
}}

#if (@syssipbal=1) {
  #switch (%item(@syssippriority, 3)=~"hp") {
    #if ((@syshp/@sysmhp)<=@syssiphp) {sip health
    #var syssipbal 0}
  } (%item(@syssippriority, 3)=~"mp") {
    #if ((@sysmp/@sysmmp)<=@syssipmp) {sip mana
    #var syssipbal 0}
  } (%item(@syssippriority, 3)=~"ego") {
    #if ((@sysego/@sysmego)<=@syssipego) {sip bromide
    #var syssipbal 0}
}}

}
Unknown2008-07-24 16:51:20
1. Indentation matters in CMUD, so that might be part of the problem (or it might not).
2. Why are you doing essentially the same thing three times in the same alias? Looks to me like you could streamline this a little...
3. When you do (@syshp/@sysmhp) you get an integer result. You need to use %float on both variables to get a floating-point result OR you could multiply by 100 first and then divide by your @syssiphp to get a pseudo-percentage.
Unknown2008-07-24 17:23:54
QUOTE(Zarquan @ Jul 24 2008, 09:51 AM) 536995
1. Indentation matters in CMUD, so that might be part of the problem (or it might not).


Yeah this is one of the more annoying things about CMUD. You should start out by not having any indentation. It matters more with the ()'s than with the {}'s but I have had odd results from both and I have never tracked down the exact rules.

Also the tread title says "compile errors" but you did not list any. When you click on the "compiled code" tab does it show code or an error? That is the fastest way to double check that you do not have a typo or an indentation issue.

I also am not following the intention of your code. Could you explain at a high level what your goal is?
Unknown2008-07-24 17:25:53
I tried changing it to this:

CODE
#if (@gmonsip=1) {

  #if (@syssipbal=1) {
    #switch (%item(@syssippriority, 1)=~"hp")
    {
      #if ((@syshp/@sysmhp)<=@syssiphp)
      {
        sip health
        #var syssipbal 0
      }
    } (%item(@syssippriority, 1)=~"mp")
    {
      #if ((@sysmp/@sysmmp)<=@syssipmp)
      {
        sip mana
        #var syssipbal 0
      }
    } (%item(@syssippriority, 1)=~"ego")
    {
      #if ((@sysego/@sysmego)<=@syssipego)
      {
        sip bromide
        #var syssipbal 0
      }
    }
  }

  #if (@syssipbal=1) {
    #switch (%item(@syssippriority, 2)=~"hp")
    {
      #if ((@syshp/@sysmhp)<=@syssiphp)
      {
        sip health
        #var syssipbal 0
      }
    } (%item(@syssippriority, 2)=~"mp")
    {
      #if ((@sysmp/@sysmmp)<=@syssipmp)
      {
        sip mana
        #var syssipbal 0
      }
    } (%item(@syssippriority, 2)=~"ego")
    {
      #if ((@sysego/@sysmego)<=@syssipego)
      {
        sip bromide
        #var syssipbal 0
      }
    }
  }

  #if (@syssipbal=1) {
    #switch (%item(@syssippriority, 3)=~"hp")
    {
      #if ((@syshp/@sysmhp)<=@syssiphp)
      {
        sip health
        #var syssipbal 0
      }
    } (%item(@syssippriority, 3)=~"mp")
    {
      #if ((@sysmp/@sysmmp)<=@syssipmp)
      {
        sip mana
        #var syssipbal 0
      }
    } (%item(@syssippriority, 3)=~"ego")
    {
      #if ((@sysego/@sysmego)<=@syssipego)
      {
        sip bromide
        #var syssipbal 0
      }
    }
  }

}


Same problem...

2. I don't claim to be a good coder...Simplest way I could think of to do prioritization, though.
3. No...I set the variables to floating point types. As long as at least one number in an expression is floating point, then the result will be too. That's how I got .44 on the first test case.

Sorry, just saw your post. It's the heart of an autosipper. And with the above code, I tried a few different things, but that variation seems to be the only one that compiles and is recognize by the color thing in the IDE. Depending on how I move the parentheses, for example putting (%item(@syssippriority, 3)=~"mp") on a line without brackets, gives me illegal token compile errors...
Catarin2008-07-24 17:29:30
QUOTE(a lone trill @ Jul 24 2008, 11:25 AM) 537003
I tried changing it to this:

CODE
#if (@gmonsip=1) {

  #if (@syssipbal=1) {
    #switch (%item(@syssippriority, 1)=~"hp")
    {
      #if ((@syshp/@sysmhp)<=@syssiphp)
      {
        sip health
        #var syssipbal 0
      }
    } (%item(@syssippriority, 1)=~"mp")
    {
      #if ((@sysmp/@sysmmp)<=@syssipmp)
      {
        sip mana
        #var syssipbal 0
      }
    } (%item(@syssippriority, 1)=~"ego")
    {
      #if ((@sysego/@sysmego)<=@syssipego)
      {
        sip bromide
        #var syssipbal 0
      }
    }
  }

  #if (@syssipbal=1) {
    #switch (%item(@syssippriority, 2)=~"hp")
    {
      #if ((@syshp/@sysmhp)<=@syssiphp)
      {
        sip health
        #var syssipbal 0
      }
    } (%item(@syssippriority, 2)=~"mp")
    {
      #if ((@sysmp/@sysmmp)<=@syssipmp)
      {
        sip mana
        #var syssipbal 0
      }
    } (%item(@syssippriority, 2)=~"ego")
    {
      #if ((@sysego/@sysmego)<=@syssipego)
      {
        sip bromide
        #var syssipbal 0
      }
    }
  }

  #if (@syssipbal=1) {
    #switch (%item(@syssippriority, 3)=~"hp")
    {
      #if ((@syshp/@sysmhp)<=@syssiphp)
      {
        sip health
        #var syssipbal 0
      }
    } (%item(@syssippriority, 3)=~"mp")
    {
      #if ((@sysmp/@sysmmp)<=@syssipmp)
      {
        sip mana
        #var syssipbal 0
      }
    } (%item(@syssippriority, 3)=~"ego")
    {
      #if ((@sysego/@sysmego)<=@syssipego)
      {
        sip bromide
        #var syssipbal 0
      }
    }
  }

}


Same problem...

2. I don't claim to be a good coder...Simplest way I could think of to do prioritization, though.
3. No...I set the variables to floating point types. As long as at least one number in an expression is floating point, then the result will be too. That's how I got .44 on the first test case.


What compile error does it give?
Unknown2008-07-24 17:30:07
QUOTE(Catarin @ Jul 24 2008, 11:29 AM) 537004
What compile error does it give?


That one compiles.
Catarin2008-07-24 17:37:17
QUOTE(a lone trill @ Jul 24 2008, 11:30 AM) 537005
That one compiles.


Okay, so none of those if statements inside the switch statements are firing? Or is it just one of them? I can't really tell from your opening post.
Unknown2008-07-24 17:42:55
QUOTE(Catarin @ Jul 24 2008, 11:37 AM) 537006
Okay, so none of those if statements inside the switch statements are firing? Or is it just one of them? I can't really tell from your opening post.


Only one if statement per switchblock can be evaluated for a given priority configuration. I've made sure that the right if statement within each switchblock (hp for the first, mana for the second, ego for the third) is reached for each stat, but all 3 of them will not fire. I've also made sure it's evaluated as a floating point number rather than integer by dumping to test variables...
Catarin2008-07-24 17:57:55
QUOTE(a lone trill @ Jul 24 2008, 11:42 AM) 537007
Only one if statement per switchblock can be evaluated for a given priority configuration. I've made sure that the right if statement within each switchblock (hp for the first, mana for the second, ego for the third) is reached for each stat, but all 3 of them will not fire. I've also made sure it's evaluated as a floating point number rather than integer by dumping to test variables...


Made sure which was evaluated as a floating point number? I understand the @sys*/@sysm* variables are evaluating properly to their floating values since you set them to floating type variables but are the syssip* variables all set to floating point types as well? It won't evaluate properly otherwise.
Unknown2008-07-24 18:09:03
QUOTE(Catarin @ Jul 24 2008, 11:57 AM) 537011
Made sure which was evaluated as a floating point number? I understand the @sys*/@sysm* variables are evaluating properly to their floating values since you set them to floating type variables but are the syssip* variables all set to floating point types as well? It won't evaluate properly otherwise.


...that did it. I thought since I was using decimal values the autotype would set it to floating point, but I guess not. Thanks.

Eh, one more small problem...It'll send "sip health" or whatever, but for some reason I have to press enter manually before the potion will be sipped? I tried using #send, same problem...
Unknown2008-07-24 20:02:33
QUOTE(a lone trill @ Jul 24 2008, 11:09 AM) 537012
...that did it. I thought since I was using decimal values the autotype would set it to floating point, but I guess not. Thanks.

Eh, one more small problem...It'll send "sip health" or whatever, but for some reason I have to press enter manually before the potion will be sipped? I tried using #send, same problem...


That sounds like a trigger on prompt vrs a trigger on a newline issue to me.
Unknown2008-07-26 14:35:12
QUOTE(Enthralled @ Jul 24 2008, 02:02 PM) 537059
That sounds like a trigger on prompt vrs a trigger on a newline issue to me.


How do I fix this?
Esano2008-07-26 14:58:33
Right click on the trigger, it should be an option. Check "trigger on prompt", and uncheck "trigger on newline".
Unknown2008-07-26 15:39:59
QUOTE(Esano @ Jul 26 2008, 08:58 AM) 537527
Right click on the trigger, it should be an option. Check "trigger on prompt", and uncheck "trigger on newline".


Well, that's the way it has been to start with. Doesn't seem to work...
Unknown2008-07-26 18:19:04
Alternatively, you can use Trigger on Newline instead of Trigger on Prompt and just CONFIG PROMPT ADD LINEBREAK in the game. That's what I do, and it's been the most consistent for me.