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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Tue Jun 22, 2010 7:42 pm   

Odd Bug with Script
 
So here's the deal. I made an Affects Window script. I recently added some new things, but I cannot isolate why any of the new things might be causing this peculiar issue. In fact, I'm completely befuddled as to why the issue is happening at all.

The issue is this: I cannot add new spells to the list.

I can delete and old spell and then add it again and it works fine. But if I add a completely NEW spell that's never been on the list before. It suddenly gives odd issues. I can't delete the spell with the alias I made to delete it and it doesn't show up properly in the window. Here's a screen shot, it shows better some of what's happening:



If you see the three arrows, you can see the command prompt, this is what is typed there:
#LOOPDB @_accept_spell {#show %iskey(@_accept_spell, %key)"."%key}

In the main session window it shows the results of that command:
1. Detect Invis
2. Sanctuary
6. Invisibility
3. Detect Hidden
4. Haste
5. Self Projection

Notice anything odd?? In theory it should be going up from 1-6 in proper order. Now, if you look at the Session Editor, you can see that each spell after Invisibility is actually 1 higher than what the command showed, and that Invisibility is #3, not #6.

This creates problems. And it must be why I can't delete the spells and why they don't show up properly, as when it tries to access their number it is getting the number of something else entirely.

Here's the Script:
Code:

<class name="Affects Window" id="554">
  <trigger name="Capture-Spells" priority="7090" regex="true" id="555">
    <pattern>^(?:Spell|Song ):\s([\w '-]+)(?:\s+)?:\smodifies [\w '-]+ by (?:-)?\d+ (for (\d+) cycles|permanently)</pattern>
    <value>$_spell=%trim( %1)
#LOCAL $_time
#IF (%2!="permanently") {$_time=%3+1} {$_time="permanently"}
#IF (%ismember( $_spell, @_accept_spell)) {
  $_mem_num=%ismember( $_spell, @_accept_spell)
  $_spell=%item( @_accept_spell, $_mem_num)
  #ADDKEY _spell_list $_spell $_time
  _max_len=%max( @_max_len, %len( $_spell))
  #IF (%ismember( $_spell, "Protection Good|Protection Evil|Protection Neutral") &amp;&amp; %ismember( "Protection", @_spell_list)) {#DELKEY _spell_list "Protection"}
  show_aff
  } {#IF (%ismember( $_spell, @_accept_malad)) {
    $_mem_num=%ismember( $_spell, @_accept_malad)
    $_spell=%item( @_accept_malad, $_mem_num)
    #ADDKEY _malad_list $_spell $_time
    _max_len=%max( @_max_len, %len( $_spell))   
    show_aff
    }}
_spell=%null</value>
  </trigger>
  <trigger name="spell_tick_timer" priority="7150" regex="true" id="561">
    <pattern>^(?: )?Timer now at 41 secs.$</pattern>
    <value><![CDATA[#IF (%numkeys( @_spell_list)>0 || %numkeys( @_malad_list)>0) {
  #LOCAL $_all_list
  #IF (%numitems( @_malad_list)>0) {#LOOPDB @_malad_list {#ADDKEY $_all_list %key %val}}
  #IF (%numitems( @_spell_list)>0) {#LOOPDB @_spell_list {#ADDKEY $_all_list %key %val}}
  #LOOPDB  $_all_list {
    $_time=%val
    #LOCAL $_type
    #IF (%iskey(@_accept_malad, %key)) {$_type=%db(@_accept_malad, %key)}
    #IF (%iskey(@_accept_spell, %key)) {$_type=%db(@_accept_spell, %key)}
    #IF ($_time!=0 && $_time!="permanently") {
      #IF ($_type) {#ADD $_time 1}
      {$_time=$_time-1}
      $_str_time=%string( $_time)
      $_str_len=@strlen( $_str_time)
      _num_len=%max( @_num_len, $_str_len)
      }
    #IF ($_time=0 && !$_type) {#IF (%ismember( %key, @_req_spell) || %ismember( %key, @_hid_spell)) {#ADDKEY $_all_list %key 0} {#IF (%ismember( %key, "Protection Good|Protection Evil|Protection Neutral") && %ismember( "Protection", @_req_spell)) {
          #ADDKEY _spell_list "Protection" 0
          #DELKEY $_all_list %key
          } {
          #show %ansi( 12)">>> "%ansi( 15)%key" has fallen! "%ansi( 12)"<<<"%ansi( reset)
          #IF (@_afw_set.history) {
            #WINDOW History %ansi( 12)">>> "%ansi( 15)%key" has fallen! "%ansi( 12)"<<<"%ansi( reset)
            #T- clear-history
            #T+ clear-history
            }
          #DELKEY $_all_list %key
          }}} {
      #IF ($_time=1 && !$_type) {
        #show %ansi( 15)%if( @_afw_set.blink, %ansi( blink))%key" has 1 tick remaining!"%ansi( reset)
        #IF (@_afw_set.history) {
          #WINDOW History %ansi( 15)%key" has 1 tick remaining!"%ansi( reset)
          #T- clear-history
          #T+ clear-history
          }
        }
      #ADDKEY $_all_list %key $_time
      }
    }
  #LOCAL $_new_mala $_new_spell
  #LOOPDB $_all_list {#IF (%ismember( %key, @_accept_malad)) {#ADDKEY $_new_mala %key %val} {#IF (%ismember( %key, @_accept_spell) || %ismember( %key, "Protection")) {#ADDKEY $_new_spell %key %val} {#show "Discarding... "%key}}}
  #IF (%numitems( @_malad_list)>0) {#IF (%numitems( $_new_mala)>0) {_malad_list=$_new_mala} {_malad_list=%null}}
  #IF (%numitems( @_spell_list)>0) {#IF (%numitems( $_new_spell)>0) {_spell_list=$_new_spell} {_spell_list=%null}}
  #EXEC {show_aff}
  }
  ]]></value>
  </trigger>
  <trigger name="gag-aff" priority="5720" regex="true" enabled="false" id="572">
    <pattern>(?:^(?:(?:Spell|Song ):\s(?:[\w ,'-]+)(?:\s+)?:\s|\s+:\s)modifies [\w '-]+ by (?:-)?\d+ (?:for \d+ cycles|permanently)|^You are affected by the following spells:)</pattern>
    <value>#gag
#T+ gag-aff-off2</value>
  </trigger>
  <trigger name="gag-aff-off" type="Alarm" priority="5730" enabled="false" id="573">
    <pattern>60</pattern>
    <value>#T- gag-aff
#T- gag-aff-off</value>
  </trigger>
  <trigger name="gag-aff-off2" priority="5750" regex="true" enabled="false" id="575">
    <pattern>^$</pattern>
    <value>#T- gag-aff-off
#T- gag-aff
#T- gag-aff-off2</value>
  </trigger>
  <trigger name="auto-clear-spell" priority="12660" regex="true" id="1266">
    <pattern>(^You are not affected by any spells\.$|^You are affected by the following spells:$)</pattern>
    <value>#IF (%1="You are not affected by any spells.") {
  #LOOPDB @_spell_list {
    $_spell=%key
    #IF (%ismember( $_spell, @_req_spell) || %ismember( $_spell, @_hid_spell)) {#ADDKEY _spell_list $_spell 0} {#IF (%ismember( $_spell, "Protection Good|Protection Evil|Protection Neutral") &amp;&amp; %ismember( "Protection", @_req_spell)) {
        #ADDKEY _spell_list "Protection" 0
        #DELKEY _spell_list $_spell
        } {#DELKEY _spell_list $_spell}}
    }
  #LOOPDB @_malad_list {
    $_spell=%key
    #DELKEY _malad_list $_spell
    }
  }
    {
  #LOOPDB @_spell_list {#ADDKEY _check_spell %key 0}
  #LOOPDB @_malad_list {#ADDKEY _check_spell %key 0}
  #T+ scan-spells
  #T+ scan-spells-off
  }</value>
  </trigger>
  <trigger name="scan-spells" priority="12670" regex="true" enabled="false" id="1267">
    <pattern>^(?:Spell|Song ):\s([\w '-]+)(?:\s+)?:\smodifies [\w '-]+ by (?:-)?\d+ (for (\d+) cycles|permanently)</pattern>
    <value>$_spell=%trim(%1)
#IF (%iskey(@_check_spell, $_spell)) {#ADDKEY _check_spell $_spell 1}</value>
  </trigger>
  <trigger name="scan-spells-off" priority="12680" regex="true" enabled="false" id="1268">
    <pattern>^$</pattern>
    <value>#T- scan-spells
#LOOPDB @_check_spell  {#IF %val {} {#IF (%iskey( @_malad_list, %key)) {#DELKEY _malad_list %key} {#IF (%iskey( @_spell_list, %key)) {#IF (%ismember( %key, @_req_spell)) {#IF (%match( %key, "^Protection$")) {#IF (%iskey( @_spell_list, "Protection Evil") || %iskey( @_spell_list, "Protection Good") || %iskey( @_spell_list, "Protection Neutral")) {#DELKEY _spell_list %key} {
              #ADDKEY _spell_list %key 0
              #DELKEY _spell_list "Protection Evil"
              #DELKEY _spell_list "Protection Good"
              #DELKEY _spell_list "Protection Neutral"
              }} {#ADDKEY _spell_list %key 0}} {#DELKEY _spell_list %key}}}}}
_check_spell=%null
show_aff
#T- scan-spells-off</value>
  </trigger>
  <var name="_check_spell" type="Record" id="1269"/>
  <var name="_afw_update" id="1312">1</var>
  <alias name="show_aff" id="1360">
    <value><![CDATA[#FORALL @_req_spell {#IF (!%iskey( @_spell_list, %i)) {#IF (%match( %i, "^Protection$")) {#IF (%iskey( @_spell_list, "Protection Evil") || %iskey( @_spell_list, "Protection Good") || %iskey( @_spell_list, "Protection Neutral")) {} {#ADDKEY _spell_list %i 0}} {#ADDKEY _spell_list %i 0}}}
#FORALL @_hid_spell {#IF (!%iskey( @_spell_list, %i)) {#ADDKEY _spell_list %i 0}}
#CLR Affects
#LOCAL $_spell_list $_curr_rec
$_all_malas=%dbkeys( @_malad_list)
$_malas_rec=@_malad_list
$_prio_m_list=@_malad_order
#FORALL $_prio_m_list {#IF (!%ismember( %i, $_all_malas)) {#DELI $_prio_m_list %i}}
$_all_spells=%dbkeys( @_spell_list)
$_spells_rec=@_spell_list
#FORALL $_all_spells {#IF (%ismember( %i, @_hid_spell) && %db( @_spell_list, %i)>1) {
    #DELI $_all_spells %i
    #DELKEY $_spells_rec %i
    }}
$_prio_list=@_spell_order
#FORALL $_prio_list {#IF (!%ismember( %i, $_all_spells)) {#DELI $_prio_list %i}}
$_all_spells=$_prio_list
#IF (@_afw_set.top) {
  $_spell_list=$_all_malas
  $_curr_rec=$_malas_rec
  } {
  $_spell_list=$_all_spells
  $_curr_rec=$_spells_rec
  }

