[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  VBscript
. . -> [Subject]  Dumb Question About Triggers

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Dumb Question About Triggers

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Gaweinrod   (5 posts)  [Biography] bio
Date Sat 11 May 2002 03:40 PM (UTC)  quote  ]

Amended on Sat 11 May 2002 03:43 PM (UTC) by Gaweinrod

Message
Yet another dumb question from me! I'm slightly confused with this trigger thing. I want to make a trigger that will say 'Yes' when the word 'Hello' is said in the world. Is it possible to create a trigger from a trigger?
[Go to top] top

Posted by Nick Gammon   Australia  (18,800 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Sun 12 May 2002 02:34 AM (UTC)  quote  ]
Message
Not quite sure what you are trying to do here. A trigger reacts to something *from* the world.

So, you could make a trigger that looks for:


Match: Hello
Send: yes
Regular expression: checked


If you want to react to something *you* type, then you want an alias.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Gaweinrod   (5 posts)  [Biography] bio
Date Reply #2 on Sun 12 May 2002 01:21 PM (UTC)  quote  ]
Message
Yea, that's what I meant... I tend to be very confusing though. I tried to play around with the trigger but it doesn't seem to work. I want to do that... what are some of the specific settings that I'll need to select. And can I create a trigger from a trigger?
[Go to top] top

Posted by Nick Gammon   Australia  (18,800 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Sun 12 May 2002 09:46 PM (UTC)  quote  ]
Message
Press the help button (F1) when you are looking at the trigger edit screen.

Basically, don't change a setting unless you feel a need to (ie. you understand why you want to change it).

Most triggers only need the "enabled" box set, but if you are using regular expressions - and you usually realise it when you are - you check the "regular expression" box.

I don't understand what you mean by "a trigger from a trigger" - can you give an example?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Gaweinrod   (5 posts)  [Biography] bio
Date Reply #4 on Sun 12 May 2002 09:53 PM (UTC)  quote  ]
Message
Say the trigger is activated and it sends to the world 'Hello.' This would be a one time trigger. That trigger would then create another trigger that would send to the world 'Hello again' when it's case evaluated to true or whatever.
[Go to top] top

Posted by Nick Gammon   Australia  (18,800 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Mon 13 May 2002 08:33 AM (UTC)  quote  ]
Message
I would just have the one trigger, that tests a counter or flag of some sort. When the counter is 1 it might say one thing, but when it was 2, do something else, and so on.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Gaweinrod   (5 posts)  [Biography] bio
Date Reply #6 on Mon 13 May 2002 08:17 PM (UTC)  quote  ]
Message
Allright, more dumb questions. I believe that Google sent me to this forum to entertain everybody with my idiocity. Oh well... I'm really having trouble with the triggers - I must be doing something wrong. In the Trigger: field I typed Hello, which is what I want it to match on. I didn't tough the Match: or on or any of the checkboxes next to that. In send, I wrote say hi. I checked the enabled, and ignore case, and labeled it 'triggerthatdoesnotwork' should this be working? I've also got an interesting project... I need something that will count the number of 'ship's rats' in the room. Here are a few examples... BTW I did read the help file, I'm just really stupid.

