+ Reply to Thread
Results 1 to 9 of 9

Thread: [dev tool] RiftRC -- it's a login script!

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

    Default [dev tool] RiftRC -- it's a login script!

    http://www.riftui.com/downloads/info199-RiftRC.html

    RiftRC lets you write a single block of lua code which gets evaluated at login. That's it.

    What's this for? Say you're debugging an addon. Wouldn't it be nice to have some stuff like

    Code:
    d = Inspect.Addon.Detail('myaddon').data
    function runit()
    for i, v in pairs(d.scans) do
    ...
    end
    end
    so you could log in and just /script runit instead of trying to run that stuff? Oh, yes, yes it would. That would be awesome.

    (Note: For "log in", read also "reload UI".)

    DISCLAIMER: I can't figure out how to handle arrow keys, so they basically work on each line as though it were a completely separate thing.
    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
    RIFT Community Ambassador the_real_seebs's Avatar
    Join Date
    Jan 2011
    Posts
    16,859

    Default

    Added a display of the return value of the script (if any).
    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!)

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

    Default

    Code:
    local function __OOP_TEST()
       -- lots of tests and specs here
    end
    
    table.insert(Event.Addon.Load.End, { __OOP_TEST, "libTea", "OOP Test" })
    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.

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

    Default

    Unfortunately, that probably won't work, since I don't execute the stashed stuff until AFTER event.addon.load.end.

    Hmm.

    Which might or might not work, but I would expect not because the iterator was probably started before... huh. Dangerous. Don't do that.
    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!)

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

    Default

    Why would that NOT work? I've been testing everything I coded so far like that. Note that the event is called AFTER my addon is loaded; which is only if my addon didn't crash of any syntax errors or the likes.

    Least of all it's dangerous, don't say such stuff. :P
    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.

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

    Default

    The reason it might be a problem is that run_rc is originally called from a handler for Event.Addon.Startup.End.

    I am assuming that somewhere in the system code, there's a loop roughly like:

    Code:
    for idx, tab in ipairs(Event.Addon.Startup.End) do
      BillCPUTo(tab[2], tab[3])
      tab[1]()
    end
    tab(1) is the provided function, which in my case does a loadstring and then tries to execute your code.

    So you end up with something like:

    Code:
    for idx, tab in ipairs(Event.Addon.Startup.End) do
      if idx == 1 then
        table.insert(Event.Addon.Startup.End, { another_table })
      end
    end
    and modifying an array while traversing it is Bad Juju.
    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!)

  7. #7
    Plane Walker Imhothar's Avatar
    Join Date
    Feb 2012
    Posts
    439

    Default

    Don't forget Event.Addon.Load.End is raised once for every addon, not just yours. You got to check the first argument if it matches your addon identifier, otherwise you could end up trying to run code before your addon is loaded.

    Event.Addon.Startup.End is more reliable for initialization stuff (assuming your addon loads fine) as it definitly triggers only once.
    Last edited by Imhothar; 03-03-2012 at 11:45 AM.

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

    Default

    Quote Originally Posted by Imhothar View Post
    Don't forget Event.Addon.Load.End is raised once for every addon, not just yours. You got to check the first argument if it matches your addon identifier, otherwise you could end up trying to run code before your addon is loaded.
    But this is Event.Addon.Startup.End, which is called only once.
    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
    RIFT Community Ambassador the_real_seebs's Avatar
    Join Date
    Jan 2011
    Posts
    16,859

    Default

    Updates galore! Named snippets, lots of them, which are saved. You can run them from the command line; if you have a snippet "foo" containing "return 3", then

    /rc -r foo

    will print

    [RiftRC] 3

    And this is smart about tables and stuff.
    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

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