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: Mon Mar 29, 2010 5:19 am   

Alias Not Firing, no Errors
 
Alright, so this is an odd situation. I have an alias that will not fire under the following two conditions:

It will not fire if I type:
updater add some phrase goes here
updater delete w yells( \(w+\))? '*'

nor will it fire if I type:
updater

However, typing anything else causes the alias to go as normal.

Here's the alias:
Code:

#T- Gatherer-Off
#T+ Gatherer-Off
$_show = 1
#switch (%1="clan" || %1="cla" || %1="cl" || %1="c") {
    #T+ Gatherer
    #send "whoc"
    }
 (%1="loner" || %1="lone" || %1="lon" || %1="lo" || %1="l") {
    #T+ Gatherer
    #send "who loner"
 }
 (%1="kingdom" || %1="kingdo" || %1="kingd" || %1="king" || %1="kin" || %1="ki" || %1=k") {
    #T+ Gatherer
    #send "whok"
 }
 (%1="angel" || %1="ange" || %1="ang" || %1="an" || %1="a") {
    #T+ Gatherer
    #send "who angel"
 } 
 (%1="demon" || %1="demo" || %1="dem" || %1="de" || %1="d") {
    #T+ Gatherer
    #send "who demon"
 } 
 (%1="giant" || %1="gian" || %1="gia" || %1="gi" || %1="g") {
    #T+ Gatherer
    #send "who giant"
 } 
 (%1="renegade" || %1="renegad" || %1="renega" || %1="reneg" || %1="rene" || %1="ren" || %1="re" || %1="r") {
    #T+ Gatherer
    #send "who renegade"
 }
 (%1"show" || %1="sho" || %1="sh" || %1="s") {
  $_show = 0
  #switch (%-2="level" || %-2="leve" || %-2="lev" || %-2="le" || %-2="l" || %-2="lvl") {
   #IF (@_show_change_lvl)
   {
    _show_change_lvl=0
    #show "Clan Highlighter will no longer display level changes."
   }
   {
    _show_change_lvl=1
    #show "Clan Highlighter will now display level changes."
   }
  }
   (%-2="clan") {
    #IF (@_show_change_clan)
   {
    _show_change_clan=0
    #show "Clan Highlighter will no longer display clan changes."
   }
   {
    _show_change_lvl=1
    #show "Clan Highlighter will now display clan changes."
   }
  }
   (%-2="class" || %-2="clas") {
   #IF (@_show_change_class)
   {
    _show_change_class=0
    #show "Clan Highlighter will no longer display class changes."
   }
   {
    _show_change_class=1
    #show "Clan Highlighter will now display class changes."
   } 
  }
   (%-2="rank" || %-2="ran" || %-2="ra" || %-2="r") {
   #IF (@_show_change_rank)
   {
    _show_change_rank=0
    #show "Clan Highlighter will no longer display rank changes."
   }
   {
    _show_change_rank=1
    #show "Clan Highlighter will now display rank changes."
   } 
  }
   (%-2="new" || %-2="ne" || %-2="n") {
   #IF (@_show_new)
   {
    _show_change_new=0
    #show "Clan Highlighter will no longer display new members."
   }
   {
    _show_change_new=1
    #show "Clan Highlighter will now new members."
   } 
  }
   (%-2="all" || %-2="al" || %-2="a") {
   #IF (@_show_all)
   {
    _show_all=0
    _show_change_lvl=0
    _show_change_class=0
    _show_change_clan=0
    _show_change_rank=0
    _show_new=0
    #show "Clan Highlighter is now set to show no changes or new members."
   }
   {
    _show_all=1
    _show_change_lvl=1
    _show_change_class=1
    _show_change_clan=1
    _show_change_rank=1
    _show_new=1
    #show "Clan Highlighter is now set to show all changes and new members"
   } 
  }
 }
 (%1="add" || %1="ad") {
  $_show = 0
  $_phrase = %-2
  $_phrase = %replace($_phrase, "w", "[\w'-]+")
  $_phrase = %replace($_phrase, "w+", "[\w '-]+")
  $_phrase = %replace($_phrase, "d", "\d+")
  $_phrase = %replace($_phrase, "*", ".*")
  #ADDI _highlight_if $_phrase
  #show $_phrase " added to the highlight list."
 }
 (%1="delete" || %1="delet" || %1="dele" || %1="del") {
  $_show = 0
  $_phrase = %-2
  $_phrase = %replace($_phrase, "w", "[\w'-]+")
  $_phrase = %replace($_phrase, "w+", "[\w '-]+")
  $_phrase = %replace($_phrase, "d", "\d+")
  $_phrase = %replace($_phrase, "*", ".*")
  #IF (%ismember($_phrase, @_highlight_if))
  {
   #DELITEM _highlight_if $_phrase
   #show $_phrase " has been deleted from the highlight list."
  }
 }
 {
    #T+ Gatherer
    #send "whoc"
 }
 
#IF ($_show)
{
 #T+ Continue-who
 #T+ Stop-who
 #say "Gathering updates..."
 #show "Please do not input commands until the 'Updates Complete' message is shown. Thank you."
}


I'm adding the "add" and "delete" commands to the alias so that people can put in their own patterns for a particular trigger I have. Is this even possible? Or am I being too ambitious?
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Mar 29, 2010 6:07 am   
 
Quote:

updater delete w yells( \(w+\))? '*'


() equates to evaluation, and since trigger-pattern parsing doesn't apply anywhere but to actual trigger patterns (this does not include arguments to aliases that happen to be the text of a trigger pattern) they are probably getting filtered out of what goes into %-2. Ultimately, this would mean that the delete option is trying to delete something that doesn't exist but is otherwise working perfectly.

