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
➜ Lua
➜ PluginID from different window?
PluginID from different window?
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Blainer
(191 posts) Bio
|
Date
| Wed 27 May 2009 06:42 AM (UTC) Amended on Wed 27 May 2009 07:10 AM (UTC) by Blainer
|
Message
| How do I get a plugin ID from a plugin installed in a different window than the plugin requesting the ID?
OR how do I reference a function in a plugin installed in a different window?
I have a plugin on my main window (the one connected to the MUD) which generates hyperlinked lists and outputs them to another window. If I try to make the hyperlinks just a simple send command the command goes to the window with the list and not the main window. If I do a Main_Window:Send("command") as the hyperlink nothing happens. I think the variable containing the world (Main_Window) can't be seen from the list window.
I really want to keep this as one plugin on the main window but haven't found a way yet.
| Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #1 on Wed 27 May 2009 09:05 PM (UTC) |
Message
| Each world has its own script space, so a variable in one world (like Main_Window) won't be visible in another.
If the hyperlink is sending something that is scripted, then the subsidiary world could find the variable for the main world by doing GetWorldById.
http://www.gammon.com.au/scripts/doc.php?function=GetWorldById |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Blainer
(191 posts) Bio
|
Date
| Reply #2 on Thu 28 May 2009 06:00 AM (UTC) |
Message
|
Main_Window = get_a_world ("Aardwolf","Aardwolf")
Click_List_Window = get_a_world ("Info_Window","Aardwolf")
command="north"
w=GetWorldIdList ()
w=w[1]
Click_List_Window:Hyperlink(w .. ":Send(\"" .. command .. "\")", command, command, "limegreen", "black", false)
The above code is in a plugin installed in "Main_Window" the first window. I am using the WorldID for the send command for the Hyperlink. But no matter what I put in as the place to send the command be it the Main_World variable or the w variable it won't work. The only way I can get a Hyperlink command to work is with the PluginID, calling a function from within a plugin that must be installed in the window displaying the Hyperlink.
Thanks for help Nick. | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #3 on Thu 28 May 2009 06:37 AM (UTC) Amended on Thu 28 May 2009 06:38 AM (UTC) by Nick Gammon
|
Message
| It's a bit hard to get a second world to send everything to the first (main) world without adding *something* to it. The simplest thing is probably this small plugin I wrote a while back for this sort of situation:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient [
<!ENTITY world_name "Aardwolf" >
]>
<!-- Saved on Sunday, June 22, 2008, 11:53 AM -->
<!-- MuClient version 4.29 -->
<!-- Plugin "Send_Input_To_Main_World" generated by Plugin Wizard -->
<muclient>
<plugin
name="Send_Input_To_Main_World"
author="Nick Gammon"
id="703dbfca1548310658c386a2"
language="Lua"
purpose="Redirects typing to the main world"
date_written="2008-06-22 11:02:24"
requires="4.29"
version="1.0"
>
</plugin>
<!-- Aliases -->
<aliases>
<alias
match="*"
enabled="y"
send_to="12"
sequence="100"
>
<send>
require "getworld"
w = get_a_world ("&world_name;")
if w:GetWorldID () == GetWorldID () then
ColourNote ("white", "red",
"Cannot use Send_Input_To_Main_World plugin on main world")
EnablePlugin (GetPluginID (), false)
return
end -- if
if w then
w:Execute [====[%1]====]
w:Activate ()
end -- if world exists
</send>
</alias>
</aliases>
</muclient>
Change the world_name in the 3rd line to match your world (well it looks like it is Aardwolf anyway, so no changes required).
Now with this plugin installed in your hyperlink window, the hyperlinks will send to the secondary world, the alias will match, and redirect the input to your main world.
I used something like this to make a world full of hyperlinks myself. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Blainer
(191 posts) Bio
|
Date
| Reply #4 on Thu 28 May 2009 07:00 AM (UTC) |
Message
| Hey thats a much better solution than my plugin that only handled Hyperlinks.
I'll post my Hyperlink window plugin when it's finished so we can compare. ;)
Thanks Nick | 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.
15,112 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top