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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Bug reports
. . -> [Subject]  GetWorld, GetWorldByID from plugin... returns plugin 'world' object.

GetWorld, GetWorldByID from plugin... returns plugin 'world' object.

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


Pages: 1 2  

Posted by Worstje   Netherlands  (899 posts)  [Biography] bio
Date Tue 08 Jan 2008 09:33 PM (UTC)
Message
I wanted to loop through the triggers and aliases of the world my plugin is running in. However, I -always- get the same world object returned from GetWorld and GetWorldByID as the plugin itself 'lives' in, which means I can't find out about this information in any way. I can however request this info from any other world fine.

I'm using Lua btw, in case it may be a bug with the Lua specific implementation.
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Tue 08 Jan 2008 11:59 PM (UTC)
Message
I don't quite understand the problem. Are you specifying a different world to the one the plugin runs in?

Judging by the code, the Lua function should return a userdatum which is the world matching the name, not the calling world.

You said you want the "triggers and aliases of the world my plugin is running in" - in that case don't you want the world object the plugin lives in?

- 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 #2 on Wed 09 Jan 2008 05:12 AM (UTC)
Message
The other thing to check is how you are using the world object. In Lua, you should be doing something like this:


w = GetWorld ("someworld")

w:Note ("hi there")   -- do note to someworld's window


http://www.gammon.com.au/scripts/doc.php?function=GetWorld

Check the world userdatum is not nil, or it is likely to simply refer to the current world.


- Nick Gammon

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

Posted by Worstje   Netherlands  (899 posts)  [Biography] bio
Date Reply #3 on Wed 09 Jan 2008 09:50 AM (UTC)

Amended on Wed 09 Jan 2008 09:54 AM (UTC) by Worstje

Message
Actually, I use Function(w, param1, param2, ...). But that doesn't matter, so I'll use the w: notation for clarity here.

Say my plugin was loaded in the world with name 'myworld'. I use w = world.GetWorld("myworld") to get a reference to this world in my plugin. If I then try to use w:GetTriggerList, w:GetTriggerInfo etc. I get exactly the same responses as if I'd called world.GetTriggerList() and world.GetTriggerInfo() -- the trigger information of the plugin itself. However, if I try to do the exact same thing for a world with name 'anotherworld', I get the trigger data belonging to the world.

Same thing goes for aliases.

> You said you want the "triggers and aliases of the world my
> plugin is running in" - in that case don't you want the
> world object the plugin lives in?

That's one confusing sentence. But aye, I think that is correct. I want the world object of the main script file, rather than the world object of the plugin. Similarly to how it works for other unrelated worlds.
[Go to top] top

Posted by Ked   Russia  (524 posts)  [Biography] bio
Date Reply #4 on Wed 09 Jan 2008 01:48 PM (UTC)
Message
That's not a bug - it works just as documented.

From documentation for GetTriggerList:

Quote:
If GetTriggerList is called from within a plugin, the triggers for the current plugin are used, not the "global" MUSHclient triggers.

If you want to find the list of triggers in another plugin, or the global MUSHclient triggers, use "GetPluginTriggerList".


When your plugin gets the world object for the world it is loaded in it receives just that - the same thing as what is bound to the global 'world' object, and calling methods on this returned object should behave in exactly the same way as calling them on the "default" world object. Which it does.
[Go to top] top

Posted by Worstje   Netherlands  (899 posts)  [Biography] bio
Date Reply #5 on Wed 09 Jan 2008 02:55 PM (UTC)

Amended on Wed 09 Jan 2008 03:07 PM (UTC) by Worstje

Message
That is.. silly. I could have sworn I read that help file, too. Thanks for pointing that out, Ked.

On another note, it still feels mightily odd to me. GetWorld() is what I always considered a scope changer - get the world object as it would look like for that worlds scriptfile, minus the oddities with GetTriggerList() and all pointing to the plugin specific stuff.

/me goes to write exceptions for when the current world-object is passed.

Edit: Yay, next problem. There is no GetPlugin(Alias|Trigger|Timer)Option function, so I can't check whether something of my own world is enabled. Or plugins for that matter, assuming this script ever gets expanded upon.
[Go to top] top

Posted by Ked   Russia  (524 posts)  [Biography] bio
Date Reply #6 on Wed 09 Jan 2008 03:40 PM (UTC)
Message
There's the GetPluginTriggerInfo(), which is pretty much the same thing.
[Go to top] top

