Triggering a trigger? How to make an alias that can turn a trigger off and on.

Posted by Jeremymia on Sat 11 Feb 2006 03:09 AM — 4 posts, 17,118 views.

#0
I'd like the following trigger:
Trigger:You remove * gold from a sailor's kitbag.
Response: put %1 gold in pack

However, this is very bad for when i'm shopping. Instead of disabling in manually, is there a way for me to type something like "Shopping", or, if necessary "Shopping on" and "shopping off" to avoid this?
Australia Forum Administrator #1
Name your trigger "shopping" (put that word in the "label" field). Then this alias will do it, if you have Lua as the script language.


<aliases>
  <alias
   match="shopping"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>
if GetTriggerInfo ("shopping", 8) then
  EnableTrigger ("shopping", false)
  ColourNote ("black", "yellow", "Shopping trigger turned off")
else
  EnableTrigger ("shopping", true)
  ColourNote ("white", "blue", "Shopping trigger turned on")
end -- if
</send>
  </alias>
</aliases>



Basically it sees if the trigger is enabled, and if so, turns it off (disables) it, otherwise it enables it. Type "shopping" to make the alias do its stuff.
#2
Thank you, but I still don't know how to do this.

For one, I've never used the script thing of mushclient before, so i'm not sure how to do it - I imagine the copy the code into notepad and save it as whatever.lua, though. Then you go to script, select lua, and select the script there. However, this doesn't work. (Some error about a >)

Second, what room does this leave me to declare the parameters of the trigger I want? Namely, the one where "You remove * gold from a sailor's kitbag" should result in "put %1 gold in kitbag." If I name the trigger shopping, I clearly can't name it "You remove * gold from a sailor's kitbag."

I have read the scripting overview. Sorry...
Australia Forum Administrator #3
Quote:

I imagine the copy the code into notepad and save it as whatever.lua, though


It is easier than that. See this post:

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=4777

Just make sure you have Lua as the script language, and enabled. You don't need a script file in this case.

Quote:

Second, what room does this leave me to declare the parameters of the trigger I want?


This is an alias that turns the trigger on and off. You still have the trigger, like you described, and put "shopping" in the Label field.