Thread: UI failure
View Single Post
12/05/16, 05:52 PM   #1
Rhyono
AddOn Author - Click to view addons
Join Date: Sep 2016
Posts: 659
UI failure

I've been experiencing some partial UI failure with an addon I've been working on, but I was able to reproduce the issue in a much smaller example. Using the example's functionality:
  1. Open your inventory.
  2. Type "/downitem " in chat and link a worn item in chat. Press enter.
  3. The downgraded (usually) result will appear in your chat. Now open the Champion interface.
  4. Start redistribution, end redistribution, try to start redistribution again (this will fail).
  5. Your UI should now be half useless. To fix it, type "/reloadui" in chat.

Test.txt
Code:
;Test

## Title: Test
## APIVersion: 100017
## Author: Test
## Description: Test
## Version: 1.0

Test.lua
Test.lua

Code:
local Test = {
	mame = "Test",
	author = "Test",
	version = "1.0"
}

--splits string into array
local function split_str(inputstr, sep)
	if sep == nil then
		sep = "%s"
	end
	local t={}
	local i=1
	for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
		t[i] = str
		i = i + 1
	end
	return t
end

--Tries to change an item's quality
local function GradeItem(text,inc)
	--break the string
	local item_data = split_str(text,":")
	local out = ""
	--increment the quality
	item_data[4] = tonumber(item_data[4])+inc
	if item_data[4] < 0 then
		item_data[4] = 0
	end	
	--reassemble
	local id = 1
	for id = 1, #item_data, 1 do
		out = out .. ":" .. item_data[id]
	end
	--output to chat
	CHAT_SYSTEM:AddMessage(out:sub(2))
end

--Grade handlers
local function UpgradeItem(text)
	return GradeItem(text,1)
end

local function DowngradeItem(text)
	return GradeItem(text,-1)
end

--Tries to upgrade an item's quality
SLASH_COMMANDS["/upitem"] = UpgradeItem
--Tries to downgrade an item's quality
SLASH_COMMANDS["/downitem"] = DowngradeItem
I know that it is a very lazy way of trying to change an item's quality and won't always work as planned (due to how convoluted quality can be), but it was a test piece. I'm hoping if someone can figure out what is triggering the UI failure, I can fix my real addon's problem.

Last edited by Rhyono : 12/05/16 at 07:40 PM.
  Reply With Quote