Alias setting variable to be called by trigger

Posted by Omegasage on Sat 21 Jan 2012 06:52 AM — 8 posts, 37,690 views.

#0
Ok, a little complicated here, I got this to work fairly painlessly using Portal, but Portal doesn't support multiple windows so I switched. I've got it partially working, but have ran into a few issues.

First I started with an Alias:
track (?P<target>.*)

Command:
SetVariable ("target", "%<target>")
Execute ("sense @target")

Options:
Regular Expression
Expand Variables
Send to Script

After this I have a trigger follow it up:
^(.*)You concentrate and sense their ki (?P<there>.*) of here.

Output:
%<there>
sense @target

Options:
Keep Evaluating (tried this on and off makes no difference)
Regular Expression
Expand Variables
Send to World

A couple quirks:

I have to use the track command twice. When I use it it will send whatever the previous variable was before it writes the new one in.

Sometimes get "stuck" where if part of the direction to where the target is includes a room with exits w,n,e and you're coming from the east and the target is north, it'll sometimes hang up and keep going east then west past that room. If I let it sit there for a minute or so it eventually fixes itself, but it's quicker to kill it and move manually.

Third, most recent issue, if my status is on the same line as the trigger, it wont go off at all.

For Example:
[randomstats][randomstats][randomstats][randomstats]You concentrate and sense their ki west of here.

Nothing happens in this case....
USA #1
Quote:
Third, most recent issue, if my status is on the same line as the trigger, it wont go off at all.

For Example:
[randomstats][randomstats][randomstats][randomstats]You concentrate and sense their ki west of here.


your trigger is set to match on
^(.*)You concentrate and sense their ki (?P<there>.*) of here."

that ^ requires it be the start of a new line, thus when you have a prompt or anything else it wont fire. delete that ^ and it should work.

Past that, it is helpful to copy/paste your entire trigger. Not just tell us what the trigger/send/everything is manually.

How to do that is listed in the Faq, but a quick version is open your triggers. select the trigger(s) you want. then click the copy button in that window.

you can now paste something that will look like this.

<triggers>
  <trigger
   enabled="y"
   ignore_case="y"
   match="What do you seek"
   regexp="y"
  >
  <send>say i seek the grail</send>
  </trigger>
</triggers>

You can also copy this and click the paste button, also on the triggers page, to easily load triggers.


As far as your first complaint
Quote:
I have to use the track command twice. When I use it it will send whatever the previous variable was before it writes the new one in.


here is one way i get around that


<aliases>
  <alias
   match="^dig[ ]+(.*?)$"
   enabled="y"
   group="All"
   variable="Digdir"
   regexp="y"
   send_to="9"
   ignore_case="y"
   keep_evaluating="y"
   sequence="100"
  >
  <send>%1</send>
  </alias>
  <alias
   match="dig *"
   enabled="y"
   expand_variables="y"
   group="All"
   sequence="101"
  >
  <send>dig @digdir</send>
  </alias>
</aliases>


The first alias, with a sequence of 100 sets the variable "Dirdir", and has keep evaluation checked so the 2nd alias with a sequence of 101 fires right after and sends dig @digdir with expand_variables checked, sending the variable you just set.

I am sure it is an ugly brute force approach, and that others can tell you how to do nicer... But it does work :P
#2
Your brute force approach to the alias works great. I never understood what Keep Evaluating did until going through these forums, this should make things a lot easier. However the trigger is still being funky. I'll repost both the way you suggested:


<aliases>
<alias
match="^track[ ]+(.*?)$"
enabled="y"
group="Tracking"
variable="target"
regexp="y"
send_to="9"
ignore_case="y"
keep_evaluating="y"
sequence="100"
>
<send>%1</send>
</alias>
</aliases>

<aliases>
<alias
match="track *"
enabled="y"
expand_variables="y"
group="Tracking"
sequence="101"
>
<send>sense @target</send>
</alias>
</aliases>

<triggers>
<trigger
enabled="y"
expand_variables="y"
group="Tracking"
keep_evaluating="y"
match="(.*)You concentrate and sense their ki (?P&lt;there&gt;.*) of here."
regexp="y"
sequence="100"
>
<send>%&lt;there&gt;
sense @target</send>
</trigger>
</triggers>
USA #3
I am not entirely sure what you are doing with your trigger.

