+ Reply to Thread
Results 1 to 8 of 8

Thread: Two Questions about Initialization/Startup

  1. #1
    Rift Disciple Oort's Avatar
    Join Date
    Feb 2011
    Posts
    129

    Default Two Questions about Initialization/Startup

    I'm dipping a toe into the addon waters writing a small mod that needs to query for an ability and some reagents.

    I've got an Event.AddOn.Load.End event that I am using to trigger my initialization routine.

    However, during this event,

    local abilityList = Inspect.Ability.New.List()

    returns nil

    and

    local inventoryList = Inspect.Item.List(Utility.Item.Slot.All())

    doesn't list all the bag contents (I wasn't using .All at first, but I only was getting the list of bags).

    Is there another event that occurs later in login that I can use to get these abilities after they've been successfully populated?

    Thanks.

  2. #2
    Shield of Telara Adelea's Avatar
    Join Date
    Mar 2011
    Posts
    734

    Default

    There are something that are available at certain times during a fresh login, but not a /reloadui.

    The most reliable way I have found is :

    Code:
    local addon, data = ...
    
    function data.Event_Unit_Availability_Full(h,t)
    	for k,v in pairs(t) do
    		if v == "player" then
    			Command.Event.Detach(Event.Unit.Availability.Full, nil, nil, nil, addon.identifier)
    			-- do more stuff
    		end
    	end
    end
    
    Command.Event.Attach(Event.Unit.Availability.Full, data.Event_Unit_Availability_Full, "Event.Unit.Availability.Full")
    http://forums.riftgame.com/image.php?type=sigpic&userid=125779&dateline=13553  38065

  3. #3
    Rift Disciple Oort's Avatar
    Join Date
    Feb 2011
    Posts
    129

    Default

    Thank you for that -- it did the trick for me. And then time passed and stuff got in the way, but I finally spent some more time on my little toe-dipper and am up for my next challenge.

    I have a couple of events that I was to trigger screen flashes. I've gotten the events working and they are currently dumping text to the chat window. However, what I'd like is to flash the screen border a color, i.e., red for when the ability goes on CD and green when it comes off -- perhaps like the KBM interrupt flash.

    I've poked at the KBM and kalert code to see how they do it (I hope I'm not violating some unspoken rule of not reverse engineering to learn!) and am finding it quite complex. Is there any simple API magic to flash the window once or twice?

    Or should I plan to dissect addons to figure it out?

    Thanks again.

  4. #4
    Shield of Telara Adelea's Avatar
    Join Date
    Mar 2011
    Posts
    734

    Default

    I cant speak for anyone else, but back when I was first getting to grips with addons, looking at someone elses code to figure out how things were done was pretty common - I would then credit them in the changelog.

    For the screen flash, the way I would do it is:

    display the border effect and set a flag to indicate it was active - with a value of true or Inspect.Time.Real()
    create an event handler for Event.System.Update.Begin, and check to see if the flag was non-false - then either cancel it immediatley, or do another Inspect.Time.Real() and compare with the saved value to see if enough time had passed.
    http://forums.riftgame.com/image.php?type=sigpic&userid=125779&dateline=13553  38065

  5. #5
    Rift Disciple Oort's Avatar
    Join Date
    Feb 2011
    Posts
    129

    Default

    Going back to the original question, your solution worked for me for logging in the first time, but when I reloadui, the inventory scan is coming up empty.

    I'm looking for a solution (i.e., splitting my initialization across multiple events), but I noticed there's a moderation lag posting to this forum, so I'm getting this note out now.

  6. #6
    Rift Disciple Oort's Avatar
    Join Date
    Feb 2011
    Posts
    129

    Default

    Nevermind. Solved the problem using SavedVariables to store the value so it's available on startup and Event.Unit.Detail.LocationName to trigger an update (checking the number of an item in inventory).

  7. #7
    Rift Disciple Oort's Avatar
    Join Date
    Feb 2011
    Posts
    129

    Default

    Currently trying to figure out how to handle tracking the CD of an inventory item.

    I'm looking at Teleporter (since I know it does that) and see it uses LibInventory, which likely is my way to go.

    My only concern is that libInventory is consistently at the top of my usage percentage, often over 15%, on the system tooltip.

  8. #8
    Shield of Telara Adelea's Avatar
    Join Date
    Mar 2011
    Posts
    734

    Default

    There is no event that signals an item going on or coming off cooldown - so if you want to know this, you have to actively look for it.

    I had several addons that were doing this (Teleporter being one of them), so ended up moving the code to a library (libInventory), and providing a means to get cooldown updates.

    LibInventory does full inventory scans periodically to catch when items go on/off cooldown - that is the cause of the constant activity - though for me, the usage hovers around 5%

    The thought/hope was that doing these full scans for cooldowns in one place had to be more efficient than doing it in every addon that needed to do it.

    It only runs the scan if the watchdog has a decent amount of time left, and the last check happened more than 0.2s ago.
    http://forums.riftgame.com/image.php?type=sigpic&userid=125779&dateline=13553  38065

+ 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