Setting Variables Instantly on Triggers

Posted by Parham on Wed 16 Dec 2009 06:23 AM — 4 posts, 17,557 views.

#0
Hello there,
I am a new user on this forum, and from Iran. Hail! :-)

I am blind, and usually gag my prompt, of course. However, since most of the muds do not have an hp/ep/mp/whatever command to show you your stats, I usually, in other clients, create an alias which would be something like this:
match "hp"
send "/speech.say @hp, 0"

and so forth. However, with such a prompt:
*h, *m, *e
... is there a way to assign the wildcards to variables instantly? In another client, I could use this, which I give you as an example of what I want:
&{hp}h, &{mp}m, &{ep}e

Hopefully I have been able to get my point across.

Thanks for such a great client!
Australia Forum Administrator #1
You can make a trigger that matches the prompt, and inside the send box put 3 lines of script to set the three variables. The "send to" box needs to be "script".

Here is an example:


<triggers>
  <trigger
   enabled="y"
   match="*h, *m, *e"
   send_to="12"
   sequence="100"
  >
  <send>

require "var"

var.hp = %1
var.mp = %2
var.ep = %3

</send>
  </trigger>
</triggers>


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


Now make a few aliases to report your hp, mp, and ep as appropriate. There have been posts about screen readers if you need help on that.

Template:faq=13
Please read the MUSHclient FAQ - point 13.

#2
Greetings,
Thanks a lot! I have two questions, though.

Why send_to="12"?
And, why did you require "var", and then set var.hp/etc, and not just do something like:
hp = %1

Thanks!
Australia Forum Administrator #3
In the text version of a trigger, send to "12" means "send to script". If you click on the "send to" combo box, and select "script" that becomes 12 when the trigger is copied onto the clipboard.

So, basically, the trigger is a script trigger.

As for "require 'var'", that simplifies the setting of MUSHclient variables. A version without it would be:


SetVariable ("hp", "%1")
SetVariable ("mp", "%2")
SetVariable ("ep", "%3")


That's just a bit more typing. However you could do as you suggested and just use:


hp = %1
mp = %2
ep = %3


The distinction is that my original version set MUSHclient variables (which persist when the world is saved) compared to script variables.

However in your case, where you just want to save the current HP, which is ephemeral anyway, just using script variables is probably the better solution.