how to use mixed "send_to"?

Posted by Zero on Wed 29 Jul 2009 08:27 PM — 3 posts, 15,182 views.

#0
Hi, I want to use simple command, as below:

<triggers>
<trigger enabled="y" group="exercise" keep_evaluating="y" omit_from_output="y" regexp="n"
send_to="14"
sequence="100" match="something is wrong">
<send>look</send>
<send sen_to="12">SomethingWrong()</send>
</trigger><triggers>
<script>
sub SomethingWrong()
......

but it doesn't work. Why doesn't Mush support mixed command like this?
Australia Forum Administrator #1
For a start, if it supported it, the GUI interface would need considerable change to allow for multiple "send" boxes, and multiple "send-to" types.

Anyway, it isn't necessary. By using send-to-script you can send to mixed places, for example:


<triggers>
  <trigger
   enabled="y"
   group="exercise"
   keep_evaluating="y"
   match="something is wrong"
   omit_from_output="y"
   send_to="14"
   sequence="100"
  >
  <send>

Send ("look)  -- send to MUD

ColourNote ("white", "red", "something is wrong") -- send to output

SomethingWrong() -- call script

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


I wouldn't mix things around like this anyway - if you are calling a script function (SomethingWrong) why not just do everything in that?

In fact, if you are using send-to-script, then it is a bit confusing to have some scripting in the trigger, and some scripting somewhere else.

If you prefer to use a script file then do all your scripting in that, eg.


<triggers>
  <trigger
   enabled="y"
   group="exercise"
   keep_evaluating="y"
   match="something is wrong"
   omit_from_output="y"
   script="SomethingWrong"
   sequence="100"
  >
  </trigger>
</triggers>


Now by putting "SomethingWrong" in the Script box, the trigger itself doesn't need to send anything anywhere. Then in your script file, you can have this:


function SomethingWrong (name, line, wildcards, styles)

  Send ("look)  -- send to MUD

  ColourNote ("white", "red", "something is wrong") -- send to output

  -- other stuff  here

end -- function



See http://mushclient.com/scripting - that explains scripting in a fair bit of detail.
Amended on Wed 29 Jul 2009 09:26 PM by Nick Gammon
#2
Yes, the GUI interface will be complicated.