Thread Tools Display Modes
08/06/14, 04:15 PM   #1
unLeashed3k
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 33
Ask a simple question, get a simple answer

The purpose of this thread is to ask simple questions about the API and not a How-to tutorial. I have so many questions that often can be resolved with a yes or no, or a link to something that this type of thread may be beneficial to others.

When asking a question preface it with a Q# and answer with an A#.

I have one! ~laughs~

Q1: Is there a way to reverse the fill direction of a <StatusBar> with an attribute from the standard default of left-to-right?

Last edited by unLeashed3k : 08/11/14 at 11:36 PM.
  Reply With Quote
08/06/14, 04:47 PM   #2
Harven
 
Harven's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 135
Hey unLeashed3k,

A1: no, but you can do that like I did in my All Experience Bars addon. The function is called HarvensExperienceBar:SwitchBarTextureAlignment().
  Reply With Quote
08/06/14, 05:07 PM   #3
unLeashed3k
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 33
R1: Darn!, was hoping it would be as easy as <StatusBar fill="REVERSE" /> or SetMinMax(-200, 0) then set values going down such as SetValue(-20) for 10% filled on the right side. So with your example, if I got it straight, is to grab the texture coordinates and pull it to the left then reset the anchor of the texture?
  Reply With Quote
08/06/14, 05:22 PM   #4
Harven
 
Harven's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 135
R1: Hmm... I didn't try SetMinMax(-200, 0) with SetValue(-x) - but I don't think it will work since the arrow texture is pointing in the wrong direction. Yes, I switched horizontal texture coordinates to make a mirror texture and then reanchored it with the other end. But all the problems are gone when you use statusbars like in my Research Timers
  Reply With Quote
08/06/14, 05:30 PM   #5
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by unLeashed3k View Post
R1: Darn!, was hoping it would be as easy as <StatusBar fill="REVERSE" /> or SetMinMax(-200, 0) then set values going down such as SetValue(-20) for 10% filled on the right side. So with your example, if I got it straight, is to grab the texture coordinates and pull it to the left then reset the anchor of the texture?
If you want to do it in XML, try barAlignment="REVERSE":
xml Code:
  1. <StatusBar name="MyBar" inherits="ZO_PlayerAttributeStatusBar" barAlignment="REVERSE" />
  Reply With Quote
08/06/14, 05:40 PM   #6
unLeashed3k
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 33
R1(Garkin): Works! I was using barAlignment="BAR_ALIGNMENT_REVERSE" because the WikiDocumentation told me so! Last time I listen to the Wiki! =)
  Reply With Quote
08/07/14, 04:11 AM   #7
Harven
 
Harven's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 135
I was sure it will not work because that's the case with ZO_ArrowStatusBarWithBG. But looks like ZO_PlayerAttributeStatusBar is completly different... sorry for misleading you
  Reply With Quote
08/08/14, 01:01 PM   #8
unLeashed3k
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 33
In the hopes of helping others [new to this API] I will self-answer my own question!

Q2: How do I hide my frame/window when I open my Inventory, Journal, Map, etc but not when I show my cursor?
A2: This tutorial explains all by Garkin.
  Reply With Quote
08/08/14, 03:06 PM   #9
unLeashed3k
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 33
Q3: Is there a way to get any index (map, zone, subzone) that's reliable to where the character is actively standing in the world or must I set up my own 'key = value' table and check that table against GetPlayerLocationName (which seems to be the only dependable information about where the player is and not what map is being viewed)?
  Reply With Quote
08/08/14, 04:11 PM   #10
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by unLeashed3k View Post
Q3: Is there a way to get any index (map, zone, subzone) that's reliable to where the character is actively standing in the world or must I set up my own 'key = value' table and check that table against GetPlayerLocationName (which seems to be the only dependable information about where the player is and not what map is being viewed)?
A3: There are two functions which doesn't depend on WorldMap:
Lua Code:
  1. local mapName = GetPlayerLocationName()
  2. local zoneName = GetUnitZone("player")
However both function returns just a localized name which is not uinque. You will have to use something different:

- If you use GetPlayerLocationName(), GetMapName() or GetUnitZone(unitTag) there are duplicate names (check map list on Esohead - http://www.esohead.com/map). Also there are issues with localized names.
- GetCurrentMapZoneIndex() - zone and subzone has the same zone index (subzone = city in the zone)
- GetCurrentMapIndex() works only for maps listed in WorldMap
- GetMapTileTexture() returns "Art/maps/stormhaven/wayrest_base_0.dds". As it is file name it must be unique. Bingo.

At first you have to reset map position, to be sure that you're checking correct location:
Lua Code:
  1. SetMapToPlayerLocation()
If map location is changed, you will probably need to redraw map, so better is:
Lua Code:
  1. if(SetMapToPlayerLocation() == SET_MAP_RESULT_MAP_CHANGED) then
  2.     CALLBACK_MANAGER:FireCallbacks("OnWorldMapChanged")
  3. end

And then use:
Lua Code:
  1. local zone, subzone = select(3,(GetMapTileTexture()):lower():find("maps/([%w%-]+)/([%w%-]+_%w+)"))
returns:
zone = "stormhaven"
subzone = "wayrest_base"

or if you want just single location name:
Lua Code:
  1. local zoneName = select(3,(GetMapTileTexture()):lower():find("maps/([%w%-]+/[%w%-]+_%w+)"))
returns:
zone = "stormhaven/wayrest_base"

Or if you are using LibMapPins library, then:
Lua Code:
  1. local LMP = LibStub("LibMapPins-1.0")
  2. local zone, subzone = LMP:GetZoneAndSubzone()
  3. local zoneName = LMP:GetZoneAndSubzone(true)

See topic: http://www.esoui.com/forums/showthread.php?t=1431
  Reply With Quote
08/08/14, 04:32 PM   #11
unLeashed3k
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 33
R3: That is what I was looking for Garkin and wish I looked at the Wish List forums a little more careful before asking.

Also SetMapToPlayerLocation() is what I was using, and it did work, but I was having some odd after-results (weird zooming on the World Map) whenever I called it.
Lua Code:
  1. if(SetMapToPlayerLocation() == SET_MAP_RESULT_MAP_CHANGED) then
  2.       CALLBACK_MANAGER:FireCallbacks("OnWorldMapChanged")
  3. end

What I needed to make to make my function work. Thanks! I think I should start paying you to mentor me... seems I'm the only one asking the newbie questions. ~laughs~
  Reply With Quote
08/09/14, 04:50 PM   #12
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,568
R3: I am not sure what exactly you plan to do, but you should probably also take a look at my LibGPS. It provides methods to get a global position (x,y) and solves a lot of these map changing issues internally.
  Reply With Quote
08/10/14, 01:51 PM   #13
unLeashed3k
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 33
Originally Posted by sirinsidiator View Post
R3: I am not sure what exactly you plan to do, but you should probably also take a look at my LibGPS. It provides methods to get a global position (x,y) and solves a lot of these map changing issues internally.
Get coordinates relevant to where the avatar is actively standing is all I wanted. Seems doable but their are no, for lack of a better phrasing, World Coordinates the server can echo back and seems all coordinates are based on client side mappings, and worse they're all based on ascending x, y coordinates. Was hoping the entire continent had a 0, 0 center World Coordinate and south/north and east/west could be determined simply based on -/+.
  Reply With Quote
08/11/14, 03:23 PM   #14
zgrssd
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 280
I got two too (that might actualy be related):
Code:
ZO_SavedVars:New()
has one parameter described like this on the wiki:
profile - Allows you to select a specific profile instead of the current character's default profile. Probably not necessary for most simple add-ons without robust profile management.
Q4: What would be the "default" profile. What exactly will that do? Is it another sublayer similar to namespace (except below the Account name, rather then above it)?
What exactly would be the use, since we can just seperate our saved table however we like in the first place?


The whole issues between 1.2.3 and 1.3.3 pointed me towards something interesting:
The saved variables do allow to share data OS user wide. It is just that the system seems to be hardcoded to use the result of GetDisplayName() and I don't want to overwrite this one (again). I need something more granular.

Q5: Is it possible to manually overwrite wich Zenimax account ZO_SavedVars:New() uses?
Specicially I would like to use the account "" or "[some constant string that is not likely to be mistaken for a real account name".
  Reply With Quote
08/11/14, 03:36 PM   #15
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
Originally Posted by zgrssd View Post
Q5: Is it possible to manually overwrite wich Zenimax account ZO_SavedVars:New() uses?
Specicially I would like to use the account "" or "[some constant string that is not likely to be mistaken for a real account name".
I tried that long ago, perhaps before 1.2. There was a function you could pass account name to (i.e. fake whatever you wanted, while maintaining their sv[profile][account][character] structure). I wanted to use that to read another account's settings, for example - but the function was bugged (and I reported that) in such a way that it didn't work at all - they forgot to pass that parameter down and it ended up in some kind of "nil argument" error.

After all the trouble with saved variables, I'd advise everyone to simply avoid ZO_SavedVars altogether.
  Reply With Quote
08/11/14, 07:29 PM   #16
Randactyl
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 251
Originally Posted by merlight View Post
After all the trouble with saved variables, I'd advise everyone to simply avoid ZO_SavedVars altogether.
I've seen this mentioned a couple of times. How does one avoid ZO_SavedVars in the first place?
  Reply With Quote
08/11/14, 08:19 PM   #17
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by Randactyl View Post
I've seen this mentioned a couple of times. How does one avoid ZO_SavedVars in the first place?
You can directly access saved variables table defined in manifest (.txt):

Code:
## SavedVariables: MyAddon_SavedVariables
Lua Code:
  1. local savedVars
  2. local defaults = {
  3.     key1 = "value1",
  4.     key2 = "value2",
  5. }
  6.  
  7. EVENT_MANAGER:RegisterForEvent("MyAddon", EVENT_ADD_ON_LOADED,
  8.     function(event, addon)
  9.         if addon ~= "MyAddon" then return end
  10.         EVENT_MANAGER:UnregisterForEvent("MyAddon", event)
  11.  
  12.         MyAddon_SavedVariables = MyAddon_SavedVariables or defaults
  13.         savedVars = MyAddon_SavedVariables
  14.     end)

As an example check Wykkyd's or Seerah's addons.
  Reply With Quote
08/11/14, 09:46 PM   #18
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Saved variables is just a table and you can define how its structure should look like.

Default structure is:
Lua Code:
  1. MyAddon_SavedVariables = {
  2.     profile = {
  3.         displayName = {
  4.             characterName = {
  5.                 namespace = {
  6.                     version = 1,
  7.                 },
  8.             },
  9.         },
  10.     },
  11. }

You can define all key names (except of displayName and characterName):
Lua Code:
  1. local namespaceTable = ZO_SavedVars:New(savedVariableTable, version, namespace, defaults, profile)

And if you don't like this structure, just use MyAddon_SavedVariables as any other table.


A4: What is the use for profiles? You can have for the same account name and character name stored more profiles. I have never used it, but I can imagine that it works this way:

Lua Code:
  1. local sv, profile
  2. local defaults = {}
  3. defaults.profile = {
  4.     name = "pve",
  5. }
  6. defaults.pve = {
  7.     key1 = true,
  8. }
  9. defaults.pvp = {
  10.     key1 = false,
  11. }
  12.  
  13. EVENT_MANAGER:RegisterForEvent("MyAddon", EVENT_ADD_ON_LOADED,
  14.     function(event, addon)
  15.         if addon ~= "MyAddon" then return end
  16.         EVENT_MANAGER:UnregisterForEvent("MyAddon", event)
  17.  
  18.         profile = ZO_SavedVars:New(MyAddon_SavedVars, 1, nil, defaults.profile)
  19.         sv = ZO_SavedVars:New(MyAddon_SavedVars, 1, nil, defaults[profile.name], profile.name)
  20.     end)
So just save name of active profile and reload UI.


A5: If you are asking if you can force ZO_SavedVars:New() to use user defined string instead of displayName, it can be done only if you redefine function GetDisplayName() (and GetUnitName(unitTag)), the same way as it does Display Name Fix addon.

Last edited by Garkin : 08/17/14 at 06:35 AM. Reason: Corrected?
  Reply With Quote
08/12/14, 06:25 AM   #19
zgrssd
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 280
Originally Posted by Randactyl View Post
I've seen this mentioned a couple of times. How does one avoid ZO_SavedVars in the first place?
All the manifest line "SavedVariable" says is:
Define a global variable of that name
Automatically write it to disk on UI unload/read it in from disk on UI load. The loading is finished just before the first OnLoaded Event is fired.

All ZO_SavedVars does is help you with structuring the data by account, character, namespaces, etc. It also provides built in versioning system (perhaps the most usefull part).
You can just as well treat it like any other table with subtables and write it directly. That way you avoid issues (the way ZO_SavedVars get's the account name is hardcoded wich lead to the issues between 1.2.3 and 1.3.3).

I started work on a really small library taht should deal with the main plumbing issues for you, as long as you tell it wich global variable to write too it takes care of the rest. Not yet finished, however.

Last edited by zgrssd : 08/12/14 at 06:27 AM.
  Reply With Quote
08/12/14, 01:35 PM   #20
unLeashed3k
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 33
Q6: Does the provided API have the functionality to detect the [red circle, cylinder, cone] ground effects (the precursor to an upcoming ability) from your combative target(s)?
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Ask a simple question, get a simple answer

Thread Tools
Display Modes

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