Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Mon Jun 28, 2010 4:05 pm   

Can't isolate this issue
 
Obviously something has changed between 3.2x and 2.37 which has caused a script of mine to act in a funky way and I'm unsure of why it does this. I'm not certain if this is a bug or me missing an understanding of a new feature. I've tried several imitations of this in test aliases to try and locate a specific bug with record variables, local variables, or anything that might cause the issue but none of them replicate the error that can be clearly seen in this script.
[ Removed Non-working script, posted updated script below ]

Type: #show "Someone's slash mauls you!"

You should get:

Someone's slash mauls you! (22.5) dmg
22.5: DAMAGE
1: DAMAGE %int

This is WRONG, for some reason, in the function "dam_calc", the $_dam variable's value is getting converted to a 1 by %int. As far as I know, it should NOT be doing this, I don't know why it is.

Code:

#show $_dam": DAMAGE"
$_dam=%int( $_dam)
#show $_dam": DAMAGE %int"


Help is muchly appreciated.
_________________
Listen to my Guitar - If you like it, listen to more

Last edited by chamenas on Mon Jun 28, 2010 5:35 pm; edited 1 time in total
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Mon Jun 28, 2010 4:47 pm   
 
Actually, I don't get anything because apparently you didn't add the trigger for someone else. Also, no one really wants to wade through 100 lines of code to figure out what's wrong. If you say it's just the damage calculation, only post that. No need for the entire script...

Charneus
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Mon Jun 28, 2010 4:50 pm   
 
That's what the bit at the end is for. You'd need the entire script to test it, and everything I posted is all that you'll need for it. But the actual code being concerned with is the bit I posted at the end. Lines 2-5 or so in the "dam_calc" function. What error are you getting when you try to test it? The line "Someone's slash mauls you!" should work exactly as I have it posted.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Mon Jun 28, 2010 5:02 pm   
 
Ah, the trigger is in there, but it's not firing for whatever reason. Might have something to do with the variable. I'll see what I can possibly do, but by typing:

#SAY {@dam_calc("Charneus","you","22.5","dog")}

It worked well for me. *shrug*

Charneus
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Mon Jun 28, 2010 5:21 pm   
 
Yeah, manually inputting into the function seems to work just fine. However, having it fire from the trigger causes the failure. Believe me when I say it's quite odd in that regard. So, the trigger will need to become functional in order for you to see it. I'll try installing what I posted here in a blank session.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Mon Jun 28, 2010 5:34 pm   
 
I tried it out and found it also wasn't working. I re-copied and pasted it into the blank session from the working session and it seems to fire now:

Install the settings first:

Settings
Code:

<class name="Dam Script Settings" id="72">
  <var name="_dam_noun" type="StringList" id="73">
    <value>slash|magic|acid blast|lightning|crush|slice|divine power|shocking bite|claw|flaming bite|slap|fireball|reposition slash|trip|kick|charge|screech|flame|pound|spell|wrath|bite|backstab|tail thrash|flamestrike|harm spell|smite|thrust|ray of truth|pierce|beating|stab|punch|chomp|lightning bolt|attack|earthquake|gore|freezing bite|shock</value>
    <json>["slash","magic","acid blast","lightning","crush","slice","divine power","shocking bite","claw","flaming bite","slap","fireball","reposition slash","trip","kick","charge","screech","flame","pound","spell","wrath","bite","backstab","tail thrash","flamestrike","harm spell","smite","thrust","ray of truth","pierce","beating","stab","punch","chomp","lightning bolt","attack","earthquake","gore","freezing bite","shock"]</json>
  </var>
  <var name="_dam_type" type="Record" id="74">
    <value><![CDATA[HIDEOUS=238|<<< ERADICATES >>>=138|devastates=30.5|misses=0|injures=14.5|MASSACRES=50.5|MANGLES=53.5|mauls=22.5|maims=34.5|HORRID=188|=== OBLITERATES ====88|grazes=6.5|GHASTLY=163|decimates=26.5|wounds=18.5|MUTILATES=38.5|DISEMBOWELS=42.5|DISMEMBERS=46.5|\*\*\* DEMOLISHES \*\*\*=58|scratches=2.5|UNSPEAKABLE=300|DREADFUL=228|hits=19.5|\*\*\* DEVASTATES \*\*\*=68|>>> ANNIHILATES <<<=113|INDESCRIBABLE=263]]></value>
    <json><![CDATA[{"HIDEOUS":238,"<<< ERADICATES >>>":138,"devastates":30.5,"misses":0,"injures":14.5,"MASSACRES":50.5,"MANGLES":53.5,"mauls":22.5,"maims":34.5,"HORRID":188,"=== OBLITERATES ===":88,"grazes":6.5,"GHASTLY":163,"decimates":26.5,"wounds":18.5,"MUTILATES":38.5,"DISEMBOWELS":42.5,"DISMEMBERS":46.5,"\*\*\* DEMOLISHES \*\*\*":58,"scratches":2.5,"UNSPEAKABLE":300,"DREADFUL":228,"hits":19.5,"\*\*\* DEVASTATES \*\*\*":68,">>> ANNIHILATES <<<":113,"INDESCRIBABLE":263}]]></json>
  </var>
  <var name="_no_dam_noun" type="StringList" id="75">
    <value>uyi|shadow has quite a few|shadow has some big nasty wounds and|kicked dirt|hand and|shadow has some small</value>
    <json>["uyi","shadow has quite a few","shadow has some big nasty wounds and","kicked dirt","hand and","shadow has some small"]</json>
  </var>
  <var name="_dam_set" type="Record" id="76">
    <value>show_color=6|mob=1|toggle=1|show_add=1|conf_clear_curr=0|auto=1|show_save=0|color4=12|color3=14|color2=2|color1=6</value>
    <json>{"show_color":6,"mob":1,"toggle":1,"show_add":1,"conf_clear_curr":0,"auto":1,"show_save":0,"color4":12,"color3":14,"color2":2,"color1":6}</json>
  </var>
  <var name="_dam_taken" type="Record" id="77">
    <value>A selkie="You|14007|Chaul|12071|Kyrlynn|7681"|You="A penguin|3|A selkie|7|A killer whale|1|A king salmon|7|Vrykolas|2|Someone|5"|Vrykolas="You|137"|A penguin="Chaul|8605|Kyrlynn|4703|You|7954"|A king salmon="You|6396|Kyrlynn|2595|Chaul|5379"|A killer whale="You|7601|Kyrlynn|2013|Chaul|5379"|Chaul="A penguin|6"</value>
    <json>{"A selkie":["You",14007,"Chaul",12071,"Kyrlynn",7681],"You":["A penguin",3,"A selkie",7,"A killer whale",1,"A king salmon",7,"Vrykolas",2,"Someone",5],"Vrykolas":["You",137],"A penguin":["Chaul",8605,"Kyrlynn",4703,"You",7954],"A king salmon":["You",6396,"Kyrlynn",2595,"Chaul",5379],"A killer whale":["You",7601,"Kyrlynn",2013,"Chaul",5379],"Chaul":["A penguin",6]}</json>
  </var>
  <var name="_dam_taken_sav" type="Record" id="78"/>
  <var name="_dam_done" type="Record" id="79">
    <value>A selkie="You|7"|You="A selkie|14007|A penguin|7954|A killer whale|7601|A king salmon|6396|Vrykolas|137"|Vrykolas="You|2"|A penguin="Chaul|6|You|3"|Kyrlynn="A penguin|4703|A selkie|7681|A killer whale|2013|A king salmon|2595"|A king salmon="You|7"|A killer whale="You|1"|Chaul="A penguin|8605|A selkie|12071|A killer whale|5379|A king salmon|5379"|Someone="You|5"</value>
    <json>{"A selkie":["You",7],"You":["A selkie",14007,"A penguin",7954,"A killer whale",7601,"A king salmon",6396,"Vrykolas",137],"Vrykolas":["You",2],"Someone":["You",5],"A penguin":["Chaul",6,"You",3],"Kyrlynn":["A penguin",4703,"A selkie",7681,"A killer whale",2013,"A king salmon",2595],"A king salmon":["You",7],"A killer whale":["You",1],"Chaul":["A penguin",8605,"A selkie",12071,"A killer whale",5379,"A king salmon",5379]}</json>
  </var>
  <var name="_dam_done_sav" type="Record" id="80"/>
  <var name="_dam_done_show" id="81"/>
  <var name="_dam_taken_show" id="82"/>
  <var name="_dam_done_noun" type="Record" id="83">
    <value>A selkie="pierce|2|slash|4|pound|1"|You="claw|36095"|Vrykolas="pierce|2"|A penguin="slash|6|pound|2|pierce|1"|Kyrlynn="shock|16992"|A king salmon="pierce|7"|A killer whale="slash|0|pierce|1"|Chaul="freezing bite|3853|flaming bite|1652|shock|15710|shocking bite|10219"|Someone="slash|5"</value>
    <json>{"A selkie":["pierce",2,"slash",4,"pound",1],"You":["claw",36095],"Vrykolas":["pierce",2],"Someone":["slash",5],"A penguin":["slash",6,"pound",2,"pierce",1],"Kyrlynn":["shock",16992],"A king salmon":["pierce",7],"A killer whale":["slash",0,"pierce",1],"Chaul":["freezing bite",3853,"flaming bite",1652,"shock",15710,"shocking bite",10219]}</json>
  </var>
  <var name="_dam_done_noun_sav" type="Record" id="84">
    <json>{}</json>
  </var>
  <var name="_dam_taken_noun" type="Record" id="85">
    <value>A selkie="claw|14007|freezing bite|1707|flaming bite|860|shock|13436|shocking bite|3749"|You="pound|3|pierce|13|slash|9"|Vrykolas="claw|137"|A penguin="freezing bite|2146|shock|7925|flaming bite|792|claw|7954|shocking bite|2445"|A king salmon="claw|6396|shock|6231|shocking bite|1743"|A killer whale="claw|7601|shock|5110|shocking bite|2282"|Chaul="slash|6"</value>
    <json>{"A selkie":["claw",14007,"freezing bite",1707,"flaming bite",860,"shock",13436,"shocking bite",3749],"You":["pound",3,"pierce",13,"slash",9],"Vrykolas":["claw",137],"A penguin":["freezing bite",2146,"shock",7925,"flaming bite",792,"claw",7954,"shocking bite",2445],"A king salmon":["claw",6396,"shock",6231,"shocking bite",1743],"A killer whale":["claw",7601,"shock",5110,"shocking bite",2282],"Chaul":["slash",6]}</json>
  </var>
  <var name="_dam_taken_noun_sav" type="Record" id="86"/>
  <var name="_dam_done_noun_show" id="87"/>
  <var name="_dam_taken_noun_show" id="88"/>
</class>


Script
Code:

<class name="Dam Script" id="89">
  <trigger name="dam-gather" priority="14760" regex="true" id="90">
    <pattern>(?:[\w '-,]+'s|Your) ([\w ]+) (?:does )?(@_dam_type)</pattern>
    <value><![CDATA[#LOCAL $_target $_aggressor $_color $_dam_calc
$_dam_n=%trim( %replace( %1, "does", ""))
$_dam_t=%2
$_dam_t=%replace( $_dam_t, "*", "\*")
$_dam=%db( _dam_type, $_dam_t)
#SWITCH ($_dam>=57) {$_color=@_dam_set.color4}
 ($_dam<57 && $_dam>36) {$_color=@_dam_set.color3}
 ($_dam<=36 && $_dam>0) {$_color=@_dam_set.color2}
 {$_color=@_dam_set.color1}
#SWITCH (%regex( %trigger, %concat( "Your (?:", $_dam_n, ") (?:does )?(?:", %replace( %2, "*", "\*"), ")(?: things to)? ([\w '-,]+)"), $_target) && %ismember( $_dam_n, _dam_noun)) {
  #sayadd " ("%ansi( $_color)$_dam%ansi( reset)") dmg"
  #IF ((%numwords( $_target)>1 && @_dam_set.mob) || %numwords( $_target)=1) {$_dam_calc=@dam_calc( "Your", $_target, $_dam, $_dam_n)}
  }
  (%regex( %trigger, %concat( "([\w '-,]+)'s (?:", $_dam_n, ") (?:does )?(?:", %replace( %2, "*", "\*"), ")(?: things to)? ([\w '-,]+)"), $_aggressor, $_target) && %ismember( $_dam_n, _dam_noun)) {
  #sayadd " ("%ansi( $_color)$_dam%ansi( reset)") dmg"
  #IF ((%numwords( $_target)>1 && @_dam_set.mob) || %numwords( $_target)=1) {#IF ((%numwords( $_aggressor)>1 && @_dam_set.mob) || %numwords( $_aggressor)=1) {$_dam_calc=@dam_calc( $_aggressor, $_target, $_dam, $_dam_n)}}
  }
 {#IF (!%ismember( $_dam_n, @_dam_noun) && !%ismember( $_dam_n, @_no_dam_noun) && @_dam_set.auto) {
    #ADDI _dam_noun $_dam_n
    #IF (@_dam_set.show_add) {
      #show %ansi( 14)"("$_dam_n")"%ansi( 10)" has been added to the damage nouns list!"%ansi( reset)
      #IF ((%numwords( $_target)>1 && @_dam_set.mob) || %numwords( $_target)=1) {#IF ((%numwords( $_aggressor)>1 && @_dam_set.mob) || %numwords( $_aggressor)=1) {$_dam_calc=@dam_calc( $_aggressor, $_target, $_dam, $_dam_n)}}
      }
    #sayadd " ("%ansi( $_color)$_dam%ansi( reset)") dmg"
    }}]]></value>
  </trigger>
  <func name="dam_calc" id="91">
    <value>#LOCAL $_dam_done_list $_mem_num
