Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ Trigger to disable another trigger

Trigger to disable another trigger

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1 2  

Posted by Olaf   (2 posts)  Bio
Date Tue 20 Mar 2001 06:51 AM (UTC)
Message
Hi, I was wondering about one thing in the mushclient.

Is it possible to make a trigger disable another trigger?

I have battle triggers set. But as soon as I see
"You killed *" I want to disable about 4-6 triggers.

I also would like to enable them within my attack alias.


Thanks
Olaf
Top

Posted by Olaf   (2 posts)  Bio
Date Reply #1 on Tue 20 Mar 2001 06:52 AM (UTC)
Message
One other thing. Is it possible to call an alias from a trigger?


Olaf.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #2 on Tue 20 Mar 2001 01:18 PM (UTC)
Message
Disabling triggers from a trigger

Yes, you can disable triggers from within a trigger.

The trigger which does the disabling must have a label (any text would do, such as "disable_trigger").

Then you must enter the name of a script subroutine, which you put into the script file (and turn scripting on). It doesn't matter which script language you use, but I'll choose VBscript as an example. I'll assume that we call the trigger script "OnDisableTriggers" (ie. this is the name that you put in the "script" field for the trigger.

You also need to give a label to each of the triggers that need to be disabled/enabled so we can refer to them by name. I'll assume you call them "trigger1" through to "trigger6" although you would probably want to give them better names.



sub OnDisableTriggers (strTriggerName, trig_line, arrWildCards)
  World.EnableTrigger "trigger1", FALSE
  World.EnableTrigger "trigger2", FALSE
  World.EnableTrigger "trigger3", FALSE
  World.EnableTrigger "trigger4", FALSE
  World.EnableTrigger "trigger5", FALSE
  World.EnableTrigger "trigger6", FALSE
end sub



Enabling triggers from an alias

Next, to enable them again you need to add a script to your attack alias. This just enables the triggers you disabled in the trigger.



sub OnEnableTriggers (strAliasName, theoutput, ArrWildcards)
  World.EnableTrigger "trigger1", TRUE 
  World.EnableTrigger "trigger2", TRUE 
  World.EnableTrigger "trigger3", TRUE 
  World.EnableTrigger "trigger4", TRUE 
  World.EnableTrigger "trigger5", TRUE 
  World.EnableTrigger "trigger6", TRUE 
end sub




Call an alias from a trigger

No, you can't call an alias from a trigger. Why would you want to do this? An alias is supposed to simplify typing things, a trigger to react to something from the MUD.

What you could do is have both the trigger and the alias call the same script, thus they could end up doing the same thing.




- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Dubthach   (47 posts)  Bio
Date Reply #3 on Thu 22 Mar 2001 12:55 PM (UTC)
Message
There are many instances where it is nice to call an alias from a trigger. Suppose, for an example, that I have a spellup alias that checks which spells I need and resets the ones that are not on. I might want this to run every time a battle ends, which would necessitate a trigger. But, I would also want to be able to explicitly call the spellup routine whenever I want, which would necessitate an alias. The easiest way to get both of these actions is to have an alias that can be called explicitly or through the trigger.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #4 on Thu 22 Mar 2001 01:43 PM (UTC)
Message
I think you mean a function rather than an alias.

eg.

Quote:

I have a spellup alias that checks which spells I need and resets the ones that are not on


To do this you need a function (script subroutine) rather than just an alias.

Then you simply call that function from both the alias and the trigger.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by David   USA  (49 posts)  Bio
Date Reply #5 on Fri 13 Apr 2001 11:30 AM (UTC)
Message
Basically I am still having the same problem, I don't want to disable
triggers, I want to enable a timer via script subroutine that is set off by
a trigger


For instance i see this
* Mol retracts his right arm...

I have a trigger setup to see this:
* * retracts his right arm...

I also have it copy the second wildcard to the clipboard for other uses...

I have my trigger name as RightPunch

I have it run the SubRoutine:
OnBeingAttackedHigh

My code looks somewhat like this:
sub OnbeingAttackedHigh
world.ResetTimers
World.EnableTimer "ParryHigh", TRUE
end sub



The timer being 2 seconds and sending to the world parry high.

I also have a trigger setup that if I am successful or unsuccessful in my
parry, It also does this:

sub OnBlocking
world.ResetTimers
World.EnableTimer "ParryHigh", FALSE
end sub

My code(with a LOT of Nicks help) to fame:

sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #6 on Fri 13 Apr 2001 09:27 PM (UTC)

Amended on Fri 13 Apr 2001 09:28 PM (UTC) by Nick Gammon

Message
You haven't mentioned what the problem is here, but I can see that these trigger scripts won't work as written, simply because triggers require three arguments. If you don't supply them, you will get a message like "cannot invoke script subroutine 'OnbeingAttackedHigh'".

Like in the earlier examples in this thread, you must word your triggers like this:




sub OnbeingAttackedHigh (TriggerName, TriggerLine, WildCards)
world.ResetTimers 
World.EnableTimer "ParryHigh", TRUE 
end sub 



