1. #1

    GetInstanceInfo missing difficulty data

    Recently I started noticing a problem with my loot tracking addon, specifically that the instance difficulty was being grabbed as an empty string from GetInstanceInfo();

    Code:
    if (event == "PLAYER_ENTERING_WORLD") then
    		local name, typeOfInstance, difficulty, difficultyName, _, _, _, instanceMapId, _ = GetInstanceInfo();
    For something like Ragefire Chasm, this should return:
    Code:
    name => Ragefire Chasm
    typeOfInstance => party
    difficulty => 1
    difficultyName => Normal
    instanceMapId => 389
    What I actually get is:
    Code:
    name => Ragefire Chasm
    typeOfInstance => party
    difficulty => 0
    difficultyName => 0
    instanceMapId => 389
    If I manually run /script print(GetInstanceInfo()); when inside, it gives me the correct information, so I'm thinking it's a problem with timing and the PLAYER_ENTERING_WORLD event. Is there a better event I could be using?
    Author of Instance Profit Tracker
    Find out how much gold you earn soloing raids and dungeons

    Curse | GitHub
    WowInterface

  2. #2
    You could try to still trigger on PLAYER_ENTERING_WORLD but delay the call of GetInstanceInfo with C_Timer.After.
    http://wow.gamepedia.com/API_C_Timer.After

  3. #3
    I suspect UPDATE_INSTANCE_INFO is the correct event to use here. I haven't checked to see if it actually fires on entering an instance.

  4. #4
    Quote Originally Posted by quthar View Post
    I suspect UPDATE_INSTANCE_INFO is the correct event to use here. I haven't checked to see if it actually fires on entering an instance.
    This event fires, when you get new lockout info from server, and you have to request it first by calling RequestRaidInfo() function, otherwise, for example, GetSavedInstanceInfo() function shows cached info.

    On topic, everything works fine at loading screens, relogs, UI reloads, I even tried relogging whilst in instance.

    BTW, instead of /run print(GetInstanceInfo()) do /dump GetInstanceInfo().

    - - - Updated - - -

    I just checked your addon code, your issue is in another place, you call triggerInstance function at ADDON_LOADED event @ lines 334-338, you can't do that, it's a bit too early to do such things, hence you get 0s and nils.

    Have a nice day.

    P.S. There're some variables in your code that you dun use at all, yet you store them for some reason.
    Last edited by ls-; 2016-03-19 at 04:56 AM.

  5. #5
    Quote Originally Posted by lightspark View Post
    This event fires, when you get new lockout info from server, and you have to request it first by calling RequestRaidInfo() function, otherwise, for example, GetSavedInstanceInfo() function shows cached info.

    On topic, everything works fine at loading screens, relogs, UI reloads, I even tried relogging whilst in instance.

    BTW, instead of /run print(GetInstanceInfo()) do /dump GetInstanceInfo().

    - - - Updated - - -

    I just checked your addon code, your issue is in another place, you call triggerInstance function at ADDON_LOADED event @ lines 334-338, you can't do that, it's a bit too early to do such things, hence you get 0s and nils.

    Have a nice day.

    P.S. There're some variables in your code that you dun use at all, yet you store them for some reason.
    The code is still pretty hideous, as I test out a few things. The triggerInstance in ADDON_LOADED should only fire if you first login inside an instance, that's to catch the issue of if you logout while still inside an instance (or do /reload) That's a different issue though, that isn't working as expected. Probably because it's too early, like you were saying. The addon code currently on curse is also out of date, I've been working locally to fix issues with localization, dying in an instance, and some tweaks with the UI.

    I'm definitely going to need to go through and do some refactoring and code cleanup, though.

    I also know that the problem is in the PLAYER_ENTERING_WORLD event since I added some debugging print statements there. It's definitely reaching that point with the values set as stated in my first post. I got it working by adding some hack fixes to the OnUpdate handler for my frame. It works, but I don't like it
    Author of Instance Profit Tracker
    Find out how much gold you earn soloing raids and dungeons

    Curse | GitHub
    WowInterface

  6. #6
    Quote Originally Posted by Arcilux View Post
    The code is still pretty hideous, as I test out a few things. The triggerInstance in ADDON_LOADED should only fire if you first login inside an instance, that's to catch the issue of if you logout while still inside an instance (or do /reload) That's a different issue though, that isn't working as expected. Probably because it's too early, like you were saying. The addon code currently on curse is also out of date, I've been working locally to fix issues with localization, dying in an instance, and some tweaks with the UI.
    Well, you shouldn't have it there anyway, cuz PLAYER_ENTERING_WORLD fires in any case.

    Quote Originally Posted by Arcilux View Post
    I also know that the problem is in the PLAYER_ENTERING_WORLD event since I added some debugging print statements there. It's definitely reaching that point with the values set as stated in my first post. I got it working by adding some hack fixes to the OnUpdate handler for my frame. It works, but I don't like it
    I didn't have any issues with this part T_T I'd simply avoid performing any actions if difficultyID is 0.

    - - - Updated - - -

    This part is awkward too, well, there are many awkward spots, but it's WIP, WIP is always messy, it's fine
    local enteredInstance = ((type == "raid" or type == "party") and ignorezones[instanceMapId] == nil and not inInstance and GetNumGroupMembers() == 0)
    There is a special function to detect if player is in instance, IsInInstance. There're many ways to simplify it. Wish you had github repo, so I could look through your current code
    Last edited by ls-; 2016-03-19 at 06:11 AM.

  7. #7
    Quote Originally Posted by lightspark View Post
    Well, you shouldn't have it there anyway, cuz PLAYER_ENTERING_WORLD fires in any case.



    I didn't have any issues with this part T_T I'd simply avoid performing any actions if difficultyID is 0.

    - - - Updated - - -

    This part is awkward too, well, there are many awkward spots, but it's WIP, WIP is always messy, it's fine


    There is a special function to detect if player is in instance, IsInInstance. There're many ways to simplify it. Wish you had github repo, so I could look through your current code
    Just pushed current code up to GH https://github.com/awestover89/InstanceProfits
    Author of Instance Profit Tracker
    Find out how much gold you earn soloing raids and dungeons

    Curse | GitHub
    WowInterface

  8. #8
    Quote Originally Posted by Arcilux View Post
    Just pushed current code up to GH https://github.com/awestover89/InstanceProfits
    Yeah, already forked it, I'm gonna take a break from my UI for a day, lel, I'll help you a bit

    One thing, dun use XML, it's fairly simple addon, yet you expose so much stuff, it's not safe.
    Last edited by ls-; 2016-03-19 at 06:29 AM.

  9. #9
    Thanks, going through the PR now. I see a couple things that will cause issues, but running a general QA test of a few areas to make sure I catch them all, then I'll merge in and can make any updates. I'll look into switching from XML, personally I find it a lot cleaner than doing the UX stuff in Lua, but hadn't heard that there was any security concerns with that approach. I still heavily prefer XML, but I'll do my research.
    Author of Instance Profit Tracker
    Find out how much gold you earn soloing raids and dungeons

    Curse | GitHub
    WowInterface

  10. #10
    Quote Originally Posted by Arcilux View Post
    Thanks, going through the PR now. I see a couple things that will cause issues, but running a general QA test of a few areas to make sure I catch them all, then I'll merge in and can make any updates. I'll look into switching from XML, personally I find it a lot cleaner than doing the UX stuff in Lua, but hadn't heard that there was any security concerns with that approach. I still heavily prefer XML, but I'll do my research.
    One of the biggest concerns is global variables exposure. Someone else may name their vars identically to yours and then everyone is in trouble. Anyway, if you want to keep using XML, you have to make sure, that you declare as few global variables as possible.

Posting Permissions

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