Trouble with SetTriggerOption

Posted by Whininguser on Wed 03 Nov 2010 03:30 PM — 7 posts, 26,911 views.

Canada #0
Suppose...


function name()

  AddTrigger("monster", "match text", "", trigger_flag.Enabled, custom_colour.Custom15, 0, "", "")

  SetTriggerOption ("monster", "ignore_case", "y")

end


After the function was called, the ignore_case box remained unchecked, so I went on to play around and here's the result:

SetTriggerOption ("monster", "ignore_case", "y") (failed)
SetTriggerOption ("monster", "ignore_case", "Y") (failed)
SetTriggerOption ("monster", "ignore_case", "1") (failed)

I had the same problem in almost every other case involving the y/n argument (didn't test them all), but the function worked fine in cases without the y/n argument. For example:

SetTriggerOption ("monster", "group", "name") (worked)


What did I do wrong? Thanks :)

Environment:
Mushclient 4.33
Lua 5.1
Windows XP SP3

Amended on Wed 03 Nov 2010 03:38 PM by Whininguser
USA #1
If I run that code and put check() around the SetTriggerOption function (to check the return code), I get:
Run-time error
World: Lusternia
Immediate execution
Plugin is not allowed to set this option
stack traceback:
        [C]: in function 'error'
        [string "Check function"]:1: in function <[string "Check function"]:1>
        (tail call): ?
        [string "Alias: lua_eval"]:1: in main chunk

Which is utter nonsense, as it wasn't executed from a plugin. That error code (30032) isn't even in the list of returns from SetTriggerOption. Sounds fishy.
Australia Forum Administrator #2
Whininguser said:

What did I do wrong? Thanks :)

Environment:
Mushclient 4.33


You used an old version of MUSHclient. Don't do that. ;)

http://www.gammon.com.au/scripts/showrelnote.php?version=4.53&productid=0

See point 6 in the release notes.

For older versions you have to use 1 or 0, not "y" or "n".
Australia Forum Administrator #3
Ah, and also you can't set a couple of options, that being one of them.

Both "ignore_case" and "regexp" are marked as non-writable. Probably because they would cause the regular expression to need to be recompiled.

And the return code 30032 is shared for both "plugin cannot write" and "cannot write". I'll update the documentation.

In your case, why not just add the trigger with the options set in the first place?
Canada #4
Thanks for the clarification, guys :)


Nick Gammon said:

In your case, why not just add the trigger with the options set in the first place?


It's because I don't know how :D

So how can I do it? Suppose below is my trigger, and I want regexp and ignore_case enabled once it's added.

AddTriggerEx ("name", ".* attacks", "You are under attack!", trigger_flag.Enabled, custom_colour.Custom15, 0, "", "", 2, 50)


USA #5
Whininguser said:
AddTriggerEx ("name", ".* attacks", "You are under attack!", trigger_flag.Enabled + trigger_flag.IgnoreCase + trigger_flag.RegularExpression, custom_colour.Custom15, 0, "", "", 2, 50)

Added in bold. :)
Canada #6
Twisol said:

Added in bold. :)


Thanks! :)