To fix, you need to surround the text going to %-2 with "" or use the %literal() command.

You didn't supply any examples for the add option, but I didn't see anything in there that would indicate a failure for at least the %1 match to take place. Try putting in some #PRINT commands to see what's actually happening along the way?
_________________
EDIT: I didn't like my old signature
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Mon Mar 29, 2010 6:53 am   
 
I put in some #show commands and it simply isn't entering into add for whatever reason. I figured the same problems would occur for both add and delete, as their behavior is the same.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Mon Mar 29, 2010 3:35 pm   
 
To add to this mystery...

I hadn't actually wanted it in the updater alias, so I moved it to the "highlight" alias. When moved there, I noticed that it began to work, albeit with some errors. Typing the following:
highlight add w yells( \(w+\)? '*'
turned into:
[\w'-]+ yells( \([\w '-]++\))? '.*'

The extra + being an issue.

Not sure why it was happening, I changed the script to require a \w, \w+, etc... to further distinguish them. In addition, I put some reverse parsing for when the information would be sent back to them from the list so that they could see it as they knew how to type it (I don't expect them to know regex, hence the simplified version).

Here's the alias:
Code:

<alias name="highlight" id="496">
  <value><![CDATA[#IF (%params != %null)
{
  #switch (%1="lvl" || %1="level" || %1="leve" || %1="lev" || %1="le" || %1="l") {
      #if (@_s_lvl)
      {
        _s_lvl=0
        #show "Levels will no longer be shown in the Highlighter."
      }
      {
        _s_lvl=1
        #show "Levels will now be shown in the Highlighter."
      }
    }
    (%1="rank" || %1="ran" || %1="ra" || %1=r") {
      #if (@_s_rank)
      {
        _s_rank=0
        #show "Ranks will no longer be shown in the Highlighter."
      }
      {
        _s_rank=1
        #show "Ranks will now be shown in the Highlighter."
      }
    }
    (%1="flag" || %1="fla" || %1="fl" || %1="f") {
      #if (@_s_flag)
      {
        _s_flag=0
        #show "Flags will no longer be shown in the Highlighter."
      }
      {
        _s_flag=1
        #show "Flags will now be shown in the Highlighter."
      }
    } 
    (%1="class" || %1="clas" || %1="cla" || %1 = "cl" || %1="c") {
      #if (@_s_class)
      {
        _s_class=0
        #show "Classes will no longer be shown in the Highlighter."
      }
      {
        _s_class=1
        #show "Classes will now be shown in the Highlighter."
      }
    } 
    (%1="highlight" || %1="highligh" || %1="highlig" || %1="highli" || %1="highl" || %1 = "high") {
      #if (@_s_highlight)
      {
        _s_highlight=0
        #show "Highlighting will no longer be shown in the Highlighter."
      }
      {
        _s_highlight=1
        #show "Highlighting will now be shown in the Highlighter."
      }
    }
    (%1="toggle" || %1="toggl" || %1="togg" || %1="tog" || %1="to" || %1="t") {
     $_phrase = %-2
     $_phrase = %replace($_phrase, "w", "[\w'-]+")
     $_phrase = %replace($_phrase, "w+", "[\w '-]+")
     $_phrase = %replace($_phrase, "d", "\d+")
     $_phrase = %replace($_phrase, "*", ".*")
     #IF (%ismember($_phrase, @_highlight_if))
     {
      $_mem_num = %ismember($_phrase, @_highlight_if)
      #IF (%item(@_highlight_if_on, $_mem_num)="ON")
      {
       #VAR _highlight_if_on %replaceitem("OFF", $_mem_num, @_highlight_if_on)
       #show $_phrase" will no longer be shown in the Highlighter, but will remain on the list."
      }
      {
       #VAR _highlight_if_on %replaceitem("ON", $_mem_num, @_highlight_if_on)
       #show $_phrase" will be shown in the Highlighter."
      }
     }
     {
      #show "Sorry, that phrase is not on the list."
      #show "Perhaps you meant one of the following:"
      $_iter = 1
      $_is_match = 0
      #FORALL @_highlight_if {
       #IF (%match(%item(@_highlight_if, $_iter), $_phrase))
       {
        #ADDI _par_match %item(@_highlight_if, $_iter)
        $_is_match = 1
       }
       $_iter  = $_iter + 1
      }
      $_iter = 1
      #IF (%numitems(@_par_match)>1)
      {
       #FORALL @_par_match {
         $_phrase = %item(@_par_match, $_iter)
         $_phrase = %replace($_phrase, "[\w'-]+", "\w")
         $_phrase = %replace($_phrase, "[\w '-]+", "\w+")
         $_phrase = %replace($_phrase, "\d+", "\d")
         $_phrase = %replace($_phrase, ".*", "*")       
        #show $_phrase
        $_iter = $_iter + 1
       }
      }
      {
       #show %item(@_par_match, 1)
      }
      #FORALL @_par_match {
       #DELNITEM _par_match 1
      }
     }
    }
    (%1="add" || %1="ad") {
     $_show = 0
     $_phrase = %-2
     $_phrase = %replace($_phrase, "\w", "[\w'-]+")
     $_phrase = %replace($_phrase, "\w+", "[\w '-]+")
     $_phrase = %replace($_phrase, "\d", "\d+")
     $_phrase = %replace($_phrase, "*", ".*")
     #ADDI _highlight_if $_phrase
     #VAR _highlight_if_on %additem("ON", @_highlight_if_on)
     #show $_phrase " added to the highlight list."
    }
    (%1="delete" || %1="delet" || %1="dele" || %1="del") {
     $_show = 0
     $_phrase = %-2
     $_phrase = %replace($_phrase, "\w", "[\w'-]+")
     $_phrase = %replace($_phrase, "\w+", "[\w '-]+")
     $_phrase = %replace($_phrase, "\d", "\d+")
     $_phrase = %replace($_phrase, "*", ".*")
     #IF (%ismember($_phrase, @_highlight_if))
     {
      $_mem_num = %ismember($_phrase, @_highlight_if)
      #DELNITEM _highlight_if $_mem_num
      #DELNITEM _highlight_if_on $_mem_num
      #show $_phrase " has been deleted from the highlight list."
     }
     {
       #show "Sorry, that phrase is not on the list."
       #show "Perhaps you meant one of the following:"
       $_iter = 1
       $_is_match = 0
       #FORALL @_highlight_if {
        #IF (%match(%item(@_highlight_if, $_iter), $_phrase))
        {
         #ADDI _par_match %item(@_highlight_if, $_iter)
         $_is_match = 1
        }
        $_iter  = $_iter + 1
       }
       $_iter = 1
       #IF (%numitems(@_par_match)>1)
       {
        #FORALL @_par_match {
         $_phrase = %item(@_par_match, $_iter)
         $_phrase = %replace($_phrase, "[\w'-]+", "\w")
         $_phrase = %replace($_phrase, "[\w '-]+", "\w+")
         $_phrase = %replace($_phrase, "\d+", "\d")
         $_phrase = %replace($_phrase, ".*", "*")       
         #show
         $_iter = $_iter + 1
        }
       }
       {
        #show %item(@_par_match, 1)
       }
       #FORALL @_par_match {
        #DELNITEM _par_match 1
       }
     } 
    }   
    (%1="help" || %1="hel" || %1="he" || %1="h") {
      #switch (%2="find" || %2="fin" || %2="fi" || %2="f") {
          #show "-----------------------------------------------------------"
          #show "FIND"
          #show "-----------------------------------------------------------"
          #show "Typing this command will bring up all relevant information"
          #show "on a particular character in the following format:"
          #show "[ "%ansi(3)"clan"%ansi(reset)" ][lvl class] name (rank)"
          #show "this command also takes partial matches, and will list all"
          #show "partial matches in the following format:"
          #show "name [ "%ansi(3)"clan"%ansi(reset)" ]"
          #show "Finally, you can use 'all' for your argument instead of a"
          #show "name or part of a name, which will list all of the names"
          #show "currently on record."
          #show %ansi(12)"NOTE"%ansi(reset)": listing ALL of the names will likely be a bit spammy."
          #show "-----------------------------------------------------------"     
        }
        (%2="edit" || %2="edi" || %2="ed" || %2="e") {
          #show "-----------------------------------------------------------"
          #show "EDIT:"
          #show "-----------------------------------------------------------"
          #show "This command allows you to manually edit, add, or delete"
          #show "entries. Even though the automatic updater will add and"
          #show "adjust entries for you, you may wish to change information"
          #show "before it does, or correct information which it parses"
          #show "incorrectly. The automatic updater cannot delete entries,"
          #show "so the delete option is your only way to remove them."
          #show "edit takes the following arguments:"
          #show %ansi(12)"NOTE"%ansi(reset)": "%ansi(15)"Shalonesti Kingdom"%ansi(reset)" must be manually entered as"
          #show "the following: "%ansi(15)"Shalonesti-k"%ansi(reset)
          #show "- "%ansi(10)"clan:"%ansi(reset)" This will allow you to manually adjust the clan or"
          #show "  or kingdom of any current entry. It will do this whether"
          #show "  or not they have one to change."
          #show ":: ex: edit clan Yasan Shalonesti"
          #show "- "%ansi(10)"rank:"%ansi(reset)" This will allow you to manually adjust the rank of"
          #show "  any character currently in the list. It will do this"
          #show "  whether or not they have one to change."
          #show ":: ex: edit rank Yasan Sha'falas"
          #show "- "%ansi(10)"level:"%ansi(reset)" This will allow you to manually adjust the level"
          #show "  of any character currently in the lists. It will do this"
          #show "  whether or not they have one to change."
          #show ":: ex: edit lvl Yasan 51 OR update level Yasan 51"
          #show "- "%ansi(10)"class:"%ansi(reset)" this will allow you to manually adjust the class"
          #show "  of any character currently in the lists. It will do this"
          #show "  whether or not they have one to change."
          #show ":: ex: edit class Yasan Bladesinger"
          #show "- "%ansi(10)"delete:"%ansi(reset)" This will allow you to manually delete any"
          #show "  any character in the lists and all associated records."
          #show "  you must enter the command twice in order for it to perform"
          #show "  and three times for delete all."
          #show ":: ex: edit del Yasan OR update delete Yasan"
          #show %ansi(12)"NOTE"%ansi(reset)": typing "%ansi(12)"delete all"%ansi(reset)" will delete all of the records in the"
          #show "list."
          #show "- "%ansi(10)"add:"%ansi(reset)" This will manually add any character to the lists that"
          #show "is not currently in the lists. It has a specific entry format"
          #show "which must be followed."
          #show "The format is: edit add <name> <level> <class> <clan> <rank>"
          #show ":: ex: edit add Yasan 51 Bladesinger Shalonesti Sha'falas"
          #show "-----------------------------------------------------------"
        }
        (%2=updater || %2="update" || %2="updat" || %2="upda" || %2="upd" || %2="up" || %2="u") {
          #show "-----------------------------------------------------------"
          #show "UPDATER:"
          #show "-----------------------------------------------------------"
          #show "The updater command is one that can be used with or without"
          #show "arguments. Without arguments, it will run a parse on the whoc"
          #show "list and gather updates on clanners."
          #show "updater also takes the following arguments:"
          #show "- "%ansi(10)"clan:"%ansi(reset)" this is the default option. Typing it will still"
          #show "  only bring up and parse the whoc list."
          #show ":: ex: updater clan"
          #show "- "%ansi(10)"kingdom:"%ansi(reset)" this will run the whok list and parse"
          #show "  that information."
          #show ":: ex: updater king OR updater kingdom"
          #show "- "%ansi(10)"angel:"%ansi(reset)" this will bring up the who angel list and parse"
          #show "  that information."
          #show ":: ex: updater ang OR updater angel"
          #show "- "%ansi(10)"demon:"%ansi(reset)" this will bring up the who demon list and parse"
          #show "  that information."
          #show ":: ex: updater dem OR updater demon"
          #show "- "%ansi(10)"loner:"%ansi(reset)" this will bring up the who loner list and parse"
          #show "  that information."
          #show ":: ex: updater loner"
          #show "- "%ansi(10)"renegade:"%ansi(reset)" this will bring up the who renegade list and"
          #show "parse that information."
          #show ":: ex: updater ren OR updater renegade"
          #show "-----------------------------------------------------------"
        }
        (%2="highlight" || %2="highligh" || %2="highlig" || %2="highli" || %2="highl" || %2="high") {
          #show "-----------------------------------------------------------"
          #show "HIGHLIGHT"
          #show "-----------------------------------------------------------"
          #show "- "%ansi(10)"lvl"%ansi(reset)" or "%ansi(10)"level"%ansi(reset)" - using either one will toggle levels being"
          #show "  shown in the Highlight"
          #show "- "%ansi(10)"rank"%ansi(reset)" - will toggle ranks being shown in the Highlight"
          #show "- "%ansi(10)"flag"%ansi(reset)" - will toggle flags being shown in the Highlight"
          #show "- "%ansi(10)"class"%ansi(reset)" - will toggle classes being shown in the Highlight"
          #show "- "%ansi(10)"high"%ansi(reset)" or "%ansi(10)"highlight"%ansi(reset)" - using either will toggle the colored"
          #show "  highlights."
          #show "- "%ansi(10)"help"%ansi(reset)" - Typing this with one of the following commands"
          #show "  will bring up specific information on that command with"
          #show "  examples."
          #show "-----------------------------------------------------------"
        } 
        {
          #show "-----------------------------------------------------------"
          #show "HELP"
          #show "-----------------------------------------------------------"
          #show "Type highlight help <command> for more information on a specific"
          #show "command. ex: highlight help updater"
          #show "> highlight <param>"
          #show "> updater <param>"
          #show "> update <param> <name>"
          #show "> find <name>"
          #show "-----------------------------------------------------------"
        }
    }
}
{
          #show "-----------------------------------------------------------"
          #show "HELP"
          #show "-----------------------------------------------------------"
          #show "Type highlight help <command> for more information on a specific"
          #show "command. ex: highlight help updater"
          #show "> highlight <param>"
          #show "> updater <param>"
          #show "> edit <param> <name>"
          #show "> find <name>"
          #show "-----------------------------------------------------------"
}

