View Single Post
  #22  
Unread 12-13-2011, 01:20 PM
Cearbhall's Avatar
Cearbhall Cearbhall is offline
The Undefeated
Interface Author - Click to view interfaces
 
Join Date: Sep 2010
Posts: 5
not the best way i'm sure but can get around this until Turbine fixes it

Code:
--create quickslots

local needsItemAddedEvent = false
local function setShortCuts()
	needsItemAddedEvent = false

	for i = 1, 5 do
		if DB.quickslots[i] then
			local qs = window.quickslots[i]

			local sc = Turbine.UI.Lotro.Shortcut(DB.quickslots[i][1], DB.quickslots[i][2])
			local ok = pcall(qs.SetShortcut, qs, sc)
			if not ok then
				needsItemAddedEvent = true
			end
		end
	end

	if not needsItemAddedEvent and ItemAdded then
		Shady.Helper.Event.UnregisterCallback(backpack, 'ItemAdded', ItemAdded)
	end
end

plugin.Load = function()
	setShortCuts()

	if needsItemAddedEvent then
		local player = Turbine.Gameplay.LocalPlayer.GetInstance()
		backpack = player:GetBackpack()
		ItemAdded = Shady.Helper.Event.RegisterCallback(backpack, 'ItemAdded', function(s, args)
			setShortCuts()
		end)
	end
end
downside: quickslot's shortcut gets set everytime ItemAdded event fires
Of course you can check to see if all your quickslots setshortcut without error and unregister the backpack.ItemAdded event

edit: updated it to do just that

Last edited by Cearbhall : 12-13-2011 at 01:37 PM.
Reply With Quote