+ Reply to Thread
Results 1 to 4 of 4

Thread: Inspect.Unit.Detail information and question

  1. #1
    Soulwalker
    Join Date
    Nov 2015
    Posts
    2

    Default Inspect.Unit.Detail information and question

    Hey guys I have been creating my own addon for personal/guild use (similar to a Titan Bar in WoW) for general information such as current money, money gained, xp gained etc. At the moment I am trying to have my bar display current soul vitality and thus trying to get a grasp on the Inspect.Unit.Detail. Anyway here is the code I came up with

    Code:
    function getVitality()
    	local player = Inspect.Unit.Detail("player")
    	soulVitality = player.vitality
    	return soulVitality
    end
    My problem is I continuously get a nil value and I am not sure why. I assumed that the "player" is the unit I am referring to and player.vitality is the member I am trying to receive. So why do I continue to get a nil value? (even though I have 65 percent vitality)

    P.S. Credit will be give to user in the code comments
    Last edited by ItzRainingHP; 11-04-2015 at 07:23 AM.

  2. #2
    Sword of Telara
    Join Date
    Sep 2014
    Posts
    888

    Default

    I'm not especially experienced, but I can think of a couple of things that might be going a bit wrong.

    Firstly, unit availability. If the player is unavailable (this happens during loading screens) then the table returned Inspect.Unit.Detail will be missing certain fields, and vitality is probably one of them. Is the function ever working at all?

    Secondly, it's probably worth mentioning soulVitality isn't a local variable and might be getting referenced somewhere else, or you could be overwriting values from elsewhere. Then again I don't know enough about how Lua handles scoping to know whether it's a problem, but I'd not use that variable instead at all:

    Code:
    function getVitality()
         local player = Inspect.Unit.Detail("player")
         return player.vitality 
    end
    Spellbook@Greybriar
    Rejuvenation@Greybriar

  3. #3
    Soulwalker
    Join Date
    Nov 2015
    Posts
    2

    Default

    Yes even written as you have it without the use of outside variables I still return a null value. No the function has never worked but what do you mean I can't return the variables during load, so how can I run the function such that it doesn't do it during load, but after load has finished without the use of a slash command.

  4. #4
    Rift Chaser Lifeismystery's Avatar
    Join Date
    Dec 2010
    Posts
    341

    Default

    For me this work

    Code:
    local function getVitality()
    	local vitality = Inspect.Unit.Detail("player").vitality
    	return dump(vitality)
    end
    
    local function OnUnitAvailable(hEvent, units)
    	getVitality()
    end
    Command.Event.Attach(Event.Unit.Detail.Vitality, getVitality, "getVitalitys")
    Command.Event.Attach(Event.Unit.Availability.Full,		OnUnitAvailable, "OnUnitAvailable")
    Also you can check Addons\Gadgets\wtLibUnitDatabase\wtUnitDatabase.lu a
    And DatatextBar form Gadgets
    http://i.imgur.com/FV4Vu43.jpg

+ 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