#send %cr]]></value>
</alias>


It now comes up with an error: Argument Expected

to which I don't know how to solve that particular error.

Additionally, remember the last alias I posted?
Code:

<alias name="updater" id="481">
  <value>#T- Gatherer-Off
#T+ Gatherer-Off
$_show = 1
#switch (%1="clan" || %1="cla" || %1="cl" || %1="c") {
    #T+ Gatherer
    #send "whoc"
    }
 (%1="loner" || %1="lone" || %1="lon" || %1="lo" || %1="l") {
    #T+ Gatherer
    #send "who loner"
 }
 (%1="kingdom" || %1="kingdo" || %1="kingd" || %1="king" || %1="kin" || %1="ki" || %1=k") {
    #T+ Gatherer
    #send "whok"
 }
 (%1="angel" || %1="ange" || %1="ang" || %1="an" || %1="a") {
    #T+ Gatherer
    #send "who angel"
 } 
 (%1="demon" || %1="demo" || %1="dem" || %1="de" || %1="d") {
    #T+ Gatherer
    #send "who demon"
 } 
 (%1="giant" || %1="gian" || %1="gia" || %1="gi" || %1="g") {
    #T+ Gatherer
    #send "who giant"
 } 
 (%1="renegade" || %1="renegad" || %1="renega" || %1="reneg" || %1="rene" || %1="ren" || %1="re" || %1="r") {
    #T+ Gatherer
    #send "who renegade"
 }
 (%1"show" || %1="sho" || %1="sh" || %1="s") {
  $_show = 0
  #switch (%-2="level" || %-2="leve" || %-2="lev" || %-2="le" || %-2="l" || %-2="lvl") {
   #IF (@_show_change_lvl)
   {
    _show_change_lvl=0
    #show "Clan Highlighter will no longer display level changes."
   }
   {
    _show_change_lvl=1
    #show "Clan Highlighter will now display level changes."
   }
  }
   (%-2="clan") {
    #IF (@_show_change_clan)
   {
    _show_change_clan=0
    #show "Clan Highlighter will no longer display clan changes."
   }
   {
    _show_change_lvl=1
    #show "Clan Highlighter will now display clan changes."
   }
  }
   (%-2="class" || %-2="clas") {
   #IF (@_show_change_class)
   {
    _show_change_class=0
    #show "Clan Highlighter will no longer display class changes."
   }
   {
    _show_change_class=1
    #show "Clan Highlighter will now display class changes."
   } 
  }
   (%-2="rank" || %-2="ran" || %-2="ra" || %-2="r") {
   #IF (@_show_change_rank)
   {
    _show_change_rank=0
    #show "Clan Highlighter will no longer display rank changes."
   }
   {
    _show_change_rank=1
    #show "Clan Highlighter will now display rank changes."
   } 
  }
   (%-2="new" || %-2="ne" || %-2="n") {
   #IF (@_show_new)
   {
    _show_change_new=0
    #show "Clan Highlighter will no longer display new members."
   }
   {
    _show_change_new=1
    #show "Clan Highlighter will now new members."
   } 
  }
   (%-2="all" || %-2="al" || %-2="a") {
   #IF (@_show_all)
   {
    _show_all=0
    _show_change_lvl=0
    _show_change_class=0
    _show_change_clan=0
    _show_change_rank=0
    _show_new=0
    #show "Clan Highlighter is now set to show no changes or new members."
   }
   {
    _show_all=1
    _show_change_lvl=1
    _show_change_class=1
    _show_change_clan=1
    _show_change_rank=1
    _show_new=1
    #show "Clan Highlighter is now set to show all changes and new members"
   } 
  }
 }
 {
    #T+ Gatherer
    #send "whoc"
 }
 