#show "$_dam: "$_dam
$_dam=%int( $_dam)
#show "%int($_dam): "$_dam
$_aggressor=%proper( $_aggressor)
#IF ($_aggressor="Your") {$_aggressor="You"}
$_target=%proper( $_target)
#IF (%iskey( _dam_done, $_aggressor)) {
  $_dam_done_list=%db( _dam_done, $_aggressor)
  #IF (%ismember( $_target, $_dam_done_list)) {
    $_mem_num=%ismember( $_target, $_dam_done_list)
    $_dam_done=%int( %item( $_dam_done_list, %eval( $_mem_num+1)))
    #IF (%int( $_dam_done) || $_dam_done=0) {
      #ADD $_dam_done $_dam
      #VAR $_dam_done_list %replaceitem( $_dam_done, %eval( $_mem_num+1), $_dam_done_list)
      } {
      #show %ansi( 12)"ERROR:"%ansi( reset)" Function: dam_calc :: $_dam_done is not a number. Damage done lists may be corrupted."
      #RETURN 0
      }
    } {
    #ADDI $_dam_done_list $_target
    #VAR $_dam_done_list %additem( $_dam, $_dam_done_list)
    }
  #ADDKEY _dam_done $_aggressor $_dam_done_list
  } {#ADDKEY _dam_done $_aggressor %concat( $_target, "|", $_dam)}

#IF (%iskey( _dam_done_noun, $_aggressor)) {
  $_dam_noun_list=%db( _dam_done_noun, $_aggressor)
  #IF (%ismember( $_noun, $_dam_noun_list)) {
    $_mem_num=%ismember( $_noun, $_dam_noun_list)
    $_dam_done=%int( %item( $_dam_noun_list, %eval( $_mem_num+1)))
    #IF (%int( $_dam_done) || $_dam_done=0) {
      #ADD $_dam_done $_dam
      #VAR $_dam_noun_list %replaceitem( $_dam_done, %eval( $_mem_num+1), $_dam_noun_list)
      } {
      #show %ansi( 12)"ERROR:"%ansi( reset)" Function: dam_calc :: $_dam_done is not a number. Damage done lists may be corrupted."
      #RETURN 0
      }   
    } {
    #ADDI $_dam_noun_list $_noun
    #VAR $_dam_noun_list %additem( $_dam, $_dam_noun_list)
    }
  #ADDKEY _dam_done_noun $_aggressor $_dam_noun_list
  }  {#ADDKEY _dam_done_noun $_aggressor %concat($_noun, "|", $_dam)}
 
#IF (%iskey( _dam_taken, $_target)) {
  $_dam_taken_list=%db( _dam_taken, $_target)
  #IF (%ismember( $_aggressor, $_dam_taken_list)) {
    $_mem_num=%ismember( $_aggressor, $_dam_taken_list)
    $_dam_taken=%int( %item( $_dam_taken_list, %eval( $_mem_num+1)))
    #IF (%int( $_dam_taken) || $_dam_taken=0) {
      #ADD $_dam_taken $_dam
      #VAR $_dam_taken_list %replaceitem( $_dam_taken, %eval( $_mem_num+1), $_dam_taken_list)
      } {
      #show %ansi( 12)"ERROR:"%ansi( reset)" Function: dam_calc :: $_dam_taken is not a number. Damage taken lists may be corrupted."
      #RETURN 0
      }
    } {
    #ADDI $_dam_taken_list $_aggressor
    #VAR $_dam_taken_list %additem( $_dam, $_dam_taken_list)
    }
  #ADDKEY _dam_taken $_target $_dam_taken_list
  } {#ADDKEY _dam_taken $_target %concat( $_aggressor, "|", $_dam)}

#IF (%iskey( _dam_taken_noun, $_target)) {
  $_dam_noun_list=%db( _dam_taken_noun, $_target)
  #IF (%ismember( $_noun, $_dam_noun_list)) {
    $_mem_num=%ismember( $_noun, $_dam_noun_list)
    $_dam_done=%int( %item( $_dam_noun_list, %eval( $_mem_num+1)))
    #IF (%int( $_dam_done) || $_dam_done=0) {
      #ADD $_dam_done $_dam
      #VAR $_dam_noun_list %replaceitem( $_dam_done, %eval( $_mem_num+1), $_dam_noun_list)
      } {
      #show %ansi( 12)"ERROR:"%ansi( reset)" Function: dam_calc :: $_dam_done is not a number. Damage done lists may be corrupted."
      #RETURN 0
      }   
    } {
    #ADDI $_dam_noun_list $_noun
    #VAR $_dam_noun_list %additem( $_dam, $_dam_noun_list)
    }
  #ADDKEY _dam_taken_noun $_target $_dam_noun_list
  }  {#ADDKEY _dam_taken_noun $_target %concat($_noun, "|", $_dam)} 
 
#RETURN 1</value>
    <arglist>$_aggressor, $_target, $_dam, $_noun</arglist>
  </func>
  <alias name="dam" id="92">
    <value><![CDATA[$_cr=1
#SWITCH (%begins( "toggle", %1)) {#SWITCH (%begins( "add", %2)) {#IF (@_dam_set.show_add) {
      _dam_set.show_add=0
      #show "You will no longer see when damage nouns are added."
      } {
      _dam_set.show_add=1
      #show "You will now see when damage nouns are added."
      }}
      (%begins( "auto", %2)) {#IF (@_dam_set.auto) {
      _dam_set.auto=0
      #show "Damage nouns will no longer be added automatically."
      } {
      _dam_set.auto=1
      #show "Damage nouns will now be added automatically."
      }}
      (%begins( "mob", %2)) {#IF (@_dam_set.mob) {
      _dam_set.mob=0
      #show "Mobs will no longer be included in the damage totals."
      } {
      _dam_set.mob=1
      #show "Mobs will now be included in the damage totals."
      }}
      {#IF (%-2=%null) {#IF (@_dam_set.toggle) {
        _dam_set.toggle=0
        #T- dam-gather
        #show "Dam Script has been toggled off. Type 'dam toggle' to turn it back on."
        } {
        _dam_set.toggle=1
        #T+ dam-gather
        #show "Dam Script has been toggled on. Type 'dam toggle' to turn it back off."
        }} {#show %ansi( 12)%-2%ansi( reset)" is not a valid toggle parameter. Type 'dam help toggle' for a list of parameters."}}}
        (%begins( "colors", %1)) {
  #LOCAL $_color_list
  #ADDKEY $_color_list "dark blue" 1
  #ADDKEY $_color_list "dark green" 2
  #ADDKEY $_color_list "dark cyan" 3
  #ADDKEY $_color_list "dark red" 4
  #ADDKEY $_color_list "dark magenta" 5
  #ADDKEY $_color_list "dark yellow" 6
  #ADDKEY $_color_list "light gray" 7
  #ADDKEY $_color_list "dark gray" 8
  #ADDKEY $_color_list "light blue" 9
  #ADDKEY $_color_list "light green" 10
  #ADDKEY $_color_list "light cyan" 11
  #ADDKEY $_color_list "light red" 12
  #ADDKEY $_color_list "light magenta" 13
  #ADDKEY $_color_list "light yellow" 14
  #ADDKEY $_color_list "white" 15
  #SWITCH (%isnumber( %2) && %2<=4 && %2>0) {
    #LOCAL $_color_val
    $_color_change=0
    #IF (%isnumber( %-3) && %-3>0 && %-3<=15) {
      $_color=%-3
      $_color_val=%concat( "color", %2)
      #ADDKEY _dam_set $_color_val $_color
      $_color_change=1
      } {#IF (%ismember( %-3, $_color_list)) {
        $_color=%db( $_color_list, %lower( %-3))
        $_color_val=%concat( "color", %2)
        #ADDKEY _dam_set $_color_val $_color
        $_color_change=1
        } {
        #show "You need to enter a value from 1-15 or one of the valid color names."
        #show "Type 'dam color' for a list."
        }}
    #IF ($_color_change) {#SWITCH ($_color_val="color1") {#show "You have set the color for "%ansi( 6)"misses"%ansi( reset)" to "%ansi( @_dam_set.color1)"misses"%ansi( reset)}
         ($_color_val="color2") {#show "You have set the color for "%ansi( 2)"injures"%ansi( reset)" to "%ansi( @_dam_set.color2)"injures"%ansi( reset)}
         ($_color_val="color3") {#show "You have set the color for "%ansi( 14)"MANGLES"%ansi( reset)" to "%ansi( @_dam_set.color3)"MANGLES"%ansi( reset)}
         {#show "You have set the color for *** "%ansi( 12)"DEVASTATES"%ansi( reset)" *** to *** "%ansi( @_dam_set.color4)"DEVASTATES"%ansi( reset)" ***"}}
    }
    (%begins( "show", %2)) {
    $_color_change=0
    #IF (%isnumber( %-3) && %-3>0 && %-3<=15) {
      $_color=%-3
      #ADDKEY _dam_set show_color $_color
      $_color_change=1
      } {#IF (%ismember( %-3, $_color_list)) {
        $_color=%db( $_color_list, %lower( %-3))
        #ADDKEY _dam_set show_color $_color
        $_color_change=1
        } {
        #show "You need to enter a value from 1-15 or one of the valid color names."
        #show "Type 'dam color' for a list."
        }}
    #IF ($_color_change) {
      #show "The lines for the damage calculator will now appear like so:"
      #show %ansi( @_dam_set.show_color)"--------------------------------------------"%ansi( reset)
      #show %ansi( @_dam_set.show_color)"|                      |                   |"%ansi( reset)
      #show %ansi( @_dam_set.show_color)"--------------------------------------------"%ansi( reset)
      }
    }
    {#LOOPDB $_color_list {#show %ansi( %val)%key" "%val}}
  }
    (%begins( "noun", %1)) {#SWITCH (%begins( "add", %2)) {#IF (!%ismember( %-3, _dam_noun)) {
      #ADDI _dam_noun %-3
      #show %ansi( 14)"("%-3")"%ansi( 10)" has been added to the damage nouns list!"%ansi( reset)
      } {#show %ansi( 12)"("%-3")"%ansi( reset)" is already a member of the damage nouns list.!"}}
        (%begins( "delete", %2)) {#IF (%ismember( %-3, _dam_noun)) {
      $_mem_num=%ismember( %-3, _dam_noun)
      #DELNI _dam_noun $_mem_num
      #show %ansi( 14)"("%-3")"%ansi( 10)" has been "%ansi( 12)"deleted"%ansi( 10)" from the damage nouns list!"%ansi( reset)
      } {#show %ansi( 12)"("%-3")"%ansi( reset)" is not a member of the damage nouns list.!"}}
        (%begins( "no", %2)) {#IF (!%ismember( %-3, _no_dam_noun) && !%ismember( %-3, _dam_noun)) {
      #ADDI _no_dam_noun %-3
      #show %ansi( 12)%-3" will not be added to the damage noun list automatically."
      } {#IF (%ismember( %-3, _no_dam_noun)) {
        $_mem_num=%ismember( %-3, _no_dam_noun)
        #DELNI _no_dam_noun $_mem_num
        #show %ansi( 14)%-3" can now be added to the damage noun list automatically."
        } {#show "You cannot add a damage noun which is already on the damage noun list to the prohibited list."}}}
        {
    #show %ansi( 10)"Damage Noun List:"%ansi( reset)
    #show %ansi( 14)%repeat( "-", 15)
    #FORALL @_dam_noun {#show %i}
    #show %ansi( 14)%repeat( "-", 15)
    }} 
  (%begins( "remove", %1)) {
  $_key=%proper( %-2)
  #IF (!%iskey( _dam_done, $_key) && !%iskey( _dam_taken, $_key)) {#show %ansi( 14)$_key%ansi( reset)" is not on either list."} {
    #LOOPDB @_dam_done {$_dam_done_list=%val
    #IF (%ismember(%-2)) {}}
    #IF (%iskey( _dam_done, $_key)) {
      #DELKEY _dam_done $_key
      #show %ansi( 14)$_key"'s"%ansi( 12)" data has been removed from Damage Done."%ansi( reset)
      }
    #IF (%iskey( _dam_taken, $_key)) {
      #DELKEY _dam_taken $_key
      #show %ansi( 14)$_key"'s"%ansi( 12)" data has been removed from Damage Taken."%ansi( reset)
      }
    }
  }
  (%begins( "show", %1)) {
  #IF (@_dam_set.show_save) {
    #VAR _dam_done_show @_dam_done_sav
    #VAR _dam_done_noun_show @_dam_done_noun_sav
    #VAR _dam_taken_show @_dam_taken_sav
    #VAR _dam_taken_noun_show @_dam_taken_noun_sav
    } {
    #VAR _dam_done_show @_dam_done
    #VAR _dam_done_noun_show @_dam_done_noun
    #VAR _dam_taken_show @_dam_taken
    #VAR _dam_taken_noun_show @_dam_taken_noun
    }
  #SWITCH (%begins( "done", %2)) {#IF (%-3=%null) {#IF (@_dam_done_show!=%null) {
        #show "Damage Done :: Totals"
        #show %ansi( @_dam_set.show_color)%repeat( "-", 53)%ansi( reset)
        #LOOPDB @_dam_done_show {
          $_echo=%concat( %ansi( @_dam_set.show_color), "|", %ansi( reset))
          $_echo=%concat( $_echo, %format( "&-35s", %key), %ansi( @_dam_set.show_color), "|", %ansi( reset))
          $_total_dam=0
          #FORALL %val {#IF (%isnumber( %int( %i))) {#ADD $_total_dam %int( %i)}}
          $_echo=%concat( $_echo, %format( &-15.0n, $_total_dam), %ansi( @_dam_set.show_color), "|", %ansi( reset))
          #show $_echo
          #show %ansi( @_dam_set.show_color)%repeat( "-", 53)%ansi( reset)
          }
        } {#show "No data on the Damage Done (current) record to display."}} {#IF (%begins( "noun", %3) && %iskey( @_dam_done_noun, %-4)) {
        #show "Damage Done :: by noun :: "%-4
        #show %ansi( @_dam_set.show_color)%repeat( "-", 53)%ansi( reset)
        $_iter=1
        #LOOP %eval( %numitems( %db( _dam_done_noun_show, %-4))/2) {
          $_echo=%concat( %ansi( @_dam_set.show_color), "|", %ansi( reset))
          $_name=%item( %db( _dam_done_noun_show, %-4), $_iter)
          $_dam=%item( %db( _dam_done_noun_show, %-4), %eval( $_iter+1))
          $_echo=%concat( $_echo, %format( "&-35s", $_name), %ansi( @_dam_set.show_color), "|", %ansi( reset))
          $_echo=%concat( $_echo, %format( &-15.0n, $_dam), %ansi( @_dam_set.show_color), "|", %ansi( reset))
          #show $_echo
          #show %ansi( @_dam_set.show_color)%repeat( "-", 53)%ansi( reset)
          #ADD $_iter 2
          }       
        } {#IF (%iskey( @_dam_done_show, %-3)) {
          #show "Damage Done :: "%-3
          #show %ansi( @_dam_set.show_color)%repeat( "-", 53)%ansi( reset)
          $_iter=1
          #LOOP %eval( %numitems( %db( _dam_done_show, %-3))/2) {
            $_echo=%concat( %ansi( @_dam_set.show_color), "|", %ansi( reset))
            $_name=%item( %db( _dam_done_show, %-3), $_iter)
            $_dam=%item( %db( _dam_done_show, %-3), %eval( $_iter+1))
            $_echo=%concat( $_echo, %format( "&-35s", $_name), %ansi( @_dam_set.show_color), "|", %ansi( reset))
            $_echo=%concat( $_echo, %format( "&-15.0n", $_dam), %ansi( @_dam_set.show_color), "|", %ansi( reset))
            #show $_echo
            #show %ansi( @_dam_set.show_color)%repeat( "-", 53)%ansi( reset)
            #ADD $_iter 2
            }
          }}}}
        (%begins( "taken", %2)) {#IF (%-3=%null) {#IF (@_dam_taken_show!=%null) {
        #show "Damage Taken :: Totals"
        #show %ansi( @_dam_set.show_color)%repeat( "-", 53)%ansi( reset)
        #LOOPDB @_dam_taken_show {
          $_echo=%concat( %ansi( @_dam_set.show_color), "|", %ansi( reset))
          $_echo=%concat( $_echo, %format( "&-35s", %key), %ansi( @_dam_set.show_color), "|", %ansi( reset))
          $_total_dam=0
          #FORALL %val {#IF (%isnumber( %int( %i))) {#ADD $_total_dam %int( %i)}}
          $_echo=%concat( $_echo, %format( "&-15.0n", $_total_dam), %ansi( @_dam_set.show_color), "|", %ansi( reset))
          #show $_echo
          #show %ansi( @_dam_set.show_color)%repeat( "-", 53)%ansi( reset)
          }
        } {#show "No data on the Damage Taken (current) record to display."}} {#IF (%begins( "noun", %3) && %iskey( @_dam_taken_noun, %-4)) {
        #show "Damage Taken :: by noun :: "%-4
        #show %ansi( @_dam_set.show_color)%repeat( "-", 53)%ansi( reset)
        $_iter=1
        #LOOP %eval( %numitems( %db( _dam_taken_noun_show, %-4))/2) {
          $_echo=%concat( %ansi( @_dam_set.show_color), "|", %ansi( reset))
          $_name=%item( %db( _dam_taken_noun_show, %-4), $_iter)
          $_dam=%item( %db( _dam_taken_noun_show, %-4), %eval( $_iter+1))
          $_echo=%concat( $_echo, %format( "&-35s", $_name), %ansi( @_dam_set.show_color), "|", %ansi( reset))
          $_echo=%concat( $_echo, %format( "&-15.0n", $_dam), %ansi( @_dam_set.show_color), "|", %ansi( reset))
          #show $_echo
          #show %ansi( @_dam_set.show_color)%repeat( "-", 53)%ansi( reset)
          #ADD $_iter 2
          }       
        } {#IF (%iskey( @_dam_taken, %-3)) {
          #show "Damage Taken :: "%-3
          #show %ansi( @_dam_set.show_color)%repeat( "-", 53)%ansi( reset)
          $_iter=1
          #LOOP %eval( %numitems( %db( _dam_taken_show, %-3))/2) {
            $_echo=%concat( %ansi( @_dam_set.show_color), "|", %ansi( reset))
            $_name=%item( %db( _dam_taken_show, %-3), $_iter)
            $_dam=%item( %db( _dam_taken_show, %-3), %eval( $_iter+1))
            $_echo=%concat( $_echo, %format( "&-35s", $_name), %ansi( @_dam_set.show_color), "|", %ansi( reset))
            $_echo=%concat( $_echo, %format( "&-15.0n", $_dam), %ansi( @_dam_set.show_color), "|", %ansi( reset))
            #show $_echo
            #show %ansi( @_dam_set.show_color)%repeat( "-", 53)%ansi( reset)
            #ADD $_iter 2
            }
          }}}}
        (%begins( "save", %2)) {
    _dam_set.show_save=1
    #show "The Dam Script will now show data from your saved records."
    }
        (%begins( "current", %2)) {
    _dam_set.show_save=0
    #show "The Dam Script will now show data from your current records."
    }
    {
    #show "Damage Calculator"
    #show %ansi( @_dam_set.show_color)%repeat( "-", 69)%ansi( reset)
    $_title=%concat( %ansi( @_dam_set.show_color), "|", %ansi( reset))
    $_title=%concat( $_title, %format( "&-35s", "Name"))
    $_title=%concat( $_title, %ansi( @_dam_set.show_color), "|", %ansi( reset))
    $_title=%concat( $_title, %format( "&-15s", "Damage Done"))
    $_title=%concat( $_title, %ansi( @_dam_set.show_color), "|", %ansi( reset))
    $_title=%concat( $_title, %format( "&-15s", "Damage Taken"))
    $_title=%concat( $_title, %ansi( @_dam_set.show_color), "|", %ansi( reset))
    #show $_title
    #show %ansi( @_dam_set.show_color)%repeat( "-", 69)%ansi( reset)
    #IF (@_dam_done_show!=%null || @_dam_taken_show!=%null) {
      #LOOPDB @_dam_done_show {
        $_echo=%concat( %ansi( @_dam_set.show_color), "|", %ansi( reset))
        $_echo=%concat( $_echo, %format( "&-35s", %key), %ansi( @_dam_set.show_color), "|", %ansi( reset))
        $_total_dam=0
        #FORALL %val {#IF (%isnumber( %int( %i))) {#ADD $_total_dam %int( %i)}}
        $_echo=%concat( $_echo, %format( "&-15.0n", $_total_dam), %ansi( @_dam_set.show_color), "|", %ansi( reset))
        $_total_dam=0
        #IF (%iskey( _dam_taken_show, %key)) {
          #FORALL %db( _dam_taken_show, %key) {#IF (%isnumber( %int( %i))) {#ADD $_total_dam %int( %i)}}
          $_echo=%concat( $_echo, %format( "&-15.0n", $_total_dam), %ansi( @_dam_set.show_color), "|", %ansi( reset))
          } {$_echo=%concat( $_echo, %format( "&-15s", "No data."), %ansi( @_dam_set.show_color), "|", %ansi( reset))}
        #show $_echo
        #show %ansi( @_dam_set.show_color)%repeat( "-", 69)%ansi( reset)
        }
      #LOOPDB @_dam_taken_show {#IF (!%iskey( _dam_done_show, %key)) {
          $_echo=%concat( %ansi( @_dam_set.show_color), "|", %ansi( reset))
          $_echo=%concat( $_echo, %format( "&-35s", %key), %ansi( @_dam_set.show_color), "|", %ansi( reset))
          $_echo=%concat( $_echo, %format( "&-15s", "No data."), %ansi( @_dam_set.show_color), "|", %ansi( reset))
          $_total_dam=0
          #FORALL %val {#IF (%isnumber( %int( %i))) {#ADD $_total_dam %int( %i)}}
          $_echo=%concat( $_echo, %format( &-15.0n, $_total_dam), %ansi( @_dam_set.show_color), "|", %ansi( reset))
          #show $_echo
          #show %ansi( @_dam_set.show_color)%repeat( "-", 69)%ansi( reset)   
          }}
      } {
      $_echo=%concat( %ansi( @_dam_set.show_color), "|", %ansi( reset))
      $_echo=%concat( $_echo, %format( "&-67s", "No data on record."))
      $_echo=%concat( $_echo, %ansi( @_dam_set.show_color), "|", %ansi( reset))
      #show $_echo
      #show %ansi( @_dam_set.show_color)%repeat( "-", 69)%ansi( reset)         
      }
    }
  _dam_done_show=%null
  _dam_done_noun_show=%null
  _dam_taken_show=%null
  _dam_taken_noun_show=%null
  }
  (%begins( "clear", %1)) {#SWITCH (%begins( "current", %2)) {#IF (@_dam_set.conf_clear_curr) {
      _dam_done=%null
      _dam_done_noun=%null
      #show "Damage Done (current) data cleared."
      _dam_taken=%null
      _dam_taken_noun=%null
      #show "Damage Taken (current) data cleared."
      _dam_set.conf_clear_curr=0
      } {
      _dam_set.conf_clear_curr=1
      #T+ conf-clear-curr
      #show "Please type 'dam "%1" "%2"' again to confirm that you wish to clear your current Damage records."
      }}}
{}
#IF ($_cr) {#send %cr}]]></value>
  </alias>
  <trigger name="conf-clear-curr" type="Alarm" priority="20470" enabled="false" id="93">
    <pattern>10</pattern>
    <value>_dam_set.conf_clear_curr=0
