+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 15 of 35

  Click here to go to the first Rift Team post in this thread.   Thread: Exposing addons to other things that want them?

  1. #1
    RIFT Community Ambassador the_real_seebs's Avatar
    Join Date
    Jan 2011
    Posts
    16,859

    Default Exposing addons to other things that want them?

    Is there a good way to make addons available without massive global namespace pollution?

    Like, say I want to make a table available. Obviously I can just use savedvariables, which are global by default (semi-eww), but... What next?

    It seems like it might be really handy to have some kind of way of registering things we intend to expose.

    Does the addon system enforce any kind of name-uniqueness among addons? If so, maybe that could be used to give us a mechanism for looking up another addon's public interface.

    ... I'm betting I've just missed something obvious, though.
    You can play WoW in any MMO. You don't have to play WoW in RIFT. Oh, and no, RIFT is not a WoW clone. Not having fun any more? Learn to play, noob! I don't speak for Riftui, but I moderate stuff there. Just came back? Welcome back! Here's what's changed. (Updated for 2.5!)

  2. #2
    Plane Touched Verea's Avatar
    Join Date
    Feb 2011
    Location
    Netherlands
    Posts
    200

    Default

    libTea offers library features that do not spam globals. Works much like this:

    Code:
    local lib = Tea.Library.register:("YourLibrary-1.0", 20) -- major + minor
    lib.* can now be used to hook events to.
    Other libraries can call:

    Code:
    local libYourLib = Tea.Library.load("YourLibrary-1.0")
    It also supports versioning, let's say multiple addons embed your Library, Tea.Library.load("YourLibrary1.0") will always be the latest minor version.
    Last edited by Verea; 03-01-2012 at 04:51 PM.
    Verae, level 60 Cleric @ Blightweald, Guild Master of Tea Club
    I want to fly like an eagle, to the sea.
    I want to fly like an eagle, let my spirit carry me.

  3. #3
    RIFT Community Ambassador the_real_seebs's Avatar
    Join Date
    Jan 2011
    Posts
    16,859

    Default

    Note that the existing addon API already does that for multiple embedded versions of the same library. Zorba thought ahead.
    You can play WoW in any MMO. You don't have to play WoW in RIFT. Oh, and no, RIFT is not a WoW clone. Not having fun any more? Learn to play, noob! I don't speak for Riftui, but I moderate stuff there. Just came back? Welcome back! Here's what's changed. (Updated for 2.5!)

  4. #4
    Plane Touched Verea's Avatar
    Join Date
    Feb 2011
    Location
    Netherlands
    Posts
    200

    Default

    You sure it has versioning support though?
    Verae, level 60 Cleric @ Blightweald, Guild Master of Tea Club
    I want to fly like an eagle, to the sea.
    I want to fly like an eagle, let my spirit carry me.

  5. #5
    RIFT Community Ambassador the_real_seebs's Avatar
    Join Date
    Jan 2011
    Posts
    16,859

    Default

    Quote Originally Posted by Verea View Post
    You sure it has versioning support though?
    So Zorba has told us, yes.
    You can play WoW in any MMO. You don't have to play WoW in RIFT. Oh, and no, RIFT is not a WoW clone. Not having fun any more? Learn to play, noob! I don't speak for Riftui, but I moderate stuff there. Just came back? Welcome back! Here's what's changed. (Updated for 2.5!)

  6. #6
    Plane Touched Verea's Avatar
    Join Date
    Feb 2011
    Location
    Netherlands
    Posts
    200

    Default

    I'll have to look into that then.
    Verae, level 60 Cleric @ Blightweald, Guild Master of Tea Club
    I want to fly like an eagle, to the sea.
    I want to fly like an eagle, let my spirit carry me.

  7. #7
    Sword of Telara Semele's Avatar
    Join Date
    Mar 2011
    Posts
    872

    Default

    KBM and my associated addons use the recently introduced internal data-space.

    Code:
    local AddonData = Inspect.Addon.Detail("addon-you-want-here")
    local Addons_DataTable = AddonData.data
    Hope this helps
    Rank 76 Guardian Mage

  8. #8
    RIFT Community Ambassador the_real_seebs's Avatar
    Join Date
    Jan 2011
    Posts
    16,859

    Default

    Ohhh.

    I even sort of knew about that, I just hadn't realized that it... yeah.

    That's pretty much exactly what I wanted.

    One question, though, while I'm asking obvious questions:

    "data" is "The "data" table provided to the addon at load time."

    How is that data table provided to the addon? Like, if I wanted to store a thing in that table, without calling Inspect.Addon.Detail(my-id), how would I refer to it? It appears to be empty.
    You can play WoW in any MMO. You don't have to play WoW in RIFT. Oh, and no, RIFT is not a WoW clone. Not having fun any more? Learn to play, noob! I don't speak for Riftui, but I moderate stuff there. Just came back? Welcome back! Here's what's changed. (Updated for 2.5!)

  9. #9
    Sword of Telara Semele's Avatar
    Join Date
    Mar 2011
    Posts
    872

    Default

    What I do is have my addons add a table to that table (or multiple tables). You could even have an index of Table ID's etc. Think of it as internal shared memory where the initial table is .data then have a master table with any sub-tables branch down from there.

    So, for KBM for example.

    Code:
    local AddonData = Inspect.Addon.Detail("KingMolinator")
    local KBM = AddonData.data
    I simply make my main program table containing all variables and functions use .data as the lead table. But you could also do.

    Code:
    local AddonData = Inspect.Addon.Detail("KingMolinator")
    local MyAddon = AddonData.data
    MyAddon.Functions = {}
    MyAddon.Settings = {}
    Pretty much free to do anything

    MyAddon would be a local reference for your addon, but other addons could then inspect say "KingMolinator" and have their own reference to the same table and share data and even add to the list of available functions/settings and extra references opening up dynamic plug-ins for addons (like KBM Mark-It and KBM AddWatch)

    Really awesome feature.
    Rank 76 Guardian Mage

  10. #10
    RIFT Community Ambassador the_real_seebs's Avatar
    Join Date
    Jan 2011
    Posts
    16,859

    Default

    It is, I'm just wondering whether there's a way to get to my own data table other than calling inspect.addon.detail on myself.
    You can play WoW in any MMO. You don't have to play WoW in RIFT. Oh, and no, RIFT is not a WoW clone. Not having fun any more? Learn to play, noob! I don't speak for Riftui, but I moderate stuff there. Just came back? Welcome back! Here's what's changed. (Updated for 2.5!)

  11. #11
    Plane Touched Verea's Avatar
    Join Date
    Feb 2011
    Location
    Netherlands
    Posts
    200

    Default

    It doesn't seem to have support for versioning though, that would cause problems with multiple embedded libraries. So I guess libTea's library functions will make sense for the time being.
    Verae, level 60 Cleric @ Blightweald, Guild Master of Tea Club
    I want to fly like an eagle, to the sea.
    I want to fly like an eagle, let my spirit carry me.

  12. #12
    RIFT Community Ambassador the_real_seebs's Avatar
    Join Date
    Jan 2011
    Posts
    16,859

    Default

    If I understand what Zorba previously told us, the addon system finds ALL the addons, including embedded ones, then picks the most recent version of any given name and loads that one instead of any others. This certainly fits my debugging experience when I have multiple addons referring back to a single library; I always get the newest one for everything, whether I want it or not.
    You can play WoW in any MMO. You don't have to play WoW in RIFT. Oh, and no, RIFT is not a WoW clone. Not having fun any more? Learn to play, noob! I don't speak for Riftui, but I moderate stuff there. Just came back? Welcome back! Here's what's changed. (Updated for 2.5!)

  13. #13
    Plane Touched
    Join Date
    Feb 2012
    Posts
    228

    Default

    That's what I don't like about library embedding, you can't rely that their behaviour will be the same that when you embedded them, as any third party addon could embed a higher version of the library that changes that behaviour.

    Imagine you include sorting capabilities in your LibEnfiltrate library (I haven't checked if it already has that) and you use a stable sorting algorithm. I then decide to embed your library and my code relies on that behaviour. Then you decide to change the sorting algorithm to another one that is faster but isn't stable anymore. Knowing that using the latest version of your library will mess with my addon implementation, I wouldn't want to upgrade to that version, but the addon system would do it for me if a third party addon embedded the latest version, as you say, whether I want it or not.

  14. #14
    Rift Chaser
    Join Date
    Oct 2011
    Posts
    398

    Default

    Quote Originally Posted by Baanano View Post
    That's what I don't like about library embedding, you can't rely that their behaviour will be the same that when you embedded them, as any third party addon could embed a higher version of the library that changes that behaviour.

    Imagine you include sorting capabilities in your LibEnfiltrate library (I haven't checked if it already has that) and you use a stable sorting algorithm. I then decide to embed your library and my code relies on that behaviour. Then you decide to change the sorting algorithm to another one that is faster but isn't stable anymore. Knowing that using the latest version of your library will mess with my addon implementation, I wouldn't want to upgrade to that version, but the addon system would do it for me if a third party addon embedded the latest version, as you say, whether I want it or not.
    Agreed. I don't see much benefit per-addon benefit to using the latest version found of an embedded library. It may help keep resources a bit lighter, but there seems to be so much potential for screwing over your addon based purely on a third party addon; and that is quite difficult to debug.

    In terms of addon globals : I really wish that there was some sort of default required encasement method that Zorba made available to all addon authors. Requiring addon authors to store all addon data/etc in a way that makes none of it conflict with other addons - at least without the specified permission of another addon.

    (I tried to apply this principal in LibSlashCmd - no matter what any other addons are doing, LibSlashCmd will make sure your slash command is available and working.)
    Last edited by TimeBomb; 03-02-2012 at 03:02 AM.

  15. #15
    RIFT Community Ambassador the_real_seebs's Avatar
    Join Date
    Jan 2011
    Posts
    16,859

    Default

    Quote Originally Posted by Baanano View Post
    That's what I don't like about library embedding, you can't rely that their behaviour will be the same that when you embedded them, as any third party addon could embed a higher version of the library that changes that behaviour.

    Imagine you include sorting capabilities in your LibEnfiltrate library (I haven't checked if it already has that) and you use a stable sorting algorithm. I then decide to embed your library and my code relies on that behaviour. Then you decide to change the sorting algorithm to another one that is faster but isn't stable anymore. Knowing that using the latest version of your library will mess with my addon implementation, I wouldn't want to upgrade to that version, but the addon system would do it for me if a third party addon embedded the latest version, as you say, whether I want it or not.
    The solution, roughly, is:

    Don't release a breaking change to an addon without changing its name.

    When I feel that these are really stable enough that people could reasonably rely on their behaviors, I will probably start giving them -N names, such that LibEnfiltrate-1 is promised not to break the defined API. (And if you rely on things I didn't promise, that is Own Fault.)

    Note that there's a cheap workaround: Rename your local copy. Conveniently, I permit you to do stuff like that if you need to.
    You can play WoW in any MMO. You don't have to play WoW in RIFT. Oh, and no, RIFT is not a WoW clone. Not having fun any more? Learn to play, noob! I don't speak for Riftui, but I moderate stuff there. Just came back? Welcome back! Here's what's changed. (Updated for 2.5!)

+ Reply to Thread
Page 1 of 3 1 2 3 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts