Trigger based on whether or not a trigger is active

Posted by ErockMahan on Wed 14 Feb 2007 07:50 PM — 4 posts, 20,228 views.

#0
To explain what I'm doing:

I want to set up a trigger that will go something like this:

(I send "attack beast")
Trigger activates - GetInfoAboutTrigger "punch" -
Is "punch" active?
If yes, send "punch"
If no, send ""
Is "kick" active?
If yes, send "kick"
If no, send ""


I know there is a real command that is the equivalent to "GetInfoAboutTrigger" (which I just made up, for those of you who don't know), but I haven't been able to figure it out at all.
USA #1
http://www.gammon.com.au/scripts/function.php

The above link is a list of all the scripting functions of MUSHclient. It's an invaluable resource. As to how to use this, the next example is in Lua, but pick whatever language you are most comfortable with. Just put it in the send field, and make sure the "send to" selector is set to script. I personally would get rid of the send( "" ) parts.



if GetTriggerInfo( "punch", "enabled" ) == 1 then
  send( "punch" )
else
  send( "" )
end -- check for punch
if GetTriggerInfo( "kick", "enabled" ) == 1 then
  send( "kick" )
else
  send( "" )
end -- check for kick
Amended on Thu 15 Feb 2007 10:38 AM by Shaun Biggs
Australia Forum Administrator #2
Check out:

http://www.gammon.com.au/scripts/function.php?name=GetTriggerInfo


It is actually:


if GetTriggerInfo ( "punch", 8 ) then


The 2nd argument to GetTriggerInfo is a number.

You might have been thinking of GetTriggerOption, see:

http://www.gammon.com.au/scripts/function.php?name=GetTriggerOption
#3
Yup, you got what I was after:

if GetTriggerInfo ("punch1", 8) = 1 then
send ("punch")
else
send ("")
end if

I may remove the 'else' part of that, but it works fine otherwise!