#T- conf-clear-curr</value>
  </trigger>
</class>




The matter of concern is LINES 2-4 of the dam_calc function, reposted here for specific reference:
Code:

#LOCAL $_dam_done_list $_mem_num
#show "$_dam: "$_dam
$_dam=%int( $_dam)
#show "%int($_dam): "$_dam
$_aggressor=%proper( $_aggressor)
#IF ($_aggressor="Your") {$_aggressor="You"}
$_target=%proper( $_target)
#IF (%iskey( _dam_done, $_aggressor)) {
  $_dam_done_list=%db( _dam_done, $_aggressor)
  #IF (%ismember( $_target, $_dam_done_list)) {
    $_mem_num=%ismember( $_target, $_dam_done_list)
    $_dam_done=%int( %item( $_dam_done_list, %eval( $_mem_num+1)))
    #IF (%int( $_dam_done) || $_dam_done=0) {
      #ADD $_dam_done $_dam
      #VAR $_dam_done_list %replaceitem( $_dam_done, %eval( $_mem_num+1), $_dam_done_list)
      } {
      #show %ansi( 12)"ERROR:"%ansi( reset)" Function: dam_calc :: $_dam_done is not a number. Damage done lists may be corrupted."
      #RETURN 0
      }
    } {
    #ADDI $_dam_done_list $_target
    #VAR $_dam_done_list %additem( $_dam, $_dam_done_list)
    }
  #ADDKEY _dam_done $_aggressor $_dam_done_list
  } {#ADDKEY _dam_done $_aggressor %concat( $_target, "|", $_dam)}

#IF (%iskey( _dam_done_noun, $_aggressor)) {
  $_dam_noun_list=%db( _dam_done_noun, $_aggressor)
  #IF (%ismember( $_noun, $_dam_noun_list)) {
    $_mem_num=%ismember( $_noun, $_dam_noun_list)
    $_dam_done=%int( %item( $_dam_noun_list, %eval( $_mem_num+1)))
    #IF (%int( $_dam_done) || $_dam_done=0) {
      #ADD $_dam_done $_dam
      #VAR $_dam_noun_list %replaceitem( $_dam_done, %eval( $_mem_num+1), $_dam_noun_list)
      } {
      #show %ansi( 12)"ERROR:"%ansi( reset)" Function: dam_calc :: $_dam_done is not a number. Damage done lists may be corrupted."
      #RETURN 0
      }   
    } {
    #ADDI $_dam_noun_list $_noun
    #VAR $_dam_noun_list %additem( $_dam, $_dam_noun_list)
    }
  #ADDKEY _dam_done_noun $_aggressor $_dam_noun_list
  }  {#ADDKEY _dam_done_noun $_aggressor %concat($_noun, "|", $_dam)}
 
#IF (%iskey( _dam_taken, $_target)) {
  $_dam_taken_list=%db( _dam_taken, $_target)
  #IF (%ismember( $_aggressor, $_dam_taken_list)) {
    $_mem_num=%ismember( $_aggressor, $_dam_taken_list)
    $_dam_taken=%int( %item( $_dam_taken_list, %eval( $_mem_num+1)))
    #IF (%int( $_dam_taken) || $_dam_taken=0) {
      #ADD $_dam_taken $_dam
      #VAR $_dam_taken_list %replaceitem( $_dam_taken, %eval( $_mem_num+1), $_dam_taken_list)
      } {
      #show %ansi( 12)"ERROR:"%ansi( reset)" Function: dam_calc :: $_dam_taken is not a number. Damage taken lists may be corrupted."
      #RETURN 0
      }
    } {
    #ADDI $_dam_taken_list $_aggressor
    #VAR $_dam_taken_list %additem( $_dam, $_dam_taken_list)
    }
  #ADDKEY _dam_taken $_target $_dam_taken_list
  } {#ADDKEY _dam_taken $_target %concat( $_aggressor, "|", $_dam)}

#IF (%iskey( _dam_taken_noun, $_target)) {
  $_dam_noun_list=%db( _dam_taken_noun, $_target)
  #IF (%ismember( $_noun, $_dam_noun_list)) {
    $_mem_num=%ismember( $_noun, $_dam_noun_list)
    $_dam_done=%int( %item( $_dam_noun_list, %eval( $_mem_num+1)))
    #IF (%int( $_dam_done) || $_dam_done=0) {
      #ADD $_dam_done $_dam
      #VAR $_dam_noun_list %replaceitem( $_dam_done, %eval( $_mem_num+1), $_dam_noun_list)
      } {
      #show %ansi( 12)"ERROR:"%ansi( reset)" Function: dam_calc :: $_dam_done is not a number. Damage done lists may be corrupted."
      #RETURN 0
      }   
    } {
    #ADDI $_dam_noun_list $_noun
    #VAR $_dam_noun_list %additem( $_dam, $_dam_noun_list)
    }
  #ADDKEY _dam_taken_noun $_target $_dam_noun_list
  }  {#ADDKEY _dam_taken_noun $_target %concat($_noun, "|", $_dam)} 
 
#RETURN 1


Typing: #show "Someone's slash mauls you!"

Gives an output of:
Someone's slash mauls you! (22.5) dmg
$_dam: 22.5
%int($_dam): 1
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Jun 28, 2010 6:49 pm   
 
Chamenas, it really isn't very reasonable to expect us to find the one bug in two hundred lines of code, without any attempt to cut out the extraneous stuff.

You didn't say what version you are using. I assume it is 3.20. If so, I believe the problem is a bug which has already been reported and fixed for 3.21 in which some parameters were being treated as strings instead of numbers.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Tue Jun 29, 2010 2:20 am   
 
The bug occurs in 3.21, so it hasn't been fixed. But I don't understand why I keep getting hostile posts about not cutting out the extraneous code when I specifically give you the bits of code that are causing the problem. I gave the whole script because you need to see the whole script in order to see the issue, since I have been unable to replicate the issue outside of the script, so I cannot help but give you the entirety of the script. I do not, however, expect you to look through the entire script to find the problem. In both posts in this thread I have specifically pointed to where you will need to look to find the issue.

I'm very much confused as to why people are not seeing that.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Tue Jun 29, 2010 2:53 pm   
 
I'm not sure how to better pull out the proper code snippet than I've already done. Every other test I've tried to do to replicate it has failed, which is why I shared the entire script, but, as I've said in all the posts, it's just lines 2-4 of the dam_calc function which I posted a second time, with just the snippet and the entire function in case you want to look at surrounding context, that should concern this. Maybe I'm just being silly, but it feels like a bug, since there's no reason it should exhibit this behavior.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Tue Jun 29, 2010 5:03 pm   
 
I just tried this snippet:
Code:
$_dam = 22.5
#show $_dam": DAMAGE"
$_dam=%int( $_dam)
#show $_dam": DAMAGE %int"

and it worked fine here. As Rahab mentioned, you will need to narrow this down yourself, especially with a script that complicated. That's the job of beta testing. Add more debug statements to track down the problem.

It's very possible the issue is related to beginning your variable name with a "_" character since that isn't technically allowed. Variables, aliases, etc are supposed to start with alphabetic characters. They can contain a "_" within the variable name to replace a space, but they shouldn't be starting with "_". It possible you have run into a rare situation in the parser that doesn't work when starting a variable with "_" even though it works in most other cases.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Tue Jun 29, 2010 6:46 pm   
 
Edit: Oops
_________________
Listen to my Guitar - If you like it, listen to more

Last edited by chamenas on Tue Jun 29, 2010 6:53 pm; edited 1 time in total
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Tue Jun 29, 2010 6:53 pm   
 
Is there any reason it would work in 2.37 but not 3.20? I've been trying to track it down myself for awhile now and have been unable to do personally find a way to isolate the issue. Tried replacing $_dam with $dam, but that didn't work. This is very frustrating. *sighs*

Edit: Nevermind. When I changed ALL of my variables, to no longer have a preceding _ sign it worked.

Edit 2: And suddenly it's failing again. And %int() is returning 1 instead of the number, so it has nothing to do with the preceding _
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Tue Jun 29, 2010 7:43 pm   
 
I've tried reducing the script down as much as possible, so here we have it:

Code:

<class name="test_dam" id="93">
  <var name="dam_test" type="Record" id="94">
    <value>injures=14.5|wounds=18.5</value>
    <json>{"injures":14.5,"wounds":18.5}</json>
  </var>
  <trigger name="test-dam-gather" priority="15380" regex="true" id="95">
    <pattern>(?:[\w '-,]+'s|Your) ([\w ]+) (@dam_test)</pattern>
    <value>$dam_n=%1
$dam_t=%2
$dam=%db( dam_type, $dam_t)
#SWITCH (%regex( %trigger, %concat( "Your (?:", $dam_n, ") (?:does )?(?:", $dam_t, ")(?: things to)? ([\w '-,]+)"))) {
  #CALL @test_dam_calc( $dam)
  }
  (%regex( %trigger, %concat( "([\w '-,]+)'s (?:", $dam_n, ") (?:does )?(?:", $dam_t, ")(?: things to)? ([\w '-,]+)"))) {
  #CALL @test_dam_calc( $dam)
  }</value>
  </trigger>
  <func name="test_dam_calc" id="96">
    <value>#show "$dam: "$dam
$dam=%int($dam)
#show "%int($dam): "$dam
#RETURN 1</value>
    <arglist>$dam</arglist>
  </func>
  <var name="dam_type" type="Record" id="97">
    <value><![CDATA[HIDEOUS=238|<<< ERADICATES >>>=138|devastates=30.5|misses=0|injures=14.5|MASSACRES=50.5|MANGLES=53.5|mauls=22.5|maims=34.5|HORRID=188|=== OBLITERATES ====88|grazes=6.5|GHASTLY=163|decimates=26.5|wounds=18.5|MUTILATES=38.5|DISEMBOWELS=42.5|DISMEMBERS=46.5|\*\*\* DEMOLISHES \*\*\*=58|scratches=2.5|UNSPEAKABLE=300|DREADFUL=228|hits=10.5|\*\*\* DEVASTATES \*\*\*=68|>>> ANNIHILATES <<<=113|INDESCRIBABLE=263]]></value>
    <json><![CDATA[{"HIDEOUS":238,"<<< ERADICATES >>>":138,"devastates":30.5,"misses":0,"injures":14.5,"MASSACRES":50.5,"MANGLES":53.5,"mauls":22.5,"maims":34.5,"HORRID":188,"=== OBLITERATES ===":88,"grazes":6.5,"GHASTLY":163,"decimates":26.5,"wounds":18.5,"MUTILATES":38.5,"DISEMBOWELS":42.5,"DISMEMBERS":46.5,"\*\*\* DEMOLISHES \*\*\*":58,"scratches":2.5,"UNSPEAKABLE":300,"DREADFUL":228,"hits":10.5,"\*\*\* DEVASTATES \*\*\*":68,">>> ANNIHILATES <<<":113,"INDESCRIBABLE":263}]]></json>
  </var>
</class>


Using: #show "Someone's slash wounds you!"

You should be able to see the effect. Now, here's an odd thing. If you change:
Code:

$dam=%db( dam_type, $dam_t)


to

Code:

$dam=%db( dam_t, $dam_t)


And change the appropriate variable (dam_type) to (dam_t)

It suddenly works just fine.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
GeneralStonewall
Magician


Joined: 02 Feb 2004
Posts: 364
Location: USA

PostPosted: Tue Jun 29, 2010 8:41 pm   
 
%int would return 1 if you were feeding it a string and not a number. So somewhere, one of your variable types is wrong.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Tue Jun 29, 2010 8:53 pm   
 
That's what I thought. It's getting the number from a database variable value, but all of those values are numbers and there's no way for me to tell it it's type is %int. So, instead, I have to manually convert it to an int with %int. In 2.37 %int() would return the number AS an integer if it was a string. Does it no longer do this? How am I going to explicitly define my database record values as integers?
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
GeneralStonewall
Magician


Joined: 02 Feb 2004
Posts: 364
Location: USA

PostPosted: Tue Jun 29, 2010 9:03 pm   
 
Here, this might highlight the issue:

Code:
#addkey $testvar key1 "5"
#addkey $testvar key2 5
#print ""
#print {json(testvar): %json($testvar)}
#print {int(5): %int(5)}
#print {int(~"5~"): %int("5")}
#print {int(db(testvar, key1)): %int(%db( $testvar, key1))}
#print {int(db(testvar, key2)): %int(%db( $testvar, key2))}


Quote:
json(testvar): {"key2":5,"key1":"5"}
int(5): 5
int("5"): 5
int(db(testvar, key1)): 1
int(db(testvar, key2)): 5
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Jun 30, 2010 12:37 pm   
 
You are misunderstanding the purpose of %int(). It does _not_ convert a string into an integer. Rather, it returns the integer part of a floating point value. Using %int() on a string will return 1.
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Wed Jun 30, 2010 1:07 pm   
 
Rahab, I think he knows that. What he's saying that for some reason the automatic type conversion of the string "22.5" to the floating point 22.5 is failing for some reason and that's why his code is failing. The conversion only seems to fail when the result is from the %db. His example really highlights this. I even added the following lines to get a better sense of it.

Code:
#addkey $testvar key1 "5"
#addkey $testvar key2 5
#print ""
#print {json(testvar): %json($testvar)}
#print {int(5): %int(5)}
#print {int(~"5~"): %int("5")}
#print {int(db(testvar, key1)): %int(%db( $testvar, key1))}  %db( $testvar, key1)
#print {int(db(testvar, key2)): %int(%db( $testvar, key2))}  %db( $testvar, key2)


Confirmed and truly weird.
_________________
Asati di tempari!
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Wed Jun 30, 2010 4:09 pm   
 
Yep, General has the test to reproduce this bug. Thanks for pinning this down. It's on the bug list and should be fixed in this week's release.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Wed Jun 30, 2010 5:55 pm   
 
Thanks for figuring it out, guys. I was close when I narrowed it down but missed it and so I didn't think to go further in that direction. I'm glad there's others with a bit more "know" ;)
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net