Help - Search - Members - Calendar
Full Version: City Enemy Capture - Mushclient
Achaea's Forums > Off-Topic > Tech Support > Client Help
Serris
I've made a highlighter for city enemies but have to update my 'cenemies' variable manually so I tried to make some triggers to capture all the names from 'cityenemies'. So far this is what I have:

<triggers>
<trigger
group="cityenemycapture"
ignore_case="y"
keep_evaluating="y"
match="Total: \d+"
regexp="y"
repeat="y"
send_to="12"
sequence="90"
>
<send>EnableTriggerGroup ("cityenemycapture", false)</send>
</trigger>
<trigger
enabled="y"
match="^Enemies of the City of Hashan:$"
regexp="y"
send_to="12"
sequence="100"
>
<send>EnableTriggerGroup ("cityenemycapture")</send>
</trigger>
<trigger
group="cityenemycapture"
match="(.*)"
regexp="y"
send_to="12"
sequence="100"
>
<send>SetVariable ("cenemies", "%1")
SetVariable ("enemies", Replace (GetVariable("cenemies"), ", ", "|", true))</send>
</trigger>
</triggers>

It works but only updates the list with the last line regardless if I check Keep Evaluating, Multi-Line Match, Repeat on Same Line or any variation of those. Multi-Line Match updates only one line but if I put 5 in there, it updates the fifth line from the bottom. Any ideas how to make this capture all the names? My screenwidth is 80.
Soludra
CODE
  <trigger
   group="cityenemycapture"
   keep_evaluating="y"
   match="^Total: \d+$"
   regexp="y"
   send_to="12"
   sequence="90"
>
<send>EnableTriggerGroup ("cityenemycapture", false)
SetVariable ("enemies", Replace(temp, ", ", "|", true))</send>
  </trigger>

   <trigger
   enabled="y"
   match="^Enemies of the City of Hashan:$"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>EnableTriggerGroup ("cityenemycapture")
temp = ""</send>
  </trigger>

  <trigger
   group="cityenemycapture"
   match="^(.*)$"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>temp = temp .. "%1"</send>
  </trigger>


Try this? Untested, but theoretically it should be fine. (EDIT: If it works I'll explain, I just don't feel like typing a lot just yet)

EDIT 2: My 1024'th post! That's a special number biggrin.gif
Trevize
This is what I use.

CODE
<triggers>
  <trigger
   enabled="y"
   group="enemies"
   lines_to_match="2"
   keep_evaluating="y"
   match="^Enemies of (.*)\:\n(.+)\Z"
   multi_line="y"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>enemies = enemies or {}
local temporg = data.orgs.rev["%1"]
if temporg then
  local tempvar = {
    name = "e" .. temporg,
    data = string.gsub ("%2", ", ", "|"),
    }
  SetVariable (tempvar.name, tempvar.data)
  enemies[temporg] = utils.split (tempvar.data, "|")
end -- if</send>
  </trigger>
</triggers>


With this in my script file:
CODE
data = {
  orgs = {
    city = "Ashtan",
    house = "the Merchants",
    order = "the Order of the Moon",
    citylong = "the City of Ashtan",
    houselong = "the Merchants of the Crown",
    orderlong = "the Divine Order of Ourania, Goddess of the Moon",
    rev = {
      ["the City of Ashtan"] = "city",
      ["the Merchants of the Crown"] = "house",
      ["the Divine Order of Ourania, Goddess of the Moon"] = "order",
      },
    },
  }


It lists enemies in a MUSHclient table called enemies, with the key as the org type (city/house/order) and the value a numerically indexed table of names. It also creates a MUSHclient variable, vertical-bar delimited, for use in regex highlighting. I also use this script to check enemy partial names, or see what all orgs of mine a specific enemy is:

Aliases:
CODE
<aliases>
  <alias
   match="^ce (\w+)$"
   enabled="y"
   group="enemies"
   regexp="y"
   send_to="12"
   ignore_case="y"
   sequence="100"
  >
  <send>enemies.match  (string.lower("%1"))</send>
  </alias>
  <alias
   match="^cep (\w+)$"
   enabled="y"
   group="enemies"
   regexp="y"
   send_to="12"
   ignore_case="y"
   sequence="100"
  >
  <send>enemies.partialmatch (string.lower("%1"))</send>
  </alias>
</aliases>


Script:
CODE
-- =============
--  enemy check
-- =============