#IF ($_show)
{
 #T+ Continue-who
 #T+ Stop-who
 #say "Gathering updates..."
 #show "Please do not input commands until the 'Updates Complete' message is shown. Thank you."
}</value>
</alias>


You used to be able to just type: updater
and get the same effect as typing: updater clan

But then I added the additional arguments and that seemed to break it. Well, I took those arguments out and put them with highlight. However, updater remains broken.

updater clan
still works. But typing updater by itself simply does nothing. It never goes into the appropriate switch or anything, nothing happens. It's like I haven't typed anything at all.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Mar 29, 2010 8:30 pm   
 
The error "Argument expected" actually tells you what line is the problem. It is line 158, and you have a #SHOW with no argument. Add a "" or something after the #SHOW.

When doing the highlight command, try adding quotation marks:
Code:
highlight add w "yells( \(w+\)?" '*'


As for the problem with updater, I think the problem is that you have a #switch within a #switch. I think that can cause problems.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Mar 29, 2010 8:40 pm   
 
Unless it's a new bug or a result of a bugfix in 3.16, nested #switch commands are not the problem.
_________________
EDIT: I didn't like my old signature
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Mon Mar 29, 2010 9:42 pm   
 
It turns out I didn't have anything after a #show command, so I got that working. Still haven't looked at updater any further since I'm stumped. But a new problem has creeped up. In this trigger:

Code:

<trigger name="Turn-Highlight-On" priority="3840" regex="true" id="489">
  <pattern>(@_highlight_if)</pattern>
  <value>%match(%1, @_highlight_if, $_pattern)
#show "Pattern: "$_pattern
$_mem_num = %ismember(%1, @_highlight_if)
#IF (%item(@_highlight_if_on, $_mem_num)="ON")
{
 #T+ Highlight-t
 #T+ Turn-Highlight-Off
}</value>
</trigger>


I have these two variables:

Code:

<var name="_highlight_if" type="StringList" id="540">Players near you:|You quest out with your magic in search of others|Looking around you see:|^[\w'-]+ yells</var>
  <var name="_highlight_if_on" type="StringList" id="541">ON|ON|ON|ON</var>


This is the alias:
Code:

<alias name="highlight" parsearg="false" id="496">
  <value><![CDATA[#IF (%params != %null)
{
  #switch (%1="lvl" || %1="level" || %1="leve" || %1="lev" || %1="le" || %1="l") {
      #if (@_s_lvl)
      {
        _s_lvl=0
        #show "Levels will no longer be shown in the Highlighter."
      }
      {
        _s_lvl=1
        #show "Levels will now be shown in the Highlighter."
      }
    }
    (%1="rank" || %1="ran" || %1="ra" || %1=r") {
      #if (@_s_rank)
      {
        _s_rank=0
        #show "Ranks will no longer be shown in the Highlighter."
      }
      {
        _s_rank=1
        #show "Ranks will now be shown in the Highlighter."
      }
    }
    (%1="flag" || %1="fla" || %1="fl" || %1="f") {
      #if (@_s_flag)
      {
        _s_flag=0
        #show "Flags will no longer be shown in the Highlighter."
      }
      {
        _s_flag=1
        #show "Flags will now be shown in the Highlighter."
      }
    } 
    (%1="class" || %1="clas" || %1="cla" || %1 = "cl" || %1="c") {
      #if (@_s_class)
      {
        _s_class=0
        #show "Classes will no longer be shown in the Highlighter."
      }
      {
        _s_class=1
        #show "Classes will now be shown in the Highlighter."
      }
    } 
    (%1="highlight" || %1="highligh" || %1="highlig" || %1="highli" || %1="highl" || %1 = "high") {
      #if (@_s_highlight)
      {
        _s_highlight=0
        #show "Highlighting will no longer be shown in the Highlighter."
      }
      {
        _s_highlight=1
        #show "Highlighting will now be shown in the Highlighter."
      }
    }
    (%1="toggle" || %1="toggl" || %1="togg" || %1="tog" || %1="to" || %1="t") {
     $_phrase = %-2
     $_phrase = %replace($_phrase, "\w", "[\w'-]+")
     $_phrase = %replace($_phrase, "\w+", "[\w '-]+")
     $_phrase = %replace($_phrase, "\d", "\d+")
     $_phrase = %replace($_phrase, "*", ".*")
     #IF (%ismember($_phrase, @_highlight_if))
     {
      $_mem_num = %ismember($_phrase, @_highlight_if)
      #IF (%item(@_highlight_if_on, $_mem_num)="ON")
      {
       #VAR _highlight_if_on %replaceitem("OFF", $_mem_num, @_highlight_if_on)
       #show $_phrase" will no longer be shown in the Highlighter, but will remain on the list."
      }
      {
       #VAR _highlight_if_on %replaceitem("ON", $_mem_num, @_highlight_if_on)
       #show $_phrase" will be shown in the Highlighter."
      }
     }
     {
      #show "Sorry, that phrase is not on the list."
      #show "Perhaps you meant one of the following:"
      $_iter = 1
      $_is_match = 0
      #FORALL @_highlight_if {
       #IF (%match(%item(@_highlight_if, $_iter), $_phrase))
       {
        #ADDI _par_match %item(@_highlight_if, $_iter)
        $_is_match = 1
       }
       $_iter  = $_iter + 1
      }
      $_iter = 1
      #IF (%numitems(@_par_match)>1)
      {
       #FORALL @_par_match {
         $_phrase = %item(@_par_match, $_iter)
         $_phrase = %replace($_phrase, "[\w'-]+", "\w")
         $_phrase = %replace($_phrase, "[\w '-]+", "\w+")
         $_phrase = %replace($_phrase, "\d+", "\d")
         $_phrase = %replace($_phrase, ".*", "*")       
        #show $_phrase
        $_iter = $_iter + 1
       }
      }
      {
       #show %item(@_par_match, 1)
      }
      #FORALL @_par_match {
       #DELNITEM _par_match 1
      }
     }
    }   
    (%1="add" || %1="ad") {
     $_show = 0
     $_phrase = %-2
     $_phrase = %replace($_phrase, "\w", "[\w'-]+")
     $_phrase = %replace($_phrase, "\w+", "[\w '-]+")
     $_phrase = %replace($_phrase, "\d", "\d+")
     $_phrase = %replace($_phrase, "*", ".*")
     #ADDI _highlight_if $_phrase
     #VAR _highlight_if_on %additem("ON", @_highlight_if_on)
     #show $_phrase " added to the highlight list."
    }   
    (%1="delete" || %1="delet" || %1="dele" || %1="del") {
     $_show = 0
     $_phrase = %-2
     $_phrase = %replace($_phrase, "\w", "[\w'-]+")
     $_phrase = %replace($_phrase, "\w+", "[\w '-]+")
     $_phrase = %replace($_phrase, "\d", "\d+")
     $_phrase = %replace($_phrase, "*", ".*")
     #IF (%ismember($_phrase, @_highlight_if))
     {
      $_mem_num = %ismember($_phrase, @_highlight_if)
      #DELNITEM _highlight_if $_mem_num
      #DELNITEM _highlight_if_on $_mem_num
      #show $_phrase " has been deleted from the highlight list."
     }
     {
       #show "Sorry, that phrase is not on the list."
       #show "Perhaps you meant one of the following:"
       $_iter = 1
       $_is_match = 0
       #FORALL @_highlight_if {
        #IF (%match(%item(@_highlight_if, $_iter), $_phrase))
        {
         #ADDI _par_match %item(@_highlight_if, $_iter)
         $_is_match = 1
        }
        $_iter  = $_iter + 1
       }
       $_iter = 1
       #IF (%numitems(@_par_match)>1)
       {
        #FORALL @_par_match {
         $_phrase = %item(@_par_match, $_iter)
         $_phrase = %replace($_phrase, "[\w'-]+", "\w")
         $_phrase = %replace($_phrase, "[\w '-]+", "\w+")
         $_phrase = %replace($_phrase, "\d+", "\d")
         $_phrase = %replace($_phrase, ".*", "*")       
         #show $_phrase
         $_iter = $_iter + 1
        }
       }
       {
        #show %item(@_par_match, 1)
       }
       #FORALL @_par_match {
        #DELNITEM _par_match 1
       }
     }     
    }   
    (%1="help" || %1="hel" || %1="he" || %1="h") {
      #switch (%2="find" || %2="fin" || %2="fi" || %2="f") {
          #show "-----------------------------------------------------------"
          #show "FIND"
          #show "-----------------------------------------------------------"
          #show "Typing this command will bring up all relevant information"
          #show "on a particular character in the following format:"
          #show "[ "%ansi(3)"clan"%ansi(reset)" ][lvl class] name (rank)"
          #show "this command also takes partial matches, and will list all"
          #show "partial matches in the following format:"
          #show "name [ "%ansi(3)"clan"%ansi(reset)" ]"
          #show "Finally, you can use 'all' for your argument instead of a"
          #show "name or part of a name, which will list all of the names"
          #show "currently on record."
          #show %ansi(12)"NOTE"%ansi(reset)": listing ALL of the names will likely be a bit spammy."
          #show "-----------------------------------------------------------"     
        }
        (%2="edit" || %2="edi" || %2="ed" || %2="e") {
          #show "-----------------------------------------------------------"
          #show "EDIT:"
          #show "-----------------------------------------------------------"
          #show "This command allows you to manually edit, add, or delete"
          #show "entries. Even though the automatic updater will add and"
          #show "adjust entries for you, you may wish to change information"
          #show "before it does, or correct information which it parses"
          #show "incorrectly. The automatic updater cannot delete entries,"
          #show "so the delete option is your only way to remove them."
          #show "edit takes the following arguments:"
          #show %ansi(12)"NOTE"%ansi(reset)": "%ansi(15)"Shalonesti Kingdom"%ansi(reset)" must be manually entered as"
          #show "the following: "%ansi(15)"Shalonesti-k"%ansi(reset)
          #show "- "%ansi(10)"clan:"%ansi(reset)" This will allow you to manually adjust the clan or"
          #show "  or kingdom of any current entry. It will do this whether"
          #show "  or not they have one to change."
          #show ":: ex: edit clan Yasan Shalonesti"
          #show "- "%ansi(10)"rank:"%ansi(reset)" This will allow you to manually adjust the rank of"
          #show "  any character currently in the list. It will do this"
          #show "  whether or not they have one to change."
          #show ":: ex: edit rank Yasan Sha'falas"
          #show "- "%ansi(10)"level:"%ansi(reset)" This will allow you to manually adjust the level"
          #show "  of any character currently in the lists. It will do this"
          #show "  whether or not they have one to change."
          #show ":: ex: edit lvl Yasan 51 OR update level Yasan 51"
          #show "- "%ansi(10)"class:"%ansi(reset)" this will allow you to manually adjust the class"
          #show "  of any character currently in the lists. It will do this"
          #show "  whether or not they have one to change."
          #show ":: ex: edit class Yasan Bladesinger"
          #show "- "%ansi(10)"delete:"%ansi(reset)" This will allow you to manually delete any"
          #show "  any character in the lists and all associated records."
          #show "  you must enter the command twice in order for it to perform"
          #show "  and three times for delete all."
          #show ":: ex: edit del Yasan OR update delete Yasan"
          #show %ansi(12)"NOTE"%ansi(reset)": typing "%ansi(12)"delete all"%ansi(reset)" will delete all of the records in the"
          #show "list."
          #show "- "%ansi(10)"add:"%ansi(reset)" This will manually add any character to the lists that"
          #show "is not currently in the lists. It has a specific entry format"
          #show "which must be followed."
          #show "The format is: edit add <name> <level> <class> <clan> <rank>"
          #show ":: ex: edit add Yasan 51 Bladesinger Shalonesti Sha'falas"
          #show "-----------------------------------------------------------"
        }
        (%2=updater || %2="update" || %2="updat" || %2="upda" || %2="upd" || %2="up" || %2="u") {
          #show "-----------------------------------------------------------"
          #show "UPDATER:"
          #show "-----------------------------------------------------------"
          #show "The updater command is one that can be used with or without"
          #show "arguments. Without arguments, it will run a parse on the whoc"
          #show "list and gather updates on clanners."
          #show "updater also takes the following arguments:"
          #show "- "%ansi(10)"clan:"%ansi(reset)" this is the default option. Typing it will still"
          #show "  only bring up and parse the whoc list."
          #show ":: ex: updater clan"
          #show "- "%ansi(10)"kingdom:"%ansi(reset)" this will run the whok list and parse"
          #show "  that information."
          #show ":: ex: updater king OR updater kingdom"
          #show "- "%ansi(10)"angel:"%ansi(reset)" this will bring up the who angel list and parse"
          #show "  that information."
          #show ":: ex: updater ang OR updater angel"
          #show "- "%ansi(10)"demon:"%ansi(reset)" this will bring up the who demon list and parse"
          #show "  that information."
          #show ":: ex: updater dem OR updater demon"
          #show "- "%ansi(10)"loner:"%ansi(reset)" this will bring up the who loner list and parse"
          #show "  that information."
          #show ":: ex: updater loner"
          #show "- "%ansi(10)"renegade:"%ansi(reset)" this will bring up the who renegade list and"
          #show "parse that information."
          #show ":: ex: updater ren OR updater renegade"
          #show "-----------------------------------------------------------"
        }
        (%2="highlight" || %2="highligh" || %2="highlig" || %2="highli" || %2="highl" || %2="high") {
          #show "-----------------------------------------------------------"
          #show "HIGHLIGHT"
          #show "-----------------------------------------------------------"
          #show "- "%ansi(10)"lvl"%ansi(reset)" or "%ansi(10)"level"%ansi(reset)" - using either one will toggle levels being"
          #show "  shown in the Highlight"
          #show "- "%ansi(10)"rank"%ansi(reset)" - will toggle ranks being shown in the Highlight"
          #show "- "%ansi(10)"flag"%ansi(reset)" - will toggle flags being shown in the Highlight"
          #show "- "%ansi(10)"class"%ansi(reset)" - will toggle classes being shown in the Highlight"
          #show "- "%ansi(10)"high"%ansi(reset)" or "%ansi(10)"highlight"%ansi(reset)" - using either will toggle the colored"
          #show "  highlights."
          #show "- "%ansi(10)"help"%ansi(reset)" - Typing this with one of the following commands"
          #show "  will bring up specific information on that command with"
          #show "  examples."
          #show "-----------------------------------------------------------"
        } 
        {
          #show "-----------------------------------------------------------"
          #show "HELP"
          #show "-----------------------------------------------------------"
          #show "Type highlight help <command> for more information on a specific"
          #show "command. ex: highlight help updater"
          #show "> highlight <param>"
          #show "> updater <param>"
          #show "> update <param> <name>"
          #show "> find <name>"
          #show "-----------------------------------------------------------"
        }
    }
}
{
          #show "-----------------------------------------------------------"
          #show "HELP"
          #show "-----------------------------------------------------------"
          #show "Type highlight help <command> for more information on a specific"
          #show "command. ex: highlight help updater"
          #show "> highlight <param>"
          #show "> updater <param>"
          #show "> edit <param> <name>"
          #show "> find <name>"
          #show "-----------------------------------------------------------"
}

