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 ➜ Triggering on variables

Triggering on variables

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


Pages: 1 2  

Posted by Penguin   (46 posts)  Bio
Date Mon 05 Aug 2002 02:27 PM (UTC)
Message
Is it possible to trigger on variables now? Forgive me if I'm mistaken, but I thought in version 3.24, one can trigger on variables. Let's say I have a variable "Loser" and it's value is set to "Penguin".

Will I be able to set a trigger "@Loser *" which sends "emote %1". This will basically imitate whatever "Loser" (in this case, Penguin) does. Eg. When I see "Penguin roars!" I would be able to send "emote roars!" However it doesn't seem to work. Is my trigger set wrongly?
Top

Posted by Magnum   Canada  (580 posts)  Bio
Date Reply #1 on Mon 05 Aug 2002 07:23 PM (UTC)
Message
Since you are using the latest MUSHclient, there is one thing you could do to allow us to help you better:

Select the trigger that is giving you problems. Where you would usually hit the "edit" button to configure the trigger, instead hit the "copy" button on the right side.

Next, come to the forums here, and use your windows controls to "paste" the trigger code here. (With CTRL-V for example)

Off the cuff, it seems like your trigger should work. I don't use variables in my triggers, so I don't really have experience with this. I might try clicking the "expand variables" checkbox and see if that makes a difference.

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #2 on Mon 05 Aug 2002 08:57 PM (UTC)
Message
Quote:

I would be able to send "emote roars!"


You mean "emote Penguin" however yes, that should work, providing you check "expand variables".

I agree with Magnum, copy and paste the actual trigger so we can check it.

- Nick Gammon

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

Posted by Magnum   Canada  (580 posts)  Bio
Date Reply #3 on Tue 06 Aug 2002 02:51 AM (UTC)
Message
No, he says he want to copy what the person stored in the variable does, not emote to that person.

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #4 on Tue 06 Aug 2002 03:02 AM (UTC)
Message
Ah, OK. Anyway, checking "expand variables" should do it.

- Nick Gammon

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

Posted by Vaejor   (120 posts)  Bio
Date Reply #5 on Tue 06 Aug 2002 12:23 PM (UTC)
Message
In case anyone is still wondering what this is about, here's an example. It appears to work as requested, shown as follows:

(Note: I catch "> " 0-infinite times for my prompt. You should be able to leave that in without a problem as it can catch it 0 times.)

  <trigger
   enabled="y"
   expand_variables="y"
   match="^[&gt; ]*You say: @a (.*)$"
   regexp="y"
   send_to="2"
   sequence="10"
  >
  <send>emote %1
1: '%1'
2: '%2'
3: '%3'
4: '%4'
5: '%5'
6: '%6'
7: '%7'
8: '%8'
9: '%9'
10:'%10'</send>
  </trigger>
  <variable name="a">BLAH</variable>


Try: say BLAH does something
Then: say BLAH3 does something



Nick, please try this. I've noticed that %10 has an extra '0' character added to the end of itself on v3.24.
Top

Posted by Penguin   (46 posts)  Bio
Date Reply #6 on Tue 06 Aug 2002 03:12 PM (UTC)
Message
This may not come under the same heading but anyway.. due to my infinite curiosity(stupidity), I would like to ask if there's like a way to interact with the client. (Don't worry, I'm not lacking in interactive skills with real people)

Is it possible (codable/already available) to have perhaps a trigger that when matched, gives you a choice of things to do.

Like lets say I trigger on "Llama checks you out."
Can I have perhaps a few choices (predetermined and typed out in maybe a script file or something by the user naturally) appear? Maybe have something like

(1) Run away and hide
(2) Introduce yourself
(3) Kill Llama
Make your choice:

appear and then enter either 1, 2 or 3 which are maybe aliases to do certain things?
Um do you get what I'm trying to say?
Top

Posted by Magnum   Canada  (580 posts)  Bio
Date Reply #7 on Tue 06 Aug 2002 05:05 PM (UTC)