enemies = {
  city  = utils.split (GetVariable("ecity")  or "", "|"),
  house = utils.split (GetVariable("ehouse") or "", "|"),
  order = utils.split (GetVariable("eorder") or "", "|"),

  match = function (name)
    AnsiNote (ansicolor(7), "Searching for ",
              ansicolor(15), name,
              ansicolor(7), " in enemy database.")
    local found = {
      city  = enemies.search (name, "city"),
      house = enemies.search (name, "house"),
      order = enemies.search (name, "order"),
      }
    if not (found.city or found.house or found.order) then
        AnsiNote (ansicolor(15), name,
                  ansicolor(7), " not found.")
    end -- if
    prompt.draw ()
  end, -- func

  search = function (name, org)
    local found = false
    for k, v in ipairs (enemies[org]) do
      if string.lower (name) == string.lower (v) then
        found = true
        AnsiNote (ansicolor(15), v,
                  ansicolor(9), " is an enemy of " .. data.orgs[org] .. ".")
      end -- if
    end -- for
    return found
  end, -- func

  partialmatch = function (name)
    AnsiNote (ansicolor(7), "Searching for names matching ",
              ansicolor(15), name,
              ansicolor(7), " in enemy database.")
    local found = {
      city  = enemies.partialsearch (name, "city"),
      house = enemies.partialsearch (name, "house"),
      order = enemies.partialsearch (name, "order"),
      }
    found.total = found.city + found.house + found.order
    AnsiNote (ansicolor(15), found.total,
              ansicolor(7), " names matching ",
              ansicolor(15), name,
              ansicolor(7), " found. ")
    prompt.draw ()
  end, -- func

  partialsearch = function (name, org)
    local found = 0
    for k, v in ipairs (enemies[org]) do
      if string.match(string.lower(v), name) then
        found = found + 1
        AnsiNote (ansicolor(15), v,
                  ansicolor(9), " is an enemy of " .. data.orgs[org] .. ".")
      end -- if
    end -- for
    return found
  end, -- func
  }


Note: it uses prompt.draw to draw a prompt, and ansicolor to get the color. You can find both in most of my plugins.
Naifos
I thought it to be a waste if I made a new topic on the subject and just more reason to laugh at my inept grasp on the whole of Aliases and triggers.
If I were to plug these in what document would I put them in and how would I upload them? I'm not sure if this is a common idiotic mistake but I found myself trying to highlight enemies and I came to the conclusion that with my limited knowledge I would have to take each line on the list and put a "|" in between each and every enemy (eg {e1|e2|e3} etc. and then highlight from there) Unfortunately in the end I learned that the amount of triggers and aliases I had had stopped my anti-theft trigger from working (Luckily it was a friend playing a joke that time) so I had to remove all my enemies from the list. Anyways, I'm currently reading over Trevize's tutorial on regex and trying to get more of an understanding as to what goes where and such but any help would be extremely appreciated.
Trevize
QUOTE (Naifos @ Sep 6 2009, 04:37 PM) *
I thought it to be a waste if I made a new topic on the subject and just more reason to laugh at my inept grasp on the whole of Aliases and triggers.
If I were to plug these in what document would I put them in and how would I upload them? I'm not sure if this is a common idiotic mistake but I found myself trying to highlight enemies and I came to the conclusion that with my limited knowledge I would have to take each line on the list and put a "|" in between each and every enemy (eg {e1|e2|e3} etc. and then highlight from there) Unfortunately in the end I learned that the amount of triggers and aliases I had had stopped my anti-theft trigger from working (Luckily it was a friend playing a joke that time) so I had to remove all my enemies from the list. Anyways, I'm currently reading over Trevize's tutorial on regex and trying to get more of an understanding as to what goes where and such but any help would be extremely appreciated.

I wouldn't plug them in as-is, they won't work without at least the few extra things I mentioned. I posted them mostly as a reference. If you really do want to try and paste them in, and triggers/timers/aliases you can copy what's between <triggers> and </triggers>, then open your triggers dialog and hit the paste button on the right. If you want to know what any part does, ask and I can explain, or if you want to do anything specific, again, ask and I'll explain.
Serris
Sorry this is so late. Had a problem with all my triggers suddenly not working even when I created a new world. Thanks Soludra, the triggers work great. Trevize, I've tried installing yours to see how it works but I keep running into errors. Ah, I'm going to make it into a plugin I guess and see if that works with all the triggers and such in there with the script. Actually, I think I tried to take this script from one of your threads before but it kept giving me errors. We'll see if I can figure it out - most of what you write I can't understand though which is why I was just using simple triggers to capture enemies. <.<