#send %cr]]></value>
</alias>


As you can see, the intent is to allow a simple form of regex. I think I have it working. Unfortunately the trigger has no way of knowing whether it is on or off because when the regex is matched, %1 isn't the regex, it's the pattern that matched the regex, making it difficult for me to find a way to reference the "ON" in the stringlist associated with the pattern stringlist as I use %ismember() to get the number and pair them up.

Does anyone know of a possible alternative?
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Tue Mar 30, 2010 7:40 am   
 
Got the "regex" to work, now the only issue is updater not firing when there's no argument:

Code:

<alias name="updater" id="481">
    <value>#T- Gatherer-Off
#T+ Gatherer-Off
$_show = 1
#switch (%1="clan" || %1="cla" || %1="cl" || %1="c") {
    #T+ Gatherer
    #send "whoc"
    }
 (%1="loner" || %1="lone" || %1="lon" || %1="lo" || %1="l") {
    #T+ Gatherer
    #send "who loner"
 }
 (%1="kingdom" || %1="kingdo" || %1="kingd" || %1="king" || %1="kin" || %1="ki" || %1=k") {
    #T+ Gatherer
    #send "whok"
 }
 (%1="angel" || %1="ange" || %1="ang" || %1="an" || %1="a") {
    #T+ Gatherer
    #send "who angel"
 } 
 (%1="demon" || %1="demo" || %1="dem" || %1="de" || %1="d") {
    #T+ Gatherer
    #send "who demon"
 } 
 (%1="giant" || %1="gian" || %1="gia" || %1="gi" || %1="g") {
    #T+ Gatherer
    #send "who giant"
 } 
 (%1="renegade" || %1="renegad" || %1="renega" || %1="reneg" || %1="rene" || %1="ren" || %1="re" || %1="r") {
    #T+ Gatherer
    #send "who renegade"
 }
 (%1"show" || %1="sho" || %1="sh" || %1="s") {
  $_show = 0
  #switch (%-2="level" || %-2="leve" || %-2="lev" || %-2="le" || %-2="l" || %-2="lvl") {
   #IF (@_show_change_lvl)
   {
    _show_change_lvl=0
    #show "Clan Highlighter will no longer display level changes."
   }
   {
    _show_change_lvl=1
    #show "Clan Highlighter will now display level changes."
   }
  }
   (%-2="clan") {
    #IF (@_show_change_clan)
   {
    _show_change_clan=0
    #show "Clan Highlighter will no longer display clan changes."
   }
   {
    _show_change_lvl=1
    #show "Clan Highlighter will now display clan changes."
   }
  }
   (%-2="class" || %-2="clas") {
   #IF (@_show_change_class)
   {
    _show_change_class=0
    #show "Clan Highlighter will no longer display class changes."
   }
   {
    _show_change_class=1
    #show "Clan Highlighter will now display class changes."
   } 
  }
   (%-2="rank" || %-2="ran" || %-2="ra" || %-2="r") {
   #IF (@_show_change_rank)
   {
    _show_change_rank=0
    #show "Clan Highlighter will no longer display rank changes."
   }
   {
    _show_change_rank=1
    #show "Clan Highlighter will now display rank changes."
   } 
  }
   (%-2="new" || %-2="ne" || %-2="n") {
   #IF (@_show_new)
   {
    _show_change_new=0
    #show "Clan Highlighter will no longer display new members."
   }
   {
    _show_change_new=1
    #show "Clan Highlighter will now new members."
   } 
  }
   (%-2="all" || %-2="al" || %-2="a") {
   #IF (@_show_all)
   {
    _show_all=0
    _show_change_lvl=0
    _show_change_class=0
    _show_change_clan=0
    _show_change_rank=0
    _show_new=0
    #show "Clan Highlighter is now set to show no changes or new members."
   }
   {
    _show_all=1
    _show_change_lvl=1
    _show_change_class=1
    _show_change_clan=1
    _show_change_rank=1
    _show_new=1
    #show "Clan Highlighter is now set to show all changes and new members"
   } 
  }
 }
 {
    #T+ Gatherer
    #send "whoc"
 }
 
#IF ($_show)
{
 #T+ Continue-who
 #T+ Stop-who
 #say "Gathering updates..."
 #show "Please do not input commands until the 'Updates Complete' message is shown. Thank you."
}</value>
  </alias>
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Mar 30, 2010 2:07 pm   
 
The line:
Code:
 (%1"show" || %1="sho" || %1="sh" || %1="s") {

should be:
Code:
 (%1="show" || %1="sho" || %1="sh" || %1="s") {

Very curious. I'm not at all sure why that mistake would cause that result, but it does.

[edit] Oh, of course. I see why that error gives that result. %1"show" is always TRUE, so the code ends up in this section rather than falling through to the default ELSE.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Tue Mar 30, 2010 3:59 pm   
 
Struggling to see the difference between the two lines...

Edit: Ah ha! Found it. Now you can see why I missed it in the first place. My mind literally put an = in front of the original, so I saw one when it wasn't there...


Thanks
_________________
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