View Single Post
01/14/17, 06:51 PM   #2
Dolgubon
 
Dolgubon's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2016
Posts: 409
This is the code that I use (stripped of some additional unnecessary logic) It's possible the show inventory bit doesn't need to be on a delay, it's been a while since I coded it.

[code]
local function OnLootUpdated(event)
if autoLoot then
LOOT_SHARED:LootAllItems()
zo_callLater(function() SYSTEMS:GetObject("mainMenu"):ShowCategory(MENU_CATEGORY_INVENTORY)end, 50)
end
end

EVENT_MANAGER:RegisterForEvent(WritCreater.name, EVENT_LOOT_UPDATED ,OnLootUpdated )
[\code]
l think that you need to do LOOT_SHARED:LootAllItems() instead of just LootAllItems(). Also, are you coming from Java or something? Lua has no concept of overloading functions. The second function you have listed will simply overwrite the first one listed. Instead, you'll need to build it in yourself, likely with if eventcode then 1stfunction() else 2ndfunction() end, or if not eventcode then eventcode = 1 end.

It looks like you've added the event properly, but double check that the event is added below the lootallcontents, or that it's added in the initialization function. If you add it before that, it's not going to call anything.
  Reply With Quote