#LOCAL $_echo
#IF (%numitems( $_curr_rec)>0) {
  #LOOP %numitems( $_curr_rec) {
    $_spell=%item( $_spell_list, %i)
    $_val=%db( $_curr_rec, $_spell)
    #LOCAL $_type
    #IF (%iskey(@_accept_malad, $_spell)) {$_type=%db(@_accept_malad, $_spell)}
    #IF (%iskey(@_accept_spell, $_spell)) {$_type=%db(@_accept_spell, $_spell)}   
    #IF (%len( $_spell)>@_afw_set.max_len) {_afw_set.max_len=%len( $_spell)}
    #IF (%len( $_val)>@_afw_set.num_len) {_afw_set.num_len=%len( $_val)}
    $_sval=%string( $_val)
    $_spell=%format( &-@_afw_set.max_len s, $_spell)
    $_sval=%format( &@_afw_set.num_len s, $_sval)
    $_echo=%concat( $_echo, %switch( $_type, %ansi(15), @_afw_set.top, %ansi( 12), $_val>3, %ansi( 10), $_val<=3 AND $_val>1, %ansi( 14), $_val=0, %ansi( 78), 1, %ansi( 12)%if( @_afw_set.blink, %ansi( blink))))
    $_echo=%concat( $_echo, $_spell, ": "$_sval, %ansi( reset))
    #IF (@_afw_set!=1) {#IF !(%i\@_afw_set.spl) {$_echo=%concat( $_echo, %cr)} {#IF (%i!=%numitems( $_spells_rec)) {$_echo=%concat( $_echo, %ansi( 14)" | ")}}} {$_echo=%concat( $_echo, %cr)}
    }
  #WINDOW Affects $_echo
  } {#WINDOW Affects %if( @_afw_set.top, %ansi( 10)"No Maladictions to display.", %ansi( 14)"No spell affects to display.")%ansi( reset)%cr}

$_echo=%null
$_spell_list=%null
$_curr_rec=%null

#WINDOW Affects %cr%ansi( 14)"------------------"%ansi( reset)%cr
 
#IF (@_afw_set.top) {
  $_spell_list=$_all_spells
  $_curr_rec=$_spells_rec
  } {
  $_spell_list=$_all_malas
  $_curr_rec=$_malas_rec
  }

