Thread Tools Display Modes
10/25/16, 02:19 AM   #1
Lum1on
AddOn Author - Click to view addons
Join Date: Aug 2016
Posts: 18
Default UI keeps disappearing

I have created a simple addon that keeps track of some of the most useful things for me. This is completely personal addon (at least for now) and I do know there are lots of addons that could do the same. But I also like to learn new stuff and this (coding) is something I've always wanted to learn -- and it's a great way to pass time while there's a maintenance in game - like yesterday.

The problem is, I have my addon and it shows everything like I wanted to (some tweaks needed, however). But let's say I go to the bank and want to deposit some money. After that I close the bank window, open it up some time later (within the same session, no logouts!) and want to withdraw some money. There's no a popup window that enables me to withdraw. I also can't port to any wayshrine because, well, none of the default UI's popup windows no longer appear to me.

I have no idea why this keeps happening. Sometimes it happens like within few minutes, sometimes it might take like an hour, or so. This addon also does not give me any kind of an error (except the Combat and Loot table creation because I still have to do some tweaks about it -- but that's another issue which I want to learn by myself - at least for now).

I'm not going to paste the code in here, because it's rather long. So I decided to upload it to my Dropbox and share the link with you guys.

As you can see, I do not have any XML there (yet): https://www.dropbox.com/s/61q9sa824l...Basic.txt?dl=0

Much appreciated!
  Reply With Quote
10/25/16, 03:02 AM   #2
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
Hi Lum1on,

the global function comma_value has a global i.

Get rid of this comma_value function and get rid of the ..-operator and use string.format or better zo_strformat.
If you use zo_strformat you don't need to stripe the gender and article information (^)

And I personally would recomment to make LootTab() and CombatTab() local.

Hope this helps.

And you are right: Learning coding by fixing personal needs is a good way.

Last edited by votan : 10/25/16 at 03:12 AM.
  Reply With Quote
10/25/16, 04:26 AM   #3
Lum1on
AddOn Author - Click to view addons
Join Date: Aug 2016
Posts: 18
Hey,

thanks for the reply!

Could I make the comma_value as a local function and i as a local as well? And thanks for the suggestion about zo_strformat - I'll definitely take a look at it.

I'm not at home at the moment so I can not make these changes. But I tried to disable some of the functions and noticed that if I disable both EVENT_COMBAT_EVENT and EVENT_LOOT_RECEIVED functions then everything works without any trouble. And now that I checked the code those functions doesn't use i at all and some other functions use comma_value as well.

But, I will definitely give it a try. Thanks!

EDIT:
Okay, I changed everything you suggested and it works now as a dream. Except now it gives me an error related to EVENT_COMBAT_EVENT.

Code:
-- "EVENT_COMBAT_EVENT"
local function CombatEvent ( eventCode, result, isError, abilityName, abilityGraphic, abilityActionSlotType, sourceName, sourceType, targetName, targetType, hitValue, powerType, damageType, log, sourceUnitId, targetUnitId, abilityId )
	local source_name = sourceName
	if string.find ( sourceName, "%^" ) then
		source_name = string.sub ( sourceName, 0, ( string.find ( sourceName, "%^" ) - 1.0 ))
	end
	
	local target_name = targetName
	if string.find ( targetName, "%^" ) then
		target_name = string.sub ( targetName, 0, ( string.find ( targetName, "%^" ) - 1.0 ))
	end
	
	if source_name == GetUnitName ( "player" ) then
		if sourceName == targetName then
			target_name = "yourself"
		end
		
		local x = string.sub ( GetTimeString ( ), 0.0, 5.0 )
		local y = ""
		
		if result == ACTION_RESULT_CRITICAL_DAMAGE then
			y = zo_strformat ( "|cCCCCCC[<<1>>] You dealt |cFA3232<<2>> |cFA9696critical |cCCCCCCdamage to <<3>> with <<4>>",
			x, comma_value ( hitValue ), target_name, abilityName )
		elseif result == ACTION_RESULT_CRITICAL_HEAL then
			y = zo_strformat ( "|cCCCCCC[<<1>>] You |c96FA96critically |cCCCCCChealed <<2>> for |c32FA32<<3>> |cCCCCCCwith <<4>>",
			x, target_name, comma_value ( hitValue ), abilityName )
		elseif result == ACTION_RESULT_DAMAGE then
			y = zo_strformat ( "|cCCCCCC[<<1>>] You dealt |cFA3232<<2>> |cCCCCCCdamage to <<3>> with <<4>>",
			x, comma_value ( hitValue ), target_name, abilityName )
		elseif result == ACTION_RESULT_DOT_TICK then
			y = zo_strformat ( "|cCCCCCC[<<1>>] Your <<2>> ticked |cFA3232<<3>> |cCCCCCCto <<4>>",
			x, abilityName, comma_value ( hitValue ), target_name )
		elseif result == ACTION_RESULT_DOT_TICK_CRITICAL then
			y = zo_strformat ( "|cCCCCCC[<<1>>] Your <<2>> |cFA9696critically |cCCCCCCticked |cFA3232<<3>> |cCCCCCCto <<4>>",
			x, abilityName, comma_value ( hitValue ), target_name )
		elseif result == ACTION_RESULT_HEAL then
			y = zo_strformat ( "|cCCCCCC[<<1>>] You healed <<2>> for |c32FA32<<3>> |cCCCCCCwith <<4>>",
			x, target_name, comma_value ( hitValue ), abilityName )
		elseif result == ACTION_RESULT_HOT_TICK then
			y = zo_strformat ( "|cCCCCCC[<<1>>] Your <<2>> ticked |c32FA32<<3>> |cCCCCCCto <<4>>",
			x, abilityName, comma_value ( hitValue ), target_name )
		elseif result == ACTION_RESULT_HOT_TICK_CRITICAL then
			y = zo_strformat ( "|cCCCCCC[<<1>>] Your <<2>>|c96FA96critically |cCCCCCCticked |c32FA32<<3>>|cCCCCCC to <<4>>",
			x, abilityName, comma_value ( hitValue ), target_name )
		else
			--
		end
		
		CHAT_SYSTEM.containers [ 1.0 ].windows [ Basic.combat_tab ].buffer:AddMessage ( y )
	end
end
The error is every single one of these ACTION_RESULT_ if functions. I checked and they are correct related to the local function CombatEvent ( .. ) parameters.

Any ideas what's wrong?

EDIT:
This is the new function for comma_value function because it's the only thing that isn't set in the CombatEvent function.

Code:
local comma_value = function ( amount )
	local amount_ = amount
	
	while true do
		local amount_, i = string.gsub ( amount_, "^(-?%d+)(%d%d%d)", '%1,%2' )
		
		if i == 0.0 then
			break
		end
	end
	
	return amount_
end

Last edited by Lum1on : 10/25/16 at 05:07 AM.
  Reply With Quote
10/25/16, 05:11 AM   #4
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
If you made comma_value local and did not get rid of it, you have to declare it before the first usage. That is how Lua works.

Code:
local comma_value

local function CombatEvent ( eventCode, result, isError, abilityName, abilityGraphic, abilityActionSlotType, sourceName, sourceType, targetName, targetType, hitValue, powerType, damageType, log, sourceUnitId, targetUnitId, abilityId )
...
end

-- this function is local because of above
function comma_value(value)
..
end
  Reply With Quote
10/25/16, 05:18 AM   #5
Lum1on
AddOn Author - Click to view addons
Join Date: Aug 2016
Posts: 18
Oh? I wasn't sure how to make my own local function, so I checked from the internet and came up with this answer in StackOverflow:

Code:
local func1
local func2 = function()
  func1()
end
func1 = function()
  --do something
end
And I thought it shows two different ways to create a local function (func1 and func2). So I would like to have a clarification that this isn't a case?
  Reply With Quote
10/25/16, 05:32 AM   #6
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
Originally Posted by Lum1on View Post
And I thought it shows two different ways to create a local function (func1 and func2). So I would like to have a clarification that this isn't a case?
In Lua are named functions the same as a variable, which an anonymous function is assigned to.
The example shows, that the name func1 is declared before the usage in func2, while it's real content can be assigned later.
func1 = function() and function func1() is the same in Lua.
  Reply With Quote
10/25/16, 05:35 AM   #7
Lum1on
AddOn Author - Click to view addons
Join Date: Aug 2016
Posts: 18
Ah, my bad. Didn't pay attention to the positions of the functions. For some reason I seem to forget it all the time, because in QML and C++ it didn't matter where the functions where.

Thanks for the clarification. I think I'll get this now.

EDIT:
Yes, it's working like a charm now. Finally I get to move on and add some my own UI thingies in there to show some basic stuffs. Yey!

Last edited by Lum1on : 10/25/16 at 05:50 AM.
  Reply With Quote

ESOUI » AddOns » AddOn Help/Support » Default UI keeps disappearing


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