Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Jscript
➜ 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 page
| Posted by
| Meekah
USA (16 posts) 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.
| | Top |
|
| Posted by
| Nick Gammon
Australia (23,165 posts) 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 | | Top |
|
| Posted by
| Meekah
USA (16 posts) 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? | | Top |
|
| Posted by
| Nick Gammon
Australia (23,165 posts) 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 | | Top |
|
| Posted by
| Meekah
USA (16 posts) 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.
| | Top |
|
| Posted by
| Nick Gammon
Australia (23,165 posts) 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 | | Top |
|
| Posted by
| Nick Gammon
Australia (23,165 posts) 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 ("World2"))
otherworld.Note("%1 tells you %2");</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 " 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 | | Top |
|
| Posted by
| Nick Gammon
Australia (23,165 posts) 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 | | Top |
|
| Posted by
| Meekah
USA (16 posts) 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 :) | | 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.
28,330 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top