[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]  General
. . -> [Subject]  Help for the starter
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Help for the starter

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


Posted by Krae   Netherlands  (16 posts)  [Biography] bio
Date Sat 29 Aug 2009 05:37 PM (UTC)  quote  ]
Message
So hello, I have been using Mushclient for a while. I am (barely) capable of making the simplest of triggers and aliases but what I have is mostly snagged from other scripts or just lucky guesses.
Anyway I have been trying to make two 'simple' triggers, the idea is this.
In a mud someone says something over a channel called a web and I respond to that.
The phrase would look like this:
(Web): Someone says, "Jack - COLOUR."
To which I do a command that switches to arrows of that colour.
The other phrase is:
(Web): Someone says, "TARGET is our target to the DIRECTION."
Which would lead me to targeting the target (I can target manually doing TAR TARGET) but also saving the Direction as a variable.
So later when someone says over that web, Fire.. I do AIM TARGET DIRECTION and SHOOT TARGET DIRECTION

I -thought- I finally had it but.. alas.. I suck.
Now I already have some sort of a 'system' which has the variable target in it.. I was looking to implement this in that but I'll show what I had up until now. (which doesn't work) I had been browsing about, but I think the problem lies with it not properly picking up the (Web) part though I could be wrong, please do point out what I did wrong and how I could prevent this in the future, my utmost thanks for you time reading this and any possible help offered.

Quote:

<triggers>

<trigger
 enabled="y"
 match="(?s)^(Web)\:\s+\w+\s+says\,\s+"\s+NAME\s+.\s+(\w+)\s+"\.\Z"
 regexp="y"
 send_to="2"
 sequence="100"
 >
 <send>secure bastard
bowstance
switch %1
ColourNote "crimson", "silver", "Switching to %1"</send>
 </trigger>

<trigger
 enabled="y"
 match="(?s)^(Web)\:\s+\w+\s+says\,\s+"\s+(\w+)\s+is\s+our\s+target\s+to\s+the\s+(\w+)\s+"\.\Z"
 regexp="y"
 send_to="2"
 sequence="100"
 >
 <send>world.SetVariable "target", "%1"
ColourNote "deepskyblue", "black", "Target: %1"
world.SetVariable "direction", "%2"
ColourNote "green", "black", "Dir: %2"</send>
 </trigger>
</triggers>

<variables>
  <variable name="target"></variable>
  <variable name="direction"></variable>
</variables>

[Go to top] top

Posted by Nick Gammon   Australia  (19,169 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Sat 29 Aug 2009 09:20 PM (UTC)  quote  ]
Message
It took a bit of mucking around to paste that into my copy of the client. Please follow the instructions below next time to make a copy of your trigger:

Template:copying For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.


In particular the "match" lines didn't work because they had imbedded quotes:


match="(?s)^(Web)\:\s+\w+\s+says\,\s+"\s+NAME\s+.\s+(\w+)\s+"\.\Z"


If you had simply clicked the "copy" button they would have been converted to &quot; for you.


  • The first thing I will change is to get rid of "(?s)" from your trigger match. That is the "dot matches all" option which only applies to multi-line triggers (which might have a newline in them).

  • Similarly the "\Z" is only for multi-line triggers, really. To match the end of a single-line trigger you just need "$".

  • You said you would see: (Web): Someone says, "Jack - COLOUR."

    However in your trigger you have NAME - is this supposed to be Jack, or what?

  • You haven't said what language you are using, but if it is Lua then you need to put function arguments in quotes, except in certain limited circumstances. That is, change:

    
    ColourNote "crimson", "silver", "Switching to %1"
    


    to:

    
    ColourNote ("crimson", "silver", "Switching to %1")
    


  • You are doing "send to output", so if the trigger matches, it simply prints on the screen:

    
    secure bastard
    bowstance
    switch green
    ColourNote "crimson", "silver", "Switching to green"
    


    This isn't what you want, I presume. You want to DO these things, not just put them on the screen.

    However to do things like the ColourNote you need to send to "script", however in that case you can't mix script commands with things to go to the MUD. In other words, it needs to look like this:

    
    Send ("secure bastard")
    Send ("bowstance")
    Send ("switch %1")
    ColourNote ("crimson", "silver", "Switching to %1")
    


    So, with those things fixed up, the triggers looks like this:

    
    <triggers>
      <trigger
       enabled="y"
       match="^\(Web\): \w+ says, &quot;Jack \- (\w+?)\.&quot;$"
       regexp="y"
       send_to="12"
       sequence="100"
      >
      <send>
    
    Send ("secure bastard")
    Send ("bowstance")
    Send ("switch %1")
    ColourNote ("crimson", "silver", "Switching to %1")
    
    </send>
      </trigger>
    
      <trigger
       enabled="y"
       match="^\(Web\): \w+ says, &quot;(.*?) is our target to the (\w+?)\.&quot;$"
       regexp="y"
       send_to="12"
       sequence="100"
      >
      <send>
    
    SetVariable ("target", "%1")
    ColourNote ("deepskyblue", "black", "Target: %1")
    SetVariable ("direction", "%2")
    ColourNote ("green", "black", "Dir: %2")
    
    </send>
      </trigger>
    </triggers>
    


    Template:pasting For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.



