Please provide the trigger pattern when no label is available from an error

Posted by Kahenraz on Mon 22 Apr 2019 07:10 AM — 4 posts, 17,160 views.

#0
I have an error that occurs periodically:

Immediate execution
[string "Trigger: "]:4: unexpected symbol near '0'


I'm not sure where it is. Can triggers which have no label report their pattern on an error?
Australia Forum Administrator #1
Triggers which have a failing script now report the internal trigger name instead of a blank name (if the "real" name is blank).

This is implemented in version 5.07 (pre-release) which you can download following the instructions here:

http://www.gammon.com.au/forum/?id=13903


You can find which one this is by going to the triggers configuration dialog box (the one with a list of triggers in it) and pasting this into the "filter" box:


function filter (name, trigger)
  return name == "*trigger269"
end -- filter


You would, of course, change the trigger number as required.

This box is next to "Filter by:" in the dialog box. Then check "Filter by" and the matching trigger will be the only one in the list.




If the trigger is in a plugin you can run this script in the Immediate window (Ctrl+I) to find it:


WANTED_TRIGGER = "*trigger269"

local plugins = GetPluginList() or {}
table.insert (plugins, "") -- add main world to plugins list

for _, pluginID in pairs (plugins) do

  local tl = GetPluginTriggerList (pluginID) or {}
  local pluginName = "main world file"
  if pluginID ~= "" then
     pluginName = GetPluginInfo (pluginID, 1)
  end -- of not main world file

  for id, name in ipairs (tl) do 
     if name == WANTED_TRIGGER then
       local matchText = GetPluginTriggerInfo (pluginID, name, 1)
       ColourNote ("orange", "", string.format ("Trigger '%s' in %s found! Match text: ", name, pluginName))
       ColourNote ("darkgray",  "", "  " .. matchText)
     end -- if
  end  -- for
  
end -- of each plugin


Change the first line above to match the reported trigger with the error and it should display what plugin it is in, and what the match text is.




An alternative approach is to run this script in the Immediate window (or make an alias out of it if you want, sending it all to "script"):


local plugins = GetPluginList() or {}
table.insert (plugins, "") -- add main world to plugins list

for _, pluginID in pairs (plugins) do 

  local tl = GetPluginTriggerList (pluginID) or {}
  local pluginName = "main world file"
  if pluginID ~= "" then
     pluginName = GetPluginInfo (pluginID, 1)
  end -- of not main world file

  for id, name in ipairs (tl) do 
     if GetPluginTriggerInfo (pluginID, name, 21) > 0 and  -- matched?
         GetPluginTriggerInfo (pluginID, name, 15) == sendto.script and  -- send to script? 
         not GetPluginTriggerInfo (pluginID, name, 34) then  -- failed script?
       local matchText = GetPluginTriggerInfo (pluginID, name, 1)
       ColourNote ("orange", "", string.format ("Trigger '%s' in %s has a failed script! Match text: ", name, pluginName))
       ColourNote ("darkgray",  "", "  " .. matchText)
     end -- if
  end  -- for
  
end -- of each plugin


That reports every trigger that has matched, is sending to script, and has a failed script.

If you use this (last) script then you don't need to install the new pre-release of MUSHclient because it doesn't require you to know the trigger name.
#2
Thank you. This helped me to track down the offending trigger.

I also noticed that when I check the box for "Filter by:" I get the following error dialog:

---------------------------
MUSHclient
---------------------------
Cannot find the function 'filter' - item 'filter' is nil
---------------------------
OK   
---------------------------



This does not affect the filter operation and only seems to be an issue when the filter is empty.
Australia Forum Administrator #3
That's right. When you click the "Filter by" box you are promising to provide a filter function in the filter box. This function makes the decision (which can be quite complex) as to whether a particular trigger should be displayed or not. If there is no such function you would get that error message.