[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Jscript
. . -> [Subject]  Echoing text from one window to anoter

Echoing text from one window to anoter

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Meekah   USA  (16 posts)  [Biography] bio
Date Thu 10 Apr 2003 10:44 PM (UTC)
Message
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.
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Fri 11 Apr 2003 12:15 AM (UTC)
Message
Take a look at GetWorld - the example there under JScript shows exactly what you need to do.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Meekah   USA  (16 posts)  [Biography] bio
Date Reply #2 on Fri 11 Apr 2003 11:09 PM (UTC)
Message
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?
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Sat 12 Apr 2003 07:09 AM (UTC)

Amended on Sat 12 Apr 2003 07:10 AM (UTC) by Nick Gammon

Message
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.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Meekah   USA  (16 posts)  [Biography] bio
Date Reply #4 on Sat 12 Apr 2003 10:13 PM (UTC)
Message
*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.


[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Sat 12 Apr 2003 10:48 PM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #6 on Sat 12 Apr 2003 11:07 PM (UTC)

Amended on Sat 12 Apr 2003 11:08 PM (UTC) by Nick Gammon

Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #7 on Sun 13 Apr 2003 02:44 AM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Meekah   USA  (16 posts)  [Biography] bio
Date Reply #8 on Sun 13 Apr 2003 01:22 PM (UTC)
Message
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 :)
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


20,859 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]