Echoing text from one window to anoter

Posted by Meekah on Thu 10 Apr 2003 10:44 PM — 9 posts, 33,260 views.

USA #0
I know this would use getworld, I just can not seem to grasp how to do this, and I am very new to scripting...

what I want to do is have certain text from one world sent to the other world as a note.

ie. in world 1 I see:
Sally tells you something

in world 2 I would like to see:
note:Sally told world1 something


I already have a trigger that sends the line to a notepad window, but it would be really useful if I could see it on the other character without having to constantly flip back and forth on new activity which is oftimes what I already see.

If someone could explain (in easy to understand or paste format) how to do this, I would be very grateful

Thank you in advance.
Australia Forum Administrator #1
Take a look at GetWorld - the example there under JScript shows exactly what you need to do.
USA #2
I did that and it's working to some degree, I had to put the world name as the label for the trigger that is being called to get it to work, which means it will only work on one trigger (and i need it to work on 3)

Is there somewhere in the script itself that I am supposed to put the name of the world to send to?
Australia Forum Administrator #3
The script was an example of calling it from JScript, not a trigger directly. To call it from a trigger you would need an interface, like this for example:


function OnTell (strTriggerName, strOutput, wildcardsVB)
{
  wildcards = VBArray(wildcardsVB).toArray();	
  SendToWorld ("name_of_other_world", wildcards [0]);
}


This assumes your trigger has the text to be sent in the first wildcard.

Amended on Sat 12 Apr 2003 07:10 AM by Nick Gammon
USA #4
*sigh*
Ok, I still can't get it to work

the trigger I have is this:

Trigger: * tells you*
Send: %1 tell %2
Send to: notepad (append)
Label: tells_world1
Script: Ontells_world1

and the way i did the script was:

function Ontells_world1 (strTriggerName, strOutput, wildcardsVB)
{
wildcards = VBArray(wildcardsVB).toArray();
world.note ("World2", wildcards [0]);
}

and the error i get is:

Error number: -2146827838
Event: Execution of line 4 column 3
Description: Wrong number of arguments or invalid property assignment
Called by: Function/Sub: Ontells_world1_TR called by trigger
Reason: processing trigger "Ontells_world1_TR "


was there something else i was supposed to change in the example you gave? I'm sorry for sounding so dense but this is the first time I've really played with the scripting before.


Australia Forum Administrator #5
But you haven't copied what I suggested. In the second line of the two-line function I had:

SendToWorld ("name_of_other_world", wildcards [0]);

You have:

world.note ("World2", wildcards [0]);

The script function world.note only takes one argument - the thing to be noted. The error message says you have the wrong number of arguments.
Australia Forum Administrator #6
Another approach you could take, if you have version 3.35 or 3.36 is to execute the code directly from the trigger window. However, this will fail if the trigger matching text has double-quotes in it - because the double quotes cause the script to fail (it is quotes inside quotes).

However to illustrate the idea, here it is:


<triggers>
  <trigger
   custom_colour="2"
   enabled="y"
   match="* tells you*"
   send_to="12"
   sequence="100"
  >
  <send>if (otherworld = world.getworld (&quot;World2&quot;))
  otherworld.Note(&quot;%1 tells you %2&quot;);</send>
  </trigger>
</triggers>


What this does is "send to script" to directly execute the script, rather than having to call a script routine. The problem is that the script lines look like this (when you convert &quot; to "):


if (otherworld = world.getworld ("World2"))
  otherworld.Note("%1 tells you %2");


When the trigger match routine replaces %1 and %2 with the matched text, if they happen to have a double-quote in them, then you get too many quotes in the Note line.

Thus, the method we were talking about would be safer, however if your example was a bit different, and you were sure there would not be double-quotes in the matching text, then this method is shorter and simpler.
Amended on Sat 12 Apr 2003 11:08 PM by Nick Gammon
Australia Forum Administrator #7
Version 3.37 of MUSHclient will fix that problem by automatically "escaping" strings inside wildcards when you "send to script" so you can use wildcards directly in triggers regardless of whether or not they contain quotes.
USA #8
Thanks it works for the most part with the 3.36 version
as long as no one puts a double quote in there anyway :)

Thanks ever so much :)