#IF (%numitems( $_curr_rec)>0) {
  #LOOP %numitems( $_curr_rec) {
    $_spell=%item( $_spell_list, %i)
    $_val=%db( $_curr_rec, $_spell)
    #LOCAL $_type
    #IF (%iskey(@_accept_malad, $_spell)) {$_type=%db(@_accept_malad, $_spell)}
    #IF (%iskey(@_accept_spell, $_spell)) {$_type=%db(@_accept_spell, $_spell)}   
    #IF (%len( $_spell)>@_afw_set.max_len) {_afw_set.max_len=%len( $_spell)}
    #IF (%len( $_val)>@_afw_set.num_len) {_afw_set.num_len=%len( $_val)}
    $_sval=%string( $_val)
    $_spell=%format( &-@_afw_set.max_len s, $_spell)
    $_sval=%format( &@_afw_set.num_len s, $_sval)
    $_echo=%concat( $_echo, %switch( $_type, %ansi(15), !@_afw_set.top, %ansi( 12), $_val>3, %ansi( 10), $_val<=3 AND $_val>1, %ansi( 14), $_val=0, %ansi( 78), 1, %ansi( 12)%if( @_afw_set.blink, %ansi( blink))))
    $_echo=%concat( $_echo, $_spell, ": "$_sval, %ansi( reset))
    #IF (@_afw_set!=1) {#IF !(%i\@_afw_set.spl) {$_echo=%concat( $_echo, %cr)} {#IF (%i!=%numitems( $_spells_rec)) {$_echo=%concat( $_echo, %ansi( 14)" | ")}}} {$_echo=%concat( $_echo, %cr)}
    }
  #WINDOW Affects $_echo
  }  {#WINDOW Affects %if( @_afw_set.top, %ansi( 14)"No spell affects to display.", %ansi( 10)"No Maladictions to display.")%ansi( reset)%cr}
]]></value>
  </alias>
  <alias name="affects" id="1373">
    <value><![CDATA[$_send_aff=0
#switch (%begins( "add", %1)) {
  $_params=%-3
  $_inc=0
  #IF (%rightback( $_params, 2)=" +") {
    $_inc=1
    $_params=%leftback( $_params, 2)
    }
  #SWITCH (%begins( "maladiction", %2)) {#IF (%ismember( $_params, @_accept_malad)) {
      $_mem_num=%ismember( $_params, @_accept_malad)
      $_spell=%item( @_accept_malad, $_mem_num)
      #show "The maladiction, "$_spell", is already in the list."
      } {#IF (%ismember( $_params, @_accept_spell)) {
        $_mem_num=%ismember( $_params, @_accept_spell)
        $_spell=%item( @_accept_spell, $_mem_num)
        #show "The maladiction, "$_spell", is already on the spells list."
        } {
        #ADDKEY _accept_malad $_params %if( $_inc, 1, 0)
        #ADDI _malad_order $_params
        #show $_params" added to the accepted maladictions list."
        affects gather
        }}}
   (%begins( "spell", %2)) {#IF (%ismember( $_params, @_accept_spell)) {
      $_mem_num=%ismember( $_params, @_accept_spell)
      $_spell=%item( @_accept_spell, $_mem_num)
      #show "The spell, "$_spell", is already in the list."
      } {#IF (%ismember( $_params, @_accept_malad)) {
        $_mem_num=%ismember( $_params, @_accept_malad)
        $_spell=%item( @_accept_malad, $_mem_num)
        #show "The spell, "$_spell", is already on the maladictions list."
        } {
        #ADDKEY _accept_spell $_params %if( $_inc, 1, 0)
        #ADDI _spell_order $_params
        #show $_params" added to the accepted spells list."
        affects gather
        }}}
    {#show "You need to specify: Do you wish to add a maladiction or a spell?"}
  }
  (%begins( "remove", %1)) {#IF (%ismember( %-2, @_accept_spell)) {
    $_mem_num=%ismember( %-2, @_accept_spell)
    #WIN History $_mem_num
    $_del_spell=%item( @_accept_spell, $_mem_num)
    #WIN History $_del_spell
    #IF (%ismember( $_del_spell, @_hid_spell)) {#DELI _hid_spell $_del_spell}
    #IF (%ismember( $_del_spell, @_req_spell)) {#DELI _req_spell $_del_spell}
    #DELI _spell_order $_del_spell
    #DELKEY _accept_spell $_del_spell
    #DELKEY _spell_list $_del_spell
    #show $_del_spell" has been deleted from the accepted spells."
    show_aff
    } {#IF (%ismember( %-2, @_accept_malad)) {
      $_mem_num=%ismember( %-2, @_accept_malad)
      $_del_spell=%item( @_accept_malad, $_mem_num)
      #DELI _malad_order $_del_spell
      #DELKEY _accept_malad $_del_spell
      #DELKEY _malad_list $_del_spell
      #show $_del_spell" has been deleted from the accepted maladictions."
      show_aff
      } {#show %-2", is not currently listed on the accepted spells."}}}
  (%begins( "history", %1)) {#IF (@_afw_set.history) {
    _afw_set.history=0
    #show "You will no longer see warnings in the History Window."
    #CLOSE History
    } {
    _afw_set.history=1
    #show "You will now see warnings in the History Window."
    #WINDOW History "Opening History Window"
    #T- clear-history
    #T+ clear-history
    }}
  (%begins( "gather", %1)) {
  #T+ gag-aff
  #T+ gag-aff-off
  #send "aff"
  }
  (%begins( "list", %1)) {
  #show "----------------------------------------------------"
  #show %ansi( 10)"Spells list:"%ansi( reset)
  #show "----------------------------------------------------"
  #LOOPDB @_accept_spell {#show %key%if( %iskey( @_spell_list, %key) && %db( @_spell_list, %key)>0, %ansi( 10)" *"%ansi( reset))%if( %ismember( %key, @_req_spell), %ansi( 12)" #"%ansi( reset))%if( %ismember( %key, @_hid_spell), %ansi( 14)" @"%ansi( reset))%if( %db( @_accept_spell, %key), %ansi( 15)" +"%ansi( reset))}
  #show "----------------------------------------------------"
  #show %ansi( 10)"*"%ansi( reset)" denotes an active spell."
  #show %ansi( 12)"#"%ansi( reset)" denotes a required spell."
  #show %ansi( 14)"@"%ansi( reset)" denotes a hidden spell."
  #show %ansi( 15)"+"%ansi( reset)" denotes an incrementing spell."
  #show "----------------------------------------------------"
  #show %ansi( 12)"Maladictions list:"%ansi( reset)
  #show "----------------------------------------------------"
  #LOOPDB @_accept_malad {#show %key" "%if( %iskey( @_malad_list, %key) && %db( @_malad_list, %key)>0, %ansi( 12)"*"%ansi( reset))%if( %db( @_accept_malad, %key), %ansi( 15)" +"%ansi( reset))}
  #show "----------------------------------------------------"
  #show %ansi( 12)"*"%ansi( reset)" denotes an active maladiction."
  #show %ansi( 15)"+"%ansi( reset)" denotes an incrementing maladiction."
  #show "----------------------------------------------------"
  }
  (%begins( "top", %1)) {#SWITCH (%begins( "spells", %2)) {
    _afw_set.top=0
    #show "Your spells will now appear at the top of the Affects Window."
    show_aff
    }
    (%begins( "maladictions", %2)) {
    _afw_set.top=1
    #show "Your maladictions will now appear at the top of the Affects Window."
    show_aff
    }
    {#show "You need to specify which you want on top, spells or maladictions?"}}
  (%begins( "move", %1)) {#IF  (%isnumber( %2)) {#IF (%-3!=%null) {#IF (%ismember( %-3, @_spell_list)) {#IF (%2<%numitems( @_spell_order)) {#IF (%ismember( %-3, @_spell_order)) {
            $_num=%2
            $_o_spell=%item( @_spell_order, $_num)
            $_n_spell=%-3
            $_num2=%ismember( $_n_spell, @_spell_order)
            #VAR _spell_order %replaceitem( $_n_spell, $_num, @_spell_order)
            #VAR _spell_order %replaceitem( $_o_spell, $_num2, @_spell_order)
            #show $_n_spell" switched to priority "$_num", "$_o_spell" switched to priority "$_num2
            show_aff
            }}} {#IF (%ismember( %-3, @_malad_list)) {#IF (%2<%numitems( @_malad_order)) {#IF (%ismember( %-3, @_malad_order)) {
              $_num=%2
              $_o_spell=%item( @_malad_order, $_num)
              $_n_spell=%-3
              $_num2=%ismember( $_n_spell, @_malad_order)
              #VAR _malad_order %replaceitem( $_n_spell, $_num, @_malad_order)
              #VAR _malad_order %replaceitem( $_o_spell, $_num2, @_malad_order)
              #show $_n_spell" switched to priority "$_num", "$_o_spell" switched to priority "$_num2
              show_aff
              }}} {#show %-3" is not on either list."}}} {#show "You need to enter a spell to move!"}}}
    (%begins( "lines", %1)) {#IF (%isnumber( %-2)) {
    _afw_set.spl=%-2
    #show "Affects Window will now show "%-2" spells per line."
    show_aff
    } {#show "You must enter a valid number to set the number of lines shown."}}
  (%begins( "auto", %1)) {#switch (%begins( "fade", %2)) {#IF (%ismember( %replace( %-3, "\,\", ","), @_fade_list)) {
      $_fade=%replace( %-3, "\,\", ",")
      #DELKEY _fade_list $_fade
      #IF (%numkeys( @_fade_list)<1) {#ADDKEY _fade_list null}
      #show "'"$_fade"' has been removed from the spell fade list."
      } {
      #LOCAL $_fade $_spell
      #IF (%match( %-3, "(*), (*)", $_fade, $_spell)) {
        $_spell=%trim( $_spell)
        #IF (%ismember( $_spell, @_accept_spell) || %ismember( $_spell, @_accept_malad)) {
          $_fade=%replace( $_fade, "\,\", ",")
          #ADDKEY _fade_list $_fade $_spell
          #show "'"$_fade"' added to the fade list for the spell: "$_spell
          #IF (%iskey( @_fade_list, null)) {#DELKEY _fade_list null}
          }
        {#show "You entered a spell that is not on the accepted spells or maladictions list."}
        } {
        #show "Try the following format:"
        #show "affects auto fade <spell echo>, <spell name>"
        }
      }}
      (%begins( "echo", %2)) {#IF (%ismember( %replace( %-3, "\,\", ","), @_echo_list)) {
      $_echo=%replace( %-3, "\,\", ",")
      #DELKEY _echo_list $_echo
      #IF (%numkeys( @_echo_list)<1) {#ADDKEY _echo_list null}
      #show "'"$_echo"' has been removed from the spell echo list."
      } {
      #LOCAL $_echo $_spell
      #IF (%match( %-3, "(*), (*)", $_echo, $_spell)) {
        $_spell=%trim( $_spell)
        #IF (%ismember( $_spell, @_accept_spell) || %ismember( $_spell, @_accept_malad)) {
          $_echo=%replace( $_echo, "\,\", ",")
          #ADDKEY _echo_list $_echo $_spell
          #show "'"$_echo"' added to the echo list for the spell: "$_spell
          #IF (%iskey( @_echo_list, null)) {#DELKEY _echo_list null}
          }
        {#show "You entered a spell that is not on the accepted spells or maladictions list."}
        } {
        #show "Try the following format:"
        #show "affects auto echo <spell echo>, <spell name>"
        }
      }}}
    (%begins( "required", %1)) {#IF (%ismember( %-2, @_accept_spell) || %ismember( %-2, "Protection")) {#IF (%ismember( %-2, @_req_spell)) {
      $_mem_num=%ismember( %-2, @_req_spell)
      #DELNI _req_spell $_mem_num
      #IF (%ismember( %-2, "Protection")) {
        $_mem_num=%ismember( %-2, @_spell_order)
        #DELNI _spell_order $_mem_num
        }
      #show %-2" has been removed from the required spells list."
      show_aff
      } {
      $_mem_num=%ismember( %-2, @_accept_spell)
      $_spell=%item( @_accept_spell, $_mem_num)
      #IF (!%db( @_accept_spell, $_spell)) {
        #ADDI _req_spell %-2
        #IF (%ismember( %-2, "Protection")) {#ADDI _spell_order "Protection"}     
        #show %-2" has been added to the required spells list."
        show_aff
        } {#show "You cannot add an incrementing spell to the required list."}
      }} {#show "You first need to add "%-2" to the accepted spells list. Then you may make it a required spell."}}
    (%begins( "hidden", %1)) {#IF (%ismember( %-2, @_accept_spell)) {#IF (%ismember( %-2, @_hid_spell)) {
      $_mem_num=%ismember( %-2, @_hid_spell)
      $_del_spell=%item( @_hid_spell, $_mem_num)
      #DELNI _hid_spell $_mem_num
      #show $_del_spell" has been removed from the hidden spells list."
      #show "This spell will still show up unless you remove it from the accepted spells."
      show_aff
      } {
      $_mem_num=%ismember( %-2, @_accept_spell)
      $_spell=%item( @_accept_spell, $_mem_num)
      #IF (!%db( @_accept_spell, $_spell)) {
        #ADDI _hid_spell %-2
        #show %-2" has been added to the hidden spells lists."
        show_aff
        } {#show "You cannot add an incrementing spell to the hidden list."}
      }} {#show %-2" spell is not on the accepted spells list. Please add it to accepted spells before making it hidden."}}
    (%begins( "blink", %1)) {#IF (@_afw_set.blink) {
    _afw_set.blink=0
    #show "Spells with one tick remaining will no longer blink."
    show_aff
    } {
    _afw_set.blink=1
    #show "Spells with one tick remaining will now blink."
    show_aff
    }}
    (%begins( "update", %1)) {#SWITCH (%begins( "reset", %2)) {
    _afw_update=0
    #show "@_afw_update has been reset. You can now run the updater again."
    }
    {
    #show "New to Affects Window v.0.7"
    #show %ansi( 10)"Commands:"%ansi( reset)
    #show %ansi( 9)"> Affects"%ansi( reset)
    #show "- New Parameter:"
    #show "  - history: This parameter allows you to toggle the History Window."
    #show "- New Sub-Parameter:"
    #show "  add :: +: a + sign may be added after a new spell or maladiction"
    #show "            to indicate that it is incrementing."
    #show %ansi( 10)"Features:"%ansi( reset)
    #show %ansi( 14)"> History Window"%ansi( reset)
    #show "- This new window is a window that is used in multiple scripts written"
    #show "  by Shanked. In the Affects Window script it will display tick warnings"
    #show "  and spell fade warnings. This is useful in case spells fall in battle"
    #show "  and the combat text spams them off screen. You will be able to see them"
    #show "  in a window which refreshes itself after 60 seconds of no updates."
    #show %ansi( 14)"> Incrementing Spells"%ansi( reset)
    #show "- A select few spells in the game increment instead of decrement (such as"
    #show "  killing rage). For these spells, a parameter has been added that allows"
    #show "  you to set a new spell or maladiction as incrementing. These will show up"
    #show "  as white in the window. Incrementing spells cannot be made hidden or required."
    #show %ansi( 10)"Misc:"%ansi( reset)
    #show %ansi( 11)"> Variable Consolidation"%ansi( reset)
    #show "- The @_max_len and @_num_len variables are being removed. In"
    #show "  their place will be two new keys to the @_afw_set variable"
    #show "  with similar names and performing the same function."
    #IF (!@_afw_update) {
      #show " "
      #show "Running the updates for Affects Window v0.7..."
      #show "Removing Variables: "
      #show "- @_max_len"
      #show "- @_num_len"
      #UNVAR _max_len
      #UNVAR _num_len
      #show "Variables removed."
      #show "Adding keys: "
      #show "> @_afw_set"
      #show "- max_len"
      #show "- num_len"
      #show "- history"
      #ADDKEY _afw_set max_len 0
      #ADDKEY _afw_set num_len 0
      #ADDKEY _afw_set history 0
      #show "Keys added and set to default values."
      #show "Converting Variables: "
      #show "- @_accept_spell :: stringlist -> record variable"
      #show "- @_accept_malad :: stringlist -> record variable"
      #CALL %vartype( _accept_spell, 5)
      #CALL %vartype( _accept_malad, 5)
      #LOOPDB @_accept_spell {#ADDKEY _accept_spell %key 0}
      #LOOPDB @_accept_malad {#ADDKEY _accept_malad %key 0}
      #show "Variables converted, set to default values."
      #VAR _afw_update 1
      #show "Updates complete!"
      show_aff
      } {
      #show "You're already updated to the current version."
      #show "If for some reason you've seen this message in err, please type 'affects update reset' and then 'affects update'"
      }
    }}
  (%begins( "help", %1)) {#SWITCH (%begins( "add", %2)) {
    #show "-----------------------------------------------------------"
    #show "ADD:"
    #show "-----------------------------------------------------------"
    #show "This command allows you to add spells to the spells list or"
    #show "the maladictions list. Which list it is in will dictate where"
    #show "it appears in the affects window, and how it will appear. The"
    #show "command requires that you tell it which list the spell goes"
    #show "in before you give it the spell, this is an important"
    #show "sub-parameter and it will remind you if you forget. Spells"
    #show "entered are both case-sensitive and not case-sensitive. It"
    #show "will recognize whether a spell is already in the lists"
    #show "regardless of case, but the spells will appear in the window"
    #show "in the case they were entered in. So, if you entered it as"
    #show "'StOnE SkIn' it would appear just like that in the window."
    #show %ansi( 10)"Syntax:"%ansi( reset)" affects add (spell, maladiction) <spell name>"
    #show "ex: affects add spell Sanctuary"
    #show "the example above would add Sanctuary to the spells list."
    #show %ansi(14)"Incrementing Spells:"%ansi(reset)
    #show "You can denote a spell as incrementing by adding a '+' at the end"
    #show "of the spell, with a space. Incrementing spells count up every tick"
    #show "and appear in white. The only way to wipe an incrementing spell from"
    #show "the window automatically is to have the appropriate fade echo for when"
    #show "it falls off."
    #show %ansi( 10)"Syntax:"%ansi( reset)" affects add (spell, maladiction) <spell name> +"   
    #show "ex: affects add spell Killing Rage +"
    #show "the example above would add Killing Rage to the spells list and"
    #show "it would be denoted as an incrementing spell."
    #show "-----------------------------------------------------------"   
    }
     (%begins( "remove", %2)) {
    #show "-----------------------------------------------------------"
    #show "REMOVE:"
    #show "-----------------------------------------------------------"
    #show "This command allows you to remove spells from the spells or"
    #show "maladictions list. It detects which list to remove from smartly,"
    #show "since a spell can only be on one list or the either. For that"
    #show "reason, you don't need to specify as you do with the add"
    #show "parameter. This command is not case-sensitive, though when the"
    #show "spell is removed, it will show up in the case it was entered in."
    #show %ansi( 10)"Syntax:"%ansi( reset)" affects remove <spell name>"
    #show "ex: affects remove Sanctuary"
    #show "the example above would remove Sanctuary from the spells or"
    #show "maladictions list, depending on where it was."
    #show "-----------------------------------------------------------"
    }
     (%begins( "lines", %2)) {
    #show "-----------------------------------------------------------"
    #show "LINES:"
    #show "-----------------------------------------------------------"
    #show "This command allows you to change the number of spells per"
    #show "line in the affects window. It will do this even if the spells"
    #show "do not fit, which means they will attempt to wrap if wrapping"
    #show "is on, or extend horizontally otherwise. Default is 2."
    #show %ansi( 10)"Syntax:"%ansi( reset)" affects lines <#>"
    #show "ex: affects lines 1"
    #show "the example above would put all the spells on their own line."
    #show "-----------------------------------------------------------"
    }
     (%begins( "Move", %2)) {
    #show "-----------------------------------------------------------"
    #show "MOVE:"
    #show "-----------------------------------------------------------"
    #show "This command allows you to change the order of spells or of"
    #show "maladictions as they appear in the Affects Window. The script"
    #show "will smartly identify whether the name given is in the spells"
    #show "or maladictions list and so it does not need to be specified"
    #show "in the syntax."
    #show %ansi( 10)"Syntax:"%ansi( reset)" affects move <#> <spell name>"
    #show "ex: move 1 Sanctuary"
    #show "the example above would make Sanctuary the first spell to appear"
    #show "on the list, and would move whatever spell had been number 1 to"
    #show "Sanctuary's previous location."
    #show "-----------------------------------------------------------"
    }   
     (%begins( "blink", %2)) {
    #show "-----------------------------------------------------------"
    #show "BLINK:"
    #show "-----------------------------------------------------------"
    #show "This command allows you to toggle blink warnings on and off."
    #show "when toggled on, spells will blink with 1 tick remaining, and"
    #show "their in-window warning will blink as well."
    #show %ansi( 10)"Syntax:"%ansi( reset)" affects blink"
    #show "ex: There are no variables"
    #show "-----------------------------------------------------------"
    }       
     (%begins( "Gather", %2)) {
    #show "-----------------------------------------------------------"
    #show "GATHER:"
    #show "-----------------------------------------------------------"
    #show "This command allows you to run a gagged affects in the MUD"
    #show "in order to update the Affects Window without interrupting"
    #show "your main session with affects spam."
    #show %ansi( 10)"Syntax:"%ansi( reset)" affects gather"
    #show "ex: There are no variables."
    #show "-----------------------------------------------------------"
    }       
     (%begins( "hidden", %2)) {
    #show "-----------------------------------------------------------"
    #show "HIDDEN:"
    #show "-----------------------------------------------------------"
    #show "This command allows you to add a spell to the hidden list."
    #show "Hidden spells are on the list, but do not show in the affects"
    #show "window until they're about to fall off, or when they're no"
    #show "no longer active. This command smartly removes and adds spells"
    #show "to the list by checking to see if they are there already."
    #show "This command is not case-sensitive."
    #show %ansi( 10)"Syntax:"%ansi( reset)" affects hidden <spell name>"
    #show "ex: affects hidden Detect Invis"
    #show "the example above would add the spell Detect Invis to the"
    #show "hidden list, or remove it if it was already on."
    #show "-----------------------------------------------------------"
    }       
     (%begins( "required", %2)) {
    #show "-----------------------------------------------------------"
    #show "REQUIRED:"
    #show "-----------------------------------------------------------"
    #show "This command allows you to add a spell to the required spells"
    #show "list. Required spells are not removed from the list when they"
    #show "fall off. Rather, they show up with the spell name and show 0"
    #show "ticks next to them. This command smartly removes and adds spells"
    #show "to the list by checking to see if they are there already."
    #show %ansi( 10)"Syntax:"%ansi( reset)" affects required <spell name>"
    #show "ex: affects required Sanctuary"
    #show "the example above would add the spell Sanctuary to the required"
    #show "list, or remove it if it was already on."
    #show "-----------------------------------------------------------"
    }     
     (%begins( "auto", %2)) {
    #show "-----------------------------------------------------------"
    #show "AUTO:"
    #show "-----------------------------------------------------------"
    #show "This command allows you to add to adjust settings for the"
    #show "automated updating and removal of spells from the list. The"
    #show "echo sub-parameter allows you to set the script to automatically"
    #show "update when a spell is cast on you. Whereas the fade sub-parameter"
    #show "allows the script to instantly show when a spell falls (useful"
    #show "if you've just been dispelled). This command smartly removes and"
    #show "adds to the lists by checking to see if they are there already."
    #show "It's also important to note that this command only works if you"
    #show "feed it accurate information. Try to leave ending punctuation"
    #show "marks such as periods and exclamation points out of the spell"
    #show "echoes. If the echo contains a comma, please wrap the comma in"
    #show "slash marks '\' like so: \,\. This will preserve the command for"
    #show "the echo."
    #show %ansi( 10)"Syntax:"%ansi( reset)" affects auto (echo, fade) <spell echo>, <spell name>"
    #show "ex: affects auto echo You are surrounded by a white aura, Sanctuary"
    #show "the above example would allow the script to run a gagged affects"
    #show "to update for the Sanctuary spell whenever the echo occured."
    #show "ex: affects auto fade The white aura aroudn your body fades, Sanctuary"
    #show "the example above would allow the script to immediately set Sanctuary"
    #show "to 0 and show a warning that it has fallen."
    #show "-----------------------------------------------------------"
    } 
     (%begins( "list", %2)) {
    #show "-----------------------------------------------------------"
    #show "LIST:"
    #show "-----------------------------------------------------------"
    #show "This command allows you to see a list of all of the spells in"
    #show "your spell and maladictions list. It will also mark each with"
    #show "useful information such as whether it's on the required or hidden"
    #show "spells list and whether or not it's active."
    #show %ansi( 10)"Syntax:"%ansi( reset)" affects list"
    #show "ex: There are no variables."
    #show %ansi( 4)"credit to "%ansi( 8)"Xoric's"%ansi( 4)" player for this command!"%ansi( reset)
    #show "-----------------------------------------------------------"
    }
     (%begins( "top", %2)) {
    #show "-----------------------------------------------------------"
    #show "TOP:"
    #show "-----------------------------------------------------------"
    #show "This command allows you to place either spells or maladictions"
    #show "at the top of the window, depending on how you want them."
    #show %ansi( 10)"Syntax:"%ansi( reset)" affects top (spells, maladictions)"
    #show "ex: affects top spells"
    #show "the example above would put spells first (on top) and then maladictions"
    #show "after."
    #show "-----------------------------------------------------------"
    }   
     (%begins( "history", %2)) {
    #show "-----------------------------------------------------------"
    #show "HISTORY:"
    #show "-----------------------------------------------------------"
    #show "This command allows you to toggle the history window for the"
    #show "Affects Window script. The History Window is a window used by"
    #show "Shanked in numerous scripts. For the Affects Window script it"
    #show "shows tick and spell fade warnings."
    #show %ansi( 10)"Syntax:"%ansi( reset)" affects history"
    #show "ex: There are no variables."
    #show "-----------------------------------------------------------"
    }       
  {
    #show "-----------------------------------------------------------"
    #show "HELP:"
    #show "-----------------------------------------------------------"
    #show "Type affects help <parameter> for more information on a specific"
    #show "parameter. ex: affects help add"
    #show "> "%ansi( 10)"add (spell, mala) <spell name>:"%ansi( reset)" allows you to add spells."
    #show "> "%ansi( 10)"remove <spell name>:"%ansi( reset)" allows you to remove spells."
    #show "> "%ansi( 10)"lines <#>:"%ansi( reset)" allows you to change how many spells are on each line."
    #show "> "%ansi( 10)"list: "%ansi( reset)" allows you to see all of the spells and malas in your list."
    #show "> "%ansi( 10)"top (spells, mala): "%ansi( reset)" allows you to set whether you want spells or malas first."
    #show "> "%ansi( 10)"move <#> <spell name>:"%ansi( reset)" allows you to change spell order."
    #show "> "%ansi( 10)"blink:"%ansi( reset)" allows you to toggle blinky warnings."
    #show "> "%ansi( 10)"gather:"%ansi( reset)" runs a gagged parse of the affects list."
    #show "> "%ansi( 10)"hidden <spell name>:"%ansi( reset)" adds spells to the hidden list."
    #show "> "%ansi( 10)"required <spell name>:"%ansi( reset)" adds spells to the required list."
    #show "> "%ansi( 10)"history:"%ansi(reset)" toggles the history window."
    #show "> "%ansi( 10)"auto (echo, fade) (see helpfile):"%ansi( reset)"
    #show "> "%ansi( 10)"update:"%ansi( reset)" updates to the latest version of Affects when you install a new version."
    #show "-----------------------------------------------------------"     
    }}
  {
  #send "aff"
  $_send_aff=1
  }
 
