SetTriggerOption(t, "name", tt) does not work

Posted by WillFa on Thu 15 Jun 2017 03:43 PM — 5 posts, 23,544 views.

USA #0
no error, no effect, appears to work but actually does nothing.

p.s. you have the most annoying password strength policy I have ever encountered. And I've worked in infosec. Please read xkcd comic #936. I can't use a 28 character sentence because the space character appears too many times????
Australia Forum Administrator #1
What do the variables "t" and "tt" have in them?
USA #2
Valid names of triggers. Doesn't matter if you CTRL+SHIFT+8 and pick a trigger and copy n paste it's label, If you're in a for k,v in iPairs(GetTriggerList()), if you're getting the trigger name from a function filter(s) in the Filter By dialog box...


How I discovered this is a little funny and a little embarrassing. On the mud I play is the Necromancers guild ("Necros" as everyone in the world would be wont to shorten it), and I was commenting that while I love our mutual friend, I hate partying with him because the guild is spammy as hell with epileptic seizure inducing ansi changes. Friend C said he agrees and that's why he has the entire guild's spam gagged. I said "Ooooh, gimme them triggers!" and so he sent me the file with his TinTin++ #gags... Some quick search 'n' replace in my favorite text editor and I changed all the #gag {matchtext}; into AddTrigger("NecroGag01", "matchtext", "", 7, -1, 0, "", ""), incrementing the name as appropriate.

You might notice that flags are only 7 (enabled, omit, omitlog)... and I forgot the RegEx flag. And I wanted to throw all of them into a group for quick n easy plugin wizard export... And UH OH, that's a really unfortunate typo for a white guy in America to make... yeaaaa... "NecroGag01" doesn't have a "c" in it, it has an erroneous "g". I should REALLY change that. And that's when I found out the following code doesn't work, and while debugging it, none of the "name" changes work even from the command prompt with a Send to Script character preceding it.


function filter (s)
--print (s, type(s), s:find("negrogag"))
if s:find("negrogag") then
  SetTriggerOption(s, "group", "NecroGags")
  local tempname = s:gsub("egro", "ecro")
  SetTriggerOption(s, "name", tempname)
  return true

elseif s:find("necrogag") then
  return true
else
  return false

end

end -- filter


Modifying the group works, adding the RegEx flags worked (in previous iterations of the code); so I am grabbing the correct trigger name and modifying them correctly. The "name" case in SetTriggerOption does not function.

And I did try just a single line SetTriggerOption line from the command window just in case this was a time when modifying a list during traversal has undefined results.
Amended on Fri 16 Jun 2017 08:58 AM by WillFa
Australia Forum Administrator #3
You can't change the name of a trigger/timer/alias using SetXXXoption. The documentation is incorrect in this respect.

The name is its "key" and not part of the data. I suggest you do something like ExportXML to get the trigger data, and then ImportXML using a different name. See, for example:

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

Example code:


require "addxml"  -- get extension script

-- get trigger "foo"
t = addxml.save ("trigger", "foo")

-- change its name
t.name = "bar"

-- put it back
addxml.trigger (t)

-- get rid of old one
DeleteTrigger ("foo")
USA #4
Thanks, Nick.

I actually just opened the MCL in Sublime Text and did a search and replace in there.

Just wanted to let you know of the issue (apparently in the docs, not code).