Does this solve the problem, or is there another one?




- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by David   USA  (49 posts)  Bio
Date Reply #7 on Sat 14 Apr 2001 03:44 AM (UTC)
Message
Ok, It requires 3 things, I got the trigger name, what do you mean by triggerline, and wildcards.

Also, I have only read help files. And you are correct, Cannot invoke subroutine OnBeingAttackedHigh while processing the trigger PunchRight.

Where would I find the information for the triggerline. Is it a number? What do I put there? As for the wildcards There are 2, one of whilch is literally an * the other is name.

What I am basically getting at is, what do I put in as the triggerline, or is that what I have to put there?

I am terribly confused :|

My code(with a LOT of Nicks help) to fame:

sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
Top

Posted by David   USA  (49 posts)  Bio
Date Reply #8 on Sat 14 Apr 2001 04:05 AM (UTC)
Message
Ok stupid is as stupid does. Ok I tried what you said, it worked almost perfectly...

Note, almost, Instead of waiting the 2 seconds that my timer is on to run the parry it sent it to the world immeaditly. how would i fix this?

My code(with a LOT of Nicks help) to fame:

sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #9 on Sat 14 Apr 2001 04:40 AM (UTC)
Message
You don't put things in those three arguments, they are given to you by the trigger.

TriggerName - the name of this trigger - this is so multiple triggers can share the same script, and inside the script work out which one called it.

TriggerLine - the line from the MUD that caused the trigger to fire - this is just the entire matching paragraph.

Wildcards - this is an array of 10 strings, matching the first 10 wildcards in the trigger string.

Quote:

Note, almost, Instead of waiting the 2 seconds that my timer is on to run the parry it sent it to the world immediatly. how would I fix this?


You only enabled the timer - it was running but was "dormant". It might have been near the end of its 2 seconds. You need to "reset" the timer to cause it to start counting again, eg.


world.ResetTimer "mytimer"


... although I would have thought that your "resettimers" would have worked.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by David   USA  (49 posts)  Bio
Date Reply #10 on Sat 14 Apr 2001 06:40 AM (UTC)
Message
I would have thought that resetting the timers would also do the same thing. However it didn't work. Also, I tried resetting the particualr timer such as you suggested

world.resettimer "TimerName"


Same effect. It still did not wait the proper time limit, I tried with several different timing settings. 2 seconds like it should be. 3, 5, and 7 seconds. The same this Kept occutring.

BTW, I really appreciate your help on this Nick.

My code(with a LOT of Nicks help) to fame:

sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
Top

Posted by David   USA  (49 posts)  Bio
Date Reply #11 on Sat 14 Apr 2001 06:50 AM (UTC)
Message
I really should think before I post things.

I get it world.resettimer "mytimer" isn't the timer name, its the actual world timer which keeps it from continuly running in the background...

Next question is can I set a timered timer?

If after 2 seconds I don't get the responce i am looking for can I have a timer shutdown the timer than was triggered? but without that secondary timer being on at all times? Thats like a trigget to run 2 timers at once one for 2 seconds one for 3 seconds?


My code(with a LOT of Nicks help) to fame:

sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
Top

Posted by David   USA  (49 posts)  Bio
Date Reply #12 on Sat 14 Apr 2001 06:52 AM (UTC)
Message
Sorry but I have only read help files on this stuff i have no formal training... I tried the 'mytimer' thing... Still same affect it still goes through right away


I know this can be done, there is one thing that I am over looking.

My code(with a LOT of Nicks help) to fame:

sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #13 on Sat 14 Apr 2001 09:16 PM (UTC)
Message
You were right the first time -


world.resettimer "timername"


does reset the timer of that name. Make sure the name you give is the label of the timer in question.

The order might be important, I would enable it first and then reset it, in case it doesn't reset disabled timers.

You could have two timers, but I'm not exactly sure why you want to. You can make a "one shot" timer that fires once and then deletes itself.

But if you want to, a trigger can do two "AddTimer" commands, one that adds a 2-second timer and one that adds a 3-second timer. In fact, this approach is more likely to work than simply enabling an existing timer.

The 3-second timer can do a "deletetimer" to get rid of the 2-second timer. However as I said, if the 2-second timer is made as a one-shot timer there is no point, it will have gone once the 2 seconds have elapsed.

Search for "addtimer" in the forum, there are a couple of example scripts for adding timers. (To search, see the link at the bottom of any forum page).



- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by David   USA  (49 posts)  Bio
Date Reply #14 on Sun 15 Apr 2001 03:31 AM (UTC)
Message
A couple of things.

Yes, It was all in the order of what I scripted, I switched them around. and it worked perfectly(minus what you will read about below)

I like the oneshot timer idea. I think that will work better.

But, Right now I am having a problem. I need the timer to go off at 1.5 seconds. 1 second is too short. 2 seconds is too long. Is it possible to make a timer that goes off at 1 and 1 half seconds? All I have seen is speedwalkdelay which is customizable, is there a way to add script to make it wait a half second before activating the timer?


My code(with a LOT of Nicks help) to fame:

sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


53,739 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.