#if (!$_send_aff) {#send %cr}]]></value>
  </alias>
  <trigger name="check-echo" priority="13740" id="1374">
    <pattern>^({@_echo_list})</pattern>
    <value>affects gather</value>
  </trigger>
  <trigger name="check-fade" priority="13750" id="1375">
    <pattern>^({@_fade_list})</pattern>
    <value><![CDATA[$_key=%concat( "'", %1, "'")
$_spell=%db( @_fade_list, %1)

#IF (%ismember( $_spell, @_accept_spell)) {
  #show %ansi( 12)">>> "%ansi( 14)$_spell%ansi( 15)" has FALLEN! "%ansi( 12)"<<<"%ansi( reset)
  #IF (@_afw_set.history) {
    #WINDOW History %ansi( 12)">>> "%ansi( 14)$_spell%ansi( 15)" has FALLEN! "%ansi( 12)"<<<"%ansi( reset)
    #T- clear-history
    #T+ clear-history
    }
  #IF (%ismember( $_spell, @_req_spell) || %ismember( $_spell, @_hide_spell)) {#ADDKEY _spell_list $_spell 0} {#IF (%ismember( $_spell, "Protection Good|Protection Evil|Protection Neutral") && %ismember( "Protection", @_req_spell)) {#ADDKEY _spell_list "Protection" 0} {#DELKEY $_spell}}
  } {#IF (%ismember( $_spell, @_accept_malad)) {
    #show %ansi( 10)">>> "%ansi( 15)"You are no longer affected by: "%ansi( 14)$_spell%ansi( 10)" <<<"%ansi( reset)
    #IF (@_afw_set.history) {
      #WINDOW History %ansi( 10)">>> "%ansi( 15)"You are no longer affected by: "%ansi( 14)$_spell%ansi( 10)" <<<"%ansi( reset)
      #T- clear-history
      #T+ clear-history
      }
    #DELKEY _malad_list $_spell
    }}