- Nick Gammon

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

Posted by Krae   Netherlands  (16 posts)  [Biography] bio
Date Reply #2 on Sat 29 Aug 2009 09:43 PM (UTC)  quote  ]
Message
Ah, I had written that.. outside of the client.. as I said I'm not adept at that apparently.
So thank you -very much- for your time.
I had realized that world.setvariable was vbscript and ColourNote was lua, though I thought I had to leave it as such.
So judging from that I believe that for some characters the ansi codes are needed to properly catch those?
Once again thank you a lot for your help!, for I was at a stand still on this.
[Go to top] top

Posted by Krae   Netherlands  (16 posts)  [Biography] bio
Date Reply #3 on Sat 11 Sep 2010 08:21 PM (UTC)  quote  ]

Amended on Tue 14 Sep 2010 02:32 PM (UTC) by Krae

Message
Hello!
So a year later and a little bit of learning later, I am trying to make a 'tracker' of sorts.

First of all it checks if I have managed to hit with both strikes, or just one and echoes it back to me. However one of the pitfalls is that the target can possibly dodge the attack in some way which will always (if true) be on a newline below the message of attack. So with my script it could first say 'Hit hit' and then 'hit miss' (or such). So it echoes in double, with the last one being the correct one if one strike is dodged. (I experimented with keep_evaluating but that didn't help)

Another problem is that when it registers a hit it will or rather should take the last applied venoms, check which one it was and according to that check which affliction has struck upon a hit= target has blah.
It does fire (double however and even on a miss it will fire) plus it always grabs the first affliction (clumsiness) regardless of venom.

I am not sure what it is that I did wrong here.


Thanks for the time spent reading this, any help is appreciated.
[Go to top] top

Posted by Krae   Netherlands  (16 posts)  [Biography] bio
Date Reply #4 on Sat 11 Sep 2010 08:29 PM (UTC)  quote  ]

Amended on Sat 11 Sep 2010 08:35 PM (UTC) by Krae

Message
Sorry for making another post but character limit struck!

So the alias that is called upon 'venomcheck' which is probably the troublemaker. I thought it was quite something when I discovered the success of if and then statements, however I crashed and burned here. Possibly a 'table' might be of use but I am unsure how to use them correctly especially in this situation.


<aliases>
  <alias
   match="venomcheck"
   enabled="y"
   expand_variables="y"
   send_to="12"
   sequence="100"
  >
  <send>if venom1hit == yes then
   if venom1 == xentio then
      Note ("target has clumsiness")
   elseif venom1 == eurypteria then
      Note ("target has recklessness")
   elseif venom1 == kalmia then
      Note ("target has asthma")
   elseif venom1 == strophanthus then
      Note ("target has limp_veins")
   end
end
if venom2hit == yes then
     if venom1 == xentio then
      Note ("target has clumsiness")
   elseif venom1 == eurypteria then
      Note ("target has recklessness")
   elseif venom1 == kalmia then
      Note ("target has asthma")
   elseif venom1 == strophanthus then
      Note ("target has limp_veins")
   end 
end</send>
  </alias>


The 'Note' stuff is only a placeholder since I am planning to have it sent to a miniwindow. Eventually it will list 'Target has:' and then a list of the afflictions that will be added and removed according to what I track, any thoughts or ideas on how to handle this? I -have- managed to create miniwindows from seeing the target eat an herb for example, but once a new herb is eated the window is overwritten with the new one.

Once again thanks for your time spent reading this and helping!
[Go to top] top

Posted by Nick Gammon   Australia  (19,169 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Sat 11 Sep 2010 09:18 PM (UTC)  quote  ]
Message
A quick glance at this shows you are confusing variables with their contents:


if venom1hit == yes then
   if venom1 == xentio then
      Note ("target has clumsiness")


Without quotes, the word yes is just a variable (which probably contains nothing).

So the first change is to do this:


if venom1hit == "yes" then
   if venom1 == "xentio" then
      Note ("target has clumsiness")


After all, you are setting the variables to "yes" and "no", not yes and no, right?

Second problem is you are setting MUSHclient variables (with SetVariable) but testing Lua variables. They are different beasts.

So, since you are using expand variables, one approach is this:


if @venom1hit == "yes" then
   if @venom1 == "xentio" then
      Note ("target has clumsiness")


Or you could do this:


if GetVariable ("venom1hit") == "yes" then
   if GetVariable ("venom1") == "xentio" then
      Note ("target has clumsiness")


Similarly elsewhere.

- Nick Gammon

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

Posted by Krae   Netherlands  (16 posts)  [Biography] bio
Date Reply #6 on Sat 11 Sep 2010 10:00 PM (UTC)  quote  ]
Message
Aha! Of course! I absolutely forgot to put the "yes" etc. in quotes! Thank you! Such a stupid mistake.

And ah yes, I had changed it to GetVariable etc. before but then forgot to put back the @'s again! A stupid mistake.

Thank you very very much for taking the time to help me!
Much appreciated especially such a speedy reply.
[Go to top] top

Posted by Deladan   (40 posts)  [Biography] bio
Date Reply #7 on Mon 13 Sep 2010 08:28 PM (UTC)  quote  ]
Message
If you ever get that working I'd love to have a copy of it....
[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,541 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]