Amended on Tue 06 Aug 2002 05:12 PM (UTC) by Magnum

Message
I take it by not commenting on your previous problem in this thread, you probably resolved it.

To answer your question, there are a number of ways you could accomplish that task.

One would be to write script to present a window to you with the options... but that wouldn't be wise, because your client would stall until you answered the question.

What I would probably do is have a subroutine send the question with 'World.Note' functions, and then I would set the actions to take within variables.

Next, I would create an "answer" alias, like "pick *" for example. The alias would call a script which would "World.Send" the variable.

Dim arrAnswers(10)

Sub Ask_Encounter_Question (TriggerName, TriggerLine, arrWilcards)
  World.Note "Llama has checked you out. Do you want to:"
  World.Note "1: Run away and hide."
  World.Note "2: Introduce yourself."
  World.Note "3: Kill Llama."
  ArrAnswers(0) = 3   'Number of valid answers for this question.
  arrAnswers(1) = "south, south, south"  'Whatever you do in the mud to "Run away and hide."
  arrAnswers(2) = "greet llama"  'Whatever you do in the mud to "Introduce yourself."
  arrAnswers(3) = "kill llama"  'Whatever you do in the mud to "Kill Llama."
End Sub

Alias: pick *
Label: Select_Answer
Script: Act_on_Answer

Sub Act_on_Answer (AliasName, AliasLine, arrWildcards)
  Dim x
  If Not IsNumeric(ArrWildcards(1)) Then
    World.Note "Invalid answer: You must pick a number."
  Else
    If CInt(arrWildcards(1)) > arrAnswers(0) Then
      World.Note "Invalid answer: Not one of the choices."
    Else
      World.Send arrAnswers(CInt(ArrWildcards(1)))
    End If
  End If
  'Clear the answers using a For-Next loop:
  For x = LBound(arrAnswers) to UBound(arrAnswers)
    arrAnswers(x) = Empty
  Next
  arrAnswers(0) = 0
End Sub

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #8 on Tue 06 Aug 2002 11:01 PM (UTC)

Amended on Tue 06 Aug 2002 11:19 PM (UTC) by Nick Gammon

Message
Quote:

Note: I catch "> " 0-infinite times for my prompt.

match="^[&gt; ]*You say: @a (.*)$"



Vaejor, that will catch ">" OR " " infinite times. You might mean:


match="^(&gt; )*You say: @a (.*)$"


Then you would have to emote %2, or use the other idea you (or Magnum) had to stop it going into a wildcard, which I don't remember.

- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #9 on Tue 06 Aug 2002 11:03 PM (UTC)
Message
Quote:

Nick, please try this. I've noticed that %10 has an extra '0' character added to the end of itself on v3.24.


It should be %0 - all those replacement symbols are one character. You are getting %1 followed by a zero.

- Nick Gammon

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

Posted by Vaejor   (120 posts)  Bio
Date Reply #10 on Wed 07 Aug 2002 01:55 AM (UTC)
Message
Quote:
It should be %0 - all those replacement symbols are one character. You are getting %1 followed by a zero.


Ah, okay, well that explains it then. Don't know why I thought it was 1-10.

Quote:
Vaejor, that will catch ">" OR " " infinite times. You might mean:


match="^(&gt; )*You say: @a (.*)$"



Then you would have to emote %2, or use the other idea you (or Magnum) had to stop it going into a wildcard, which I don't remember.


Yeah, I started using [> ]* initially so I wouldn't catch it into %1 before Magnum mentioned the (?:> )* style processing, so I've stuck to it. Since my prompt is the only thing that really uses ">" or " " at the beginning of the line, I feel safe enough leaving it like that; at least until my next major rewrite of all my triggers.
Top

Posted by Penguin   (46 posts)  Bio
Date Reply #11 on Wed 07 Aug 2002 07:03 AM (UTC)
Message
Yup, I have already resolved the previous problem by checking expanding variables.