show_aff]]></value>
  </trigger>
</class>


here are the settings:
Code:

<class name="Affects Window Settings" id="126">
  <var name="_accept_spell" type="Record" id="127">Detect Invis=0|Sanctuary=0|Invisibility=0|Detect Hidden=0|Haste=0|Self Projection=0</var>
  <var name="_req_spell" type="StringList" id="128">Sanctuary</var>
  <var name="_spell_list" type="Record" id="129">Detect Invis=0|Sanctuary=0|Detect Hidden=0|Self Projection=35</var>
  <var name="_afw_set" type="Record" id="130">history=0|top=0|num_len=2|blink=0|max_len=15|spl=2</var>
  <var name="_hid_spell" type="StringList" id="131">Detect Invis|Detect Hidden</var>
  <var name="_spell_order" type="StringList" id="132">Sanctuary|Haste|Detect Invis|Self Projection|Detect Hidden|Invisibility</var>
  <var name="_malad_list" type="Record" id="133"/>
  <var name="_accept_malad" type="Record" id="134"/>
  <var name="_malad_order" type="StringList" id="135"/>
  <var name="_fade_list" type="Record" id="136">The white aura around your body fades=Sanctuary</var>
  <var name="_echo_list" type="Record" id="137">You are surrounded by a white aura=Sanctuary</var>