I assume you are trying to name the variable in the regular expression. I seem to recall you can do that, but it is not something i use personally so i can't tell you how to fix it. :P

You might have some luck with this trigger though.

<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   group="Tracking"
   keep_evaluating="y"
   match="You concentrate and sense their ki (.*?) of here\.$"
   regexp="y"
   sequence="100"
  >
  <send>%1
sense @target</send>
  </trigger>
</triggers>

Assuming i understand what your trying to match right... :P It should send the direction, then sense @target.

It doesn't require that it be at the start of the line, so if there is a prompt it should still work.

It only has the one very simple variable in the match, so all that is required is a simple %1 to use that variable.

And it does require that it be the end of the line, if it doesn't work try deleting the $ at the end of the line.

#4
Neither of those tricks seem to work. I don't know why, but whenever that prompt comes up as the start of the line, any line, it seems to negate any trigger I have set up. The prompt is simply my status bar. Normally the Prompt will use up its own line, but whenever commands are stacked, the message for a new line will at times continue out of said prompt. I don't do a lot of command stacking, but sometimes it comes up, like reapplying buffs, or using delayed attacks. This is really frustrating. and I don't think it's so much a problem with the code, but maybe I tweaked a setting somewhere I shouldn't have maybe...

Wow, I just figured it out, boy do I feel stupid.

I have a separate trigger set to the status bar, and I never set it to keep evaluating. I just set it to do that, and now everything is golden. I feel dumb. Thank you for your time and efforts.
Amended on Fri 03 Feb 2012 10:23 AM by Omegasage
#5
Ok, even though I got it working again, I have ran into a different issue with it. It sends the command twice:



<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   group="Tracking"
   keep_evaluating="y"
   match="(.*)You concentrate and sense their ki (?P&lt;there&gt;.*) of here."
   regexp="y"
   sequence="100"
  >
  <send>%&lt;there&gt;
sense @target</send>
  </trigger>
</triggers>

<triggers>
  <trigger
   enabled="y"
   expand_variables="y"
   group="Tracking"
   keep_evaluating="y"
   match="(.*)You think you sense their ki (?P&lt;there&gt;.*) of here."
   regexp="y"
   sequence="100"
  >
  <send>sense @target</send>
  </trigger>
</triggers>

<aliases>
  <alias
   match="track *"
   enabled="y"
   expand_variables="y"
   group="Tracking"
   sequence="101"
  >
  <send>sense @target</send>
  </alias>
</aliases>

<aliases>
  <alias
   match="^track[ ]+(.*?)$"
   enabled="y"
   group="Tracking"
   variable="target"
   regexp="y"
   send_to="9"
   ignore_case="y"
   keep_evaluating="y"
   sequence="100"
  >
  <send>%1</send>
  </alias>
</aliases>




So if I put: "track minotaur", it will send:

sense minotaur
sense minotaur

Just like that, it really messes it up. Someone else in the MUD gave me a plugin that seems to work, but I can't tie it in to my other triggers and such. It uses commands I can't tie into my triggers, since i can't activate alias's directly.

[Moderator edit] Forum codes and [code] tags added.
Amended on Tue 07 Feb 2012 08:16 AM by Nick Gammon
Australia Forum Administrator #6
Are you sure you don't have more than one such alias? When I tried your two aliases I only saw "sense minotaur" once.

Try turning on "Trace" from the Game menu to see what aliases are firing and when.

Anyway, you don't need two aliases matching on the same thing to do two things. That's what scripting is for. Try this instead of both of them:


<aliases>
  <alias
   match="track *"
   enabled="y"
   group="Tracking"
   send_to="12"
   sequence="101"
  >
  <send>

SetVariable ("target", "%1")  -- set the variable
Send ("sense %1")   -- sense the target
Note ("Now tracking: %1")  -- confirm your action

</send>
  </alias>
</aliases>


Template:pasting
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.
Amended on Tue 07 Feb 2012 08:27 AM by Nick Gammon
#7
That works wonderfully! Thank you!

Not sure why it was sending doubles of it before. I tried the tracing as you said, but it wasn't doing it anymore. In the course of messing with other stuff I must have inadvertently fixed it. Only other place where the alias existed at all was the plugin, but that was disabled.