Thread Tools Display Modes
02-26-09, 10:00 PM   #1
eliljey
A Deviate Faerie Dragon
Join Date: Feb 2009
Posts: 14
SetLootThreshold

I'm working on an addon that manipulates loot settings and I have some code that calls SetLootThreshold. When I click my "update loot settings" button it changes the loot threshold as per my selection, but then the threshold is mysteriously changed back to whatever the old setting was. (You can see two setting update messages in the chat window.)

I've added print statements to debug it and my function only gets called once and uses the correct setting so it appears that the game is overriding my setting and changing it back.

Is this an expected behavior and if so then how do I work around it?
  Reply With Quote
02-28-09, 02:27 AM   #2
eliljey
A Deviate Faerie Dragon
Join Date: Feb 2009
Posts: 14
Can anyone at least verify that it does/doesn't do this? I certainly could just be using it wrong.
  Reply With Quote
02-28-09, 08:09 PM   #3
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Are you setting the loot method (master, free-for-all, round robin, need-before-greed, etc) as well? If so, then you need to delay the setting of the threshold or it will revert to the original loot method.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
02-28-09, 09:53 PM   #4
eliljey
A Deviate Faerie Dragon
Join Date: Feb 2009
Posts: 14
Ah ha! That's exactly what I'm doing. I'll try and figure out how to put a delay in there. Thanks very much!
  Reply With Quote
02-28-09, 10:08 PM   #5
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Either a delay or something like this:

Code:
local set_threshold = -1

local function YourFunction(...)
        -- Do your code where you set the loot method
        set_threshold = (whatever number you want to set it to)
end

YourAddonFrame:SetScript("OnUpdate", CheckThreshold)

local function CheckThreshold()
        if set_threshold >= 0 then
                SetLootThreshold(set_threshold)
                set_threshold = -1
        end
end
Completely untested, YMMV.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » SetLootThreshold


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off