</class>


If anyone is able to see something I'm missing, please let me know. I'm going to continue and try to probe it for clues, but I'm utterly lost right now. I'll let you know more if I find it out.

Here's an example of what the affects list looks like in the game so you can use it for testing:
Code:


You are affected by the following spells:
Spell: invisibility      : modifies none by 0 for 32 cycles, (16 hours)
Spell: shield            : modifies armor class by -20 for 0 cycles, (0 hours)


It goes:
Spell: <Spell Name>(spaces): modifies (none, words) by (number, negative number) for (number) cycles, ((number) hours)

So you can add more spells if you need in order to test it properly.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Jun 22, 2010 8:30 pm   
 
I haven't taken a deep look at your code (five pages of code?!), but based on the clues you've provided, I will guess that the problem is you are trying to rely on the order of keys in the database variable. You can't do that. A database variable (in the public version of Cmud) is a hash table, and you cannot rely on the order of elements. I think you'll need to work out a different method, if you are in fact trying to rely on the key order.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Tue Jun 22, 2010 9:04 pm   
 
I've come to similar conclusions Rahab, and am considering going with Linked stringlists instead. I'll let you guys know if it works out.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Wed Jun 23, 2010 3:12 pm   
 
Linked Stringlists worked. I'll keep that info in mind with Record Vars in the future.
_________________
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 General Discussion 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