I'll post the messages I get if it continues not working, hopefully someone will be able to help figure it out. Thank you both.
Naifos
QUOTE (Trevize @ Sep 3 2009, 11:01 PM) *
This is what I use.

CODE
Words

CODE
Words

CODE
Words


So where would I put these in in MUSHClient?

I mostly only know about right clicking and saving plugins to upload. How would I save these scripts and where would I put them?
Trevize
QUOTE (Naifos @ Sep 10 2009, 03:15 PM) *
QUOTE (Trevize @ Sep 3 2009, 11:01 PM) *
This is what I use.

CODE
Words

CODE
Words

CODE
Words


So where would I put these in in MUSHClient?

I mostly only know about right clicking and saving plugins to upload. How would I save these scripts and where would I put them?

First, keep in mind I put that up there as a reference. If it doesn't work, let me know what happens and I'll see about helping you fix it, though.

Plugins/aliases are exported/imported through XML. It looks a lot like HTML. Whenever you see a bunch of <tags>, the first is <triggers>, and the last is </triggers>, it's (you guessed it) a trigger or set of triggers. Just select it, copy (ctrl-c), then go to MUSHclient and in the triggers dialog, hit the paste button on the lower right. The same goes for timers and aliases. If you want to share any, just select them in MUSHclient and hit the copy button next to the paste one, then you can paste them to the forums or whatever (using ctrl-v).

For the script, copy it and paste it into your script file. You can get to it with Game|Configure|Scripting, then hit edit script. If you can't, you likely don't have a script file. Hit the new button to make one. Note that the script I pasted above is in Lua, you would have to have it as your scripting language (set at the top of the dialog opened by Game|Configure|Scripting).
Naifos
Holy Cow, 2 courses of Web Design and I didn't know you could save an XML file with the suffix.xml...

I guess I was scripting in Lua then, My Script is set to Lua

If I could have some explaination dissecting the code. \\ for commentary
This is what I think each line does, correct me if I'm wrong.

The Alias is gcare
the tick boxes "Enable" and "Expand Variable" are checked
Sequence is 100
Send To is set to "Script"

CODE
require "wait" *
wait.make (function() *
Send("grove seal") \\ tells they system to tell the server the words "grove seal" have been typed
wait.time(3) \\waits three seconds for equilibrium.
Send("grove preservation") \\ See "grove seal"
wait.time(3) \\ See above
Send("grove tend") \\See "grove seal"
end) *


I disected this from a friend's anti-theft file so here's what I don't understand.

-Why is the sequence 100?
-Why does the system need the lines marked with an asterisk? Granted I guess that "end)" closes of the "wait.make (function" line.
-When I have "wait.time(3)" is that three seconds or another measurement of time?
-What does expand variable do and why doesn't it seem to work without it?
Trevize
QUOTE (Naifos @ Sep 10 2009, 04:44 PM) *
The Alias is gcare
the tick boxes "Enable" and "Expand Variable" are checked
Sequence is 100
Send To is set to "Script"

CODE
require "wait" *
wait.make (function() *
Send("grove seal") \\ tells they system to tell the server the words "grove seal" have been typed
wait.time(3) \\waits three seconds for equilibrium.
Send("grove preservation") \\ See "grove seal"
wait.time(3) \\ See above
Send("grove tend") \\See "grove seal"
end) *


-Why is the sequence 100?
Sequence is just the order triggers fire in if several match the same line. Lower sequence fires first.
-Why does the system need the lines marked with an asterisk? Granted I guess that "end)" closes of the "wait.make (function" line.
require "wait" adds the wait lua file Nick made.
wait.make () runs the function wait.make, passing everything between () to the function.
I don't use this module myself but I gather the function it passes (what's between function() and end) is saved to a variable and run when the time is up.

-When I have "wait.time(3)" is that three seconds or another measurement of time?
Again I don't use this file but if it does what I think, it creates a timer set to that amount of seconds, yes.
-What does expand variable do and why doesn't it seem to work without it?
It should work without it. Expand variables lets you use MUSHclient vars in the syntax @var where var is the variable name. If that is the whole script, I don't see anywhere you use it.

This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.