As for the question thingy, let's say Llama approaches me but I don't want to run away, introduce myself or kill him. Is there a way to exit the questionaire by typing "exit" or something? And also, would I be able to also like type "exitall" to exit that particular question and stop any other triggers which may bring up questions like those until activated by myself?
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #12 on Wed 07 Aug 2002 10:22 AM (UTC)
Message
In the example presented by Magnum, you would have to reply "pick <something>" (which is an alias) to respond. Simply not answering would amount to exiting. In other words, you *can* reply "pick x" but don't have to.

- Nick Gammon

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

Posted by Penguin   (46 posts)  Bio
Date Reply #13 on Wed 07 Aug 2002 12:45 PM (UTC)
Message
I copied and pasted the exact script (removing the explanation like "'Number of valid answers for this question." and "'Whatever you do in the mud to "Introduce yourself.") and set up the alias as shown. However a scripting error window pops out when I click OK on the alias configuration window. It says that

Event: Execution of line 566 column 13

Description: Syntax error
Line in error:
Alias: pick *

Line 566 of my script file contains the line:

' arrAnswers(2) = "greet llama"'

(It's arrAnswers(2) in a newline with two spaces before that, moving the cursor 13 times would then bring me to between opening bracket and the 2) I don't see anything wrong with it, since no error was detected with arrAnswers(1) or arrAnswers(2). Could someone help me out?

Also, I seem to recall that in version 3.20, errors in the script file would be brought out by the Scripting Error window while attempting to save the script file. Is it changed now?
Top

Posted by Magnum   Canada  (580 posts)  Bio
Date Reply #14 on Wed 07 Aug 2002 06:07 PM (UTC)

Amended on Wed 07 Aug 2002 06:54 PM (UTC) by Magnum

Message
Ahh... Heh heh. These three lines:

Alias: pick *
Label: Select_Answer
Script: Act_on_Answer

...I did not expect you to paste that in as a part of your script file. They were intended as instructions to you, to make that alias manually. Delete those three line.

You can copy this code below into the windows clipboard, then click your alias icon to bring up the alias menu, and click the "paste" button on the right side to add this alias:

<aliases>
  <alias
   name="Select_Answer"
   script="Act_on_Answer"
   match="pick *"
   enabled="y"
   ignore_case="y"
  >
  </alias>
</aliases>

Ok?

Incidentally, I just guessed at what your "flee" commands might be (moving in a direction)... and I put multiple commands seperated by a "," . This would probably not work on any MUD. If you wanted to put multiple commands you would do it like this:

arrAnswers(1) = "south" & vbNewline & "south" & vbNewLine & "south"

"vbNewline" is a special variable (A CONSTANT), which is built into Visual Basic. In this case, it represents hitting the 'Enter/Return' key. That's what you would use the send multiple commands for an answer.

Also, the script is not completely fool-proof. You could use "pick 0" in the mud, and it would send "3" to the mud (in this example). If you type "pick -1", it would probably cause a runtime error. (Because I forgot to check to make sure the number you answer isn't < 1).

Sub Act_on_Answer (AliasName, AliasLine, arrWildcards)
  Dim x
  If Not IsNumeric(ArrWildcards(1)) Then
    World.Note "Invalid answer: You must pick a number."
  Else
    If CInt(arrWildcards(1)) > arrAnswers(0) Then
      World.Note "Invalid answer: Not one of the choices."
    ElseIf NOT CInt(arrWildcards(1)) < 1 Then
      World.Send arrAnswers(CInt(ArrWildcards(1)))
    Else
      World.Note "Question ignored and reset."
    End If
  End If
  'Clear the answers using a For-Next loop:
  For x = LBound(arrAnswers) to UBound(arrAnswers)
    arrAnswers(x) = Empty
  Next
  arrAnswers(0) = 0
End Sub

That new code above checks to see if the answer is a number less than 1, and if so, it sends nothing to the mud, but still clears the answers. (And wouldn't cause a runtime error). ...So, to be tidy, if you didn't want to pick one of the given answers, you could use "pick 0" to reset the question.

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
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.


64,143 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.