Thread Tools Display Modes
10-19-16, 01:52 PM   #1
Mayron
A Frostmaul Preserver
 
Mayron's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 275
Change Combat Text after PLAYER_ENTERING_WORLD

I want to change the combat text by altering the constants:

Lua Code:
  1. _G["UNIT_NAME_FONT"] = font;
  2. _G["NAMEPLATE_FONT"] = font;
  3. _G["DAMAGE_TEXT_FONT"] = font;
  4. _G["STANDARD_TEXT_FONT"] = font;

However, I need my database to be initialized so that I know what font to use. The database I've designed requires Player related information to set it to the correct profile so I initialize it once this info is available after the PLAYER_ENTERING_WORLD.

The problem is that the Lua code above only works if you change these values before this event. If I try doing it after then it fails to change the font.

Does anyone know a solution to this problem?
Thanks!
  Reply With Quote
10-19-16, 02:24 PM   #2
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
What is the info that you need?
__________________
Grab your sword and fight the Horde!
  Reply With Quote
10-19-16, 02:41 PM   #3
Mayron
A Frostmaul Preserver
 
Mayron's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 275
Originally Posted by Lombra View Post
What is the info that you need?
Realm name is the main one:
local key, realm = UnitFullName("player");

If the player has not entered the world then this returns nil.

I'm worried that I'll have to redesign my database to be able to run without a profile which should be possible but annoying just to get access to the font.

And also I think Saved Variables only become available once the player logins in or enters world.

Last edited by Mayron : 10-19-16 at 02:52 PM.
  Reply With Quote
10-19-16, 03:21 PM   #4
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Assuming you need the chat formatted realm name, then? I'm pretty sure GetRealmName():gsub("[ -]", "") should give you that. That's what I'm doing, anyway. Otherwise 7.1 adds GetNormalizedRealmName, which I believe gives the correctly formatted name.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
10-19-16, 03:39 PM   #5
Mayron
A Frostmaul Preserver
 
Mayron's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 275
Originally Posted by Lombra View Post
Assuming you need the chat formatted realm name, then? I'm pretty sure GetRealmName():gsub("[ -]", "") should give you that. That's what I'm doing, anyway. Otherwise 7.1 adds GetNormalizedRealmName, which I believe gives the correctly formatted name.

Thank you. So I guess there is no way of changing these font elements after PLAYER_ENTERING_WORLD.

I still have the problem of starting my database as it requires access to Saved Variables which are not available without the use of events. The font changing problem is still there because of this.
  Reply With Quote
10-19-16, 03:42 PM   #6
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Don't really know about the font bit, sorry. Your saved variables are available at ADDON_LOADED(YourAddon), though, which normally fires some time before PLAYER_ENTERING_WORLD, so you could try that.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
10-19-16, 03:58 PM   #7
Mayron
A Frostmaul Preserver
 
Mayron's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 275
Originally Posted by Lombra View Post
Don't really know about the font bit, sorry. Your saved variables are available at ADDON_LOADED(YourAddon), though, which normally fires some time before PLAYER_ENTERING_WORLD, so you could try that.
Damn you beat me to it! I was just about to say I fixed it using ADDON_LOADED and had to change my code around a bit but now it all works perfectly. Thank you for your help!

I also noticed that changing the font and reloading the UI will not apply the change and you have to restart the client. I'm sure there is a logical reason for this but it threw me off as I assumed it was a bug on my part.
  Reply With Quote
10-20-16, 03:27 AM   #8
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
Just a tip for events, I suggest using PLAYER_LOGIN for the vast majority of your addon initial code. That is called the moment the loading process is complete, with LOADING_SCREEN_DISABLED and PLAYER_ENTERING_WORLD right after.

ADDON_LOADED is usually fine, but that is called alphabetically down the addon list. Use it if you need to be before other addons, like some addons in the past listed themselves first using underscores or similar. PLAYER_ENTERING_WORLD is called every time you zone into something, like another continent or instance, so if you want to use that, you have to unregister after loading or your addon will reinitialize itself. PLAYER_LOGIN is called only once every time the UI is loaded after a login or a reload. A reliable event well after these is UPDATE_PENDING_MAIL if you need info that lags after the UI loads, like artifact data. Just make sure to unregister for that if it's just initial code.
  Reply With Quote
10-20-16, 09:53 PM   #9
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Mayron View Post
I also noticed that changing the font and reloading the UI will not apply the change and you have to restart the client. I'm sure there is a logical reason for this ...
My theory is that there are two separate "memory spaces" for the UI and the 3D game world, and variables defined in the UI that affect the 3D game world -- like UNIT_NAME_FONT -- are only copied over from the UI space to the 3D space once, when the 3D space is initialized. The "copy over" process is a pull from the 3D side, not a push from the UI side, and since reloading the UI doesn't also reload the 3D engine, there's no "copy over" when you reload the UI.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
10-22-16, 10:00 AM   #10
Mayron
A Frostmaul Preserver
 
Mayron's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 275
Thank you for all the help and interesting theory Phanx. I always assumed it was to do with saving these settings as a variable in the game engine code using the C programming language as it is directly used to control core gameplay visuals like damage numbers etc... I never really put much thought into it. So a similar idea to your theory which I like

Thanks everyone for the help.

Last edited by Mayron : 10-22-16 at 10:05 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Change Combat Text after PLAYER_ENTERING_WORLD


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