[Barana's Shipyard, Mudflats]
Shallow pools of water gather and vanish with every ripple from the close-by river. You also see a ship's rat.
Obvious paths: south, west.

[Barana's Shipyard, Mudflats]
Shallow pools of water gather and vanish with every ripple from the close-by river. You also see a rat pelt, a ship's rat, and a ship's rat (dead).
Obvious paths: south, west.

[Barana's Shipyard, Slipway Three]
This slipway holds a galley a lean reaver of the seas: You also see a ship's rat, a ship's rat, and a tattered canvas lean-to.
Obvious paths: up, down.

[Barana's Shipyard, Working Yard]
This large open area runs from the office and receiving yard down to the margin of the river itself. You also see a ship's rat, a ship's rat, a ship's rat, a tuft of grass, slipway number two, a windowless wooden shed, the shipyard office, slipway three, and slipway number one.
Obvious paths: west.

In the second example, one of them is dead - I would like that rat not to be included in the total account. Is this feasible? Could you be so kind as to show me what this code might look like?

Also, is there a pause command or anything like it for MUSHclient? Say a script performs an action that swings a sword and my 'roundtime' is six seconds. Is there any way that the script will wait six seconds or do I need to do something like this..

dim time
sub pause(time)
time = time * 30000 'or a number like that
do while time > 0
time = time -1
loop
end sub

Now my last question... for now anyways... If I type 'health' in a script, and the world responds with this -

Your body feels slightly battered.
Your spirit feels full of life.
You have no significant injuries.

or something like this -

Your body feels at full strength.
Your spirit feels full of life.
You have no significant injuries.

Could I copy that first line into a variable? Or parts of it into a variable? What would I have to do for that...?

Oops, I lied. I have another question, can a script create a trigger? Or enable it? Thanks for your patience...
[Go to top] top

Posted by Nick Gammon   Australia  (18,800 posts)  [Biography] bio   Forum Administrator
Date Reply #7 on Wed 15 May 2002 03:15 AM (UTC)  quote  ]
Message
Quote:

In the Trigger: field I typed Hello, which is what I want it to match on. I didn't tough the Match: or on or any of the checkboxes next to that. In send, I wrote say hi. I checked the enabled, and ignore case, and labeled it 'triggerthatdoesnotwork' should this be working?


I presume you actually typed 'say hello', otherwise it doesn't have much chance. :)

Triggers match rather literally, so you have a couple of choices here. A simple one is to make a regular expression, which matches anywhere on the line, eg.


Match: hello
Regular expression: checked
Ignore case: checked
Change colour to: whatever


That should colour the word "hello" if it sees it anywhere on a line.

Another approach is to get the *exact* text the trigger should match on, replacing any unknowns with asterisks, eg.

Say if the MUD does this:


say hello
You say in human 'hello'


Then you need to match like this:


Match: You say in human 'hello'
Ignore case: checked
Change colour to: whatever


Or, if someone else is going to say it ...


Match: * says, 'hello'
Ignore case: checked
Change colour to: whatever


Quote:

I need something that will count the number of 'ship's rats' in the room.


You could do this by counting them in a script, like this:


Match: *You also see*
Label: count_rats
Script: count_rats


Then put this in the script file.


Sub count_rats (TriggerName, TriggerLine, arrWildcard) 
dim count, start, col

  start = 1  ' start at column 1
  count = 0  ' no rats found yet
  do
    col = Instr (start, TriggerLine, "a ship's rat")
    if col = 0 then
       exit do
    end if
  
  count = count + 1 ' count those rats
  start = col + 1	' look for another  
  loop

  world.setstatus count & " rats found"

end sub 


This will show the number of rats on the status line.

Quote:

Also, is there a pause command or anything like it for MUSHclient? Say a script performs an action that swings a sword and my 'roundtime' is six seconds. Is there any way that the script will wait six seconds or do I need to do something like this..


You cannot pause in a script, because that would hold up the entire client. However you can introduce a timed delay, like this:


world.send "prepare myspell"
world.doafter 6, "cast myspell"


The "doafter" function does whatever you tell it, after the number of seconds you specify.

Quote:

Now my last question... for now anyways... If I type 'health' in a script, and the world responds with this -

Your body feels slightly battered.


I would make a trigger like this:


Match: Your body feels *
Send: %0
Send to: variable (label is name)
Label: health


The special sequence "%0" is the entire matching line, and matching on "Your body feels *" should hopefully match on the correct sort of line. The rest of the trigger copies the line into the variable "health".

Quote:

I have another question, can a script create a trigger? Or enable it?


Yes, see "world.addtrigger" and "world.EnableTrigger". Search this forum for examples.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] 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.


2,166 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]