Posted by Worstje   Netherlands  (899 posts)  [Biography] bio
Date Reply #7 on Wed 09 Jan 2008 06:54 PM (UTC)
Message
Stop making me feel like an idiot. :( This just is not my set of days.

However.. I recall an issue I had ages ago with needing *Option over *Info because I couldn't get to it with *Info. And now that I'm writing about it, I remember again. The multi_line and lines_to_match options were what I was looking for, and unless I'm totally out my league reading through the list in GetTriggerInfo(), I'd still be unable to find out whether my worlds triggers are multi_lines. Right now, I don't need it... but who knows about the future? :)
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #8 on Wed 09 Jan 2008 08:41 PM (UTC)
Message
Quote:

On another note, it still feels mightily odd to me. GetWorld() is what I always considered a scope changer - get the world object as it would look like for that worlds scriptfile, minus the oddities with GetTriggerList() and all pointing to the plugin specific stuff.


If you use:


w = GetWorld ("someworld")
l = w:GetTriggerList ()


Then you should get the trigger list for the nominated world, and if the nominated world has a current plugin, then that plugin's trigger list. If the nominated world is the current world, then overriding with the w: does not change the way GetTriggerList works - it still checks if there is a current plugin.

Quote:

There is no GetPlugin(Alias|Trigger|Timer)Option function ...


I suppose that could be added without too much trouble if it was required.

However considering that GetPluginTriggerInfo will answer *most* of your questions, the requirement to find exactly how many lines (say) a multi-line trigger uses, in a different plugin, seems a bit obscure. Plugins are really supposed to be self-contained "black boxes".

- Nick Gammon

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

Posted by Worstje   Netherlands  (899 posts)  [Biography] bio
Date Reply #9 on Wed 09 Jan 2008 09:47 PM (UTC)
Message
Quote:

However considering that GetPluginTriggerInfo will answer *most* of your questions, the requirement to find exactly how many lines (say) a multi-line trigger uses, in a different plugin, seems a bit obscure. Plugins are really supposed to be self-contained "black boxes".


It's for a 'yours-is-bigger-than-mine' contest. Or to be precise, I'm a numbers freak. I like the idea of loading a plugin, enter a command, and have a pretty table of how highly taxed an actual world is, by showing all the plugins, triggers and other statistics that could negatively impact performance.

Of course, this only became interesting after I wrote a bunch of scripts to add 1390 triggers to one of my plugins, bringing its triggercount 2090, of which 1950 are enabled by default. Multi-line, checks for welformedness of triggers and other stuff to optimize performance are a good plus now.
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #10 on Wed 09 Jan 2008 10:16 PM (UTC)
Message
I have added those 3 script routines to version 4.21.

- 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 #11 on Wed 09 Jan 2008 10:17 PM (UTC)
Message
Quote:

I wrote a bunch of scripts to add 1390 triggers to one of my plugins, bringing its triggercount 2090, of which 1950 are enabled by default.


How *is* performance, BTW?

- Nick Gammon

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

Posted by Worstje   Netherlands  (899 posts)  [Biography] bio
Date Reply #12 on Wed 09 Jan 2008 10:58 PM (UTC)

Amended on Wed 09 Jan 2008 11:01 PM (UTC) by Worstje

Message
Strangely decent. :D

Biggest problem is the fact I only have 512MB of RAM on a 2.5 years old Athlon64, which means a lot of swapping combined with the fact I tend to have three worlds open at once (two of which have that mega-plugin) and memoryhogger Firefox and Trillian.

I guess it takes around 0.1-0.2s to process an incoming line, but it is hard to say. I just ran a test with my prompt repeated 20 times using test trigger, and these are the results (timestamps from a plugin). Given that my prompt is the most heavily triggered, I figure it should be the best benchmark:

[4000] [3000] E100 W100 [db eb] 44:3.29 -
[4000] [3000] E100 W100 [db eb] 44:3.64 -
[4000] [3000] E100 W100 [db eb] 44:3.89 -
[4000] [3000] E100 W100 [db eb] 44:3.113 -
[4000] [3000] E100 W100 [db eb] 44:3.154 -
[4000] [3000] E100 W100 [db eb] 44:3.208 -
[4000] [3000] E100 W100 [db eb] 44:3.249 -
[4000] [3000] E100 W100 [db eb] 44:3.273 -
[4000] [3000] E100 W100 [db eb] 44:3.290 -
[4000] [3000] E100 W100 [db eb] 44:3.326 -
[4000] [3000] E100 W100 [db eb] 44:3.343 -
[4000] [3000] E100 W100 [db eb] 44:3.387 -
[4000] [3000] E100 W100 [db eb] 44:3.416 -
[4000] [3000] E100 W100 [db eb] 44:3.433 -
[4000] [3000] E100 W100 [db eb] 44:3.512 -
[4000] [3000] E100 W100 [db eb] 44:3.529 -
[4000] [3000] E100 W100 [db eb] 44:3.550 -
[4000] [3000] E100 W100 [db eb] 44:3.567 -
[4000] [3000] E100 W100 [db eb] 44:3.586 -
[4000] [3000] E100 W100 [db eb] 44:3.603 -

But even then, I am not sure how reliable the results are since this input is rather predictable.

Edit1: Oh, and clearly it is less than what I thought. Woo.

Edit2: I completely missed your first message. Thanks, that's going to be useful! If I ever finish this statistics thing, I'll send it your way. For now though, it needs a lot of cleaning up and adding features, since its core is pretty much an ugly version translated from Python when I started scripting... but I am lazy too, and it works. Hrm...
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #13 on Thu 10 Jan 2008 12:39 AM (UTC)
Message
I have added some extra debugging stuff in version 4.21, available from GetInfo (see release notes) that will let you see how many triggers/aliases are being evaluated. This could be interesting, as you might have 2000 triggers, but it evaluates 1000 before one fires.

This version is now available.

- Nick Gammon

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

Posted by Worstje   Netherlands  (899 posts)  [Biography] bio
Date Reply #14 on Thu 10 Jan 2008 02:19 AM (UTC)
Message
Whoa, that's awesome. I guess I'm not the only numbers freak then, eh? :D

(That and I guess it makes this time for another benchmarking spree? The most recent benchmarks I've found of mud clients in general are old to say the least.. :) More stuff to compare, yay!)
[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.


46,082 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

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]