Thread Tools Display Modes
06/04/14, 03:23 PM   #21
Sharlikran
 
Sharlikran's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 650
Lua Code:
  1. local textureName = GetMapTileTexture()
  2.     textureName = string.lower(textureName)
  3.     textureName = string.gsub(textureName, "^.*maps/", "")
  4.     textureName = string.gsub(textureName, "_%d+%.dds$", "")
  5.  
  6.     local location = GetPlayerLocationName()
  7.     location = string.lower(location)
  8.     location = string.gsub(location, "%s", "")
  9.     textureName = textureName .. "/" .. location
That produces "glenumbra/daggerfall_base/daggerfalltradedistrict" for a map name.
Lua Code:
  1. ["glenumbra/daggerfall/daggerfalltradedistrict"] =
  2.                         {
  3.                             [1] =
  4.                             {
  5.                                 [1] = [[art/maps/glenumbra/daggerfall_base_0.dds]],
  6.                                 [2] = [[glenumbra]],
  7.                                 [3] = [[daggerfall_base]],
  8.                                 [4] = [[daggerfalltradedistrict]],
  9.                                 [5] = [[Glenumbra]],
  10.                                 [6] = [[Daggerfall]],
  11.                             },
  12.                         },
I still have some planning to do but I am toying with this idea. [1] Is the actual texture name. [2] and [3] are how HarvestNap does it. Then [4] is the players location. I am hoping that Location will resolve the issue where some maps don't have a unique name.
Lua Code:
  1. ["therift/blessedcrucible1_base"] = {"Blessed Crucible"},
  2.     ["therift/blessedcrucible2_base"] = {"Blessed Crucible"},
  3.     ["therift/blessedcrucible3_base"] = {"Blessed Crucible"},
  4.     ["therift/blessedcrucible4_base"] = {"Blessed Crucible"},
  5.     ["therift/blessedcrucible5_base"] = {"Blessed Crucible"},
  6.     ["therift/blessedcrucible6_base"] = {"Blessed Crucible"},
  7.     ["therift/blessedcrucible7_base"] = {"Blessed Crucible"},
Look at the "Blessed Crucible" as an example. All the texture names are unique but not what is being used for the map name. Shinni and HarvestMap already skip over maps like the "Blessed Crucible" when importing from Esohead. So I would not loose any information on import. I would just skip over those names as well.

Then each unique texture name would be Root. So everything imported from Esohead would go into Root. When a player loots a node, and it's in a unique location then the node would be evaluated against Root first. If it's not in Root and there is a unique location name, log it under the unique location name. I Am going to adapt Harvester to do this since it's not HarvestMap nobody will loose important data. Then I want to add that feature you have to grab the lorebook locations, and have it report the location names so I can collect them and hopefully some translations.

Then I would have three keys, and when I know the Zone "therift" and SubZone "blessedcrucible7_base" then I only have to evaluate the location name.

Last edited by Sharlikran : 06/04/14 at 03:46 PM.
  Reply With Quote
06/04/14, 06:46 PM   #22
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
I think that you are making it overly complicated. If you use texture names you don't need location name.
Lua Code:
  1. local mapname = select(4,(GetMapTileTexture()):lower():find("(maps/)([%w%-]+/[%w%-]+_[%w%-]+)"))
  2. --format used by HarvestMap "glenumbra/daggerfall_base"
  3.  
  4. local zone, subzone = select(4,(GetMapTileTexture()):lower():find("(maps/)([%w%-]+)/([%w%-]+_[%w%-]+)"))
  5. --format used in SkyShards "glenumbra", "daggerfall_base"
It has to be unique because it is a file name and you can't have more files (subzone) with the same name in one folder (zone).

Originally Posted by Sharlikran View Post
Lua Code:
  1. ["therift/blessedcrucible1_base"] = {"Blessed Crucible"},
  2.     ["therift/blessedcrucible2_base"] = {"Blessed Crucible"},
  3.     ["therift/blessedcrucible3_base"] = {"Blessed Crucible"},
  4.     ["therift/blessedcrucible4_base"] = {"Blessed Crucible"},
  5.     ["therift/blessedcrucible5_base"] = {"Blessed Crucible"},
  6.     ["therift/blessedcrucible6_base"] = {"Blessed Crucible"},
  7.     ["therift/blessedcrucible7_base"] = {"Blessed Crucible"},
Look at the "Blessed Crucible" as an example. All the texture names are unique but not what is being used for the map name. Shinni and HarvestMap already skip over maps like the "Blessed Crucible" when importing from Esohead. So I would not loose any information on import. I would just skip over those names as well.
As you say, it is not possible to get exact location if you have just a map name. For example all floors in dungeons have the same name.

Last edited by Garkin : 06/04/14 at 06:50 PM.
  Reply With Quote
06/04/14, 07:58 PM   #23
Sharlikran
 
Sharlikran's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 650
Let me play with it. I wana try my idea. Can you help with something?

This is the string I have, "stonefalls/davonswatch_base"
Lua Code:
  1. local count = 0
  2.     local mapParse = {}
  3.     for v1, v2 in string.gmatch (textureName, "(.-)%/") do
  4.         count = count +1
  5.         mapParse[count] = v1
  6.         d(count .. ") " .. v1)
  7.         d(count .. ") " .. mapParse[count])
  8.     end
I was looking through the lua.org stuff and could not find what I wanted. That crappy bit of code got me the first part of the string before the "/", "stonefalls" but not the second half. Then I tried your code and it's working. However, I have my doubts about my understanding of the syntax. I think I am doing it wrong and just getting lucky and they return what I want.

textureName = "stonefalls/davonswatch_base"
Lua Code:
  1. local v1, v2 = select(3,textureName:find("([%w%-]+)/([%w%-]+_[%w%-]+)"))
I get "stonefalls" and "davonswatch_base" which is exactly what I want.

textureName = "stonefalls/davonswatch_base/davonswatch"
Lua Code:
  1. local v1, v2, v3 = select(3,textureName:find("([%w%-]+)/([%w%-]+_[%w%-]+)/([%w%-]+)"))
I get "stonefalls", "davonswatch_base", and "davonswatch" which is exactly what I want.

textureName = "stonefalls/stonefalls_base"
Lua Code:
  1. local v1, v2, v3 = select(3,textureName:find("([%w%-]+)/([%w%-]+)_([%w%-]+)"))
I get "stonefalls", "stonefalls", and "base" which is exactly what I want.

Q1) Did I do it right?
Q2) Why does 3 work in all cases. I tried a 2 for the first example with only v1, and v2 and I got a number and a string.
  Reply With Quote
06/04/14, 08:36 PM   #24
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by Sharlikran View Post
Q1) Did I do it right?
Q2) Why does 3 work in all cases. I tried a 2 for the first example with only v1, and v2 and I got a number and a string.
If it works, you did it right
Lua Code:
  1. select(3, string.find(name, pattern))
  2. -- or if you use colon syntax
  3. select(3, (name):find(pattern))
This works because string.find(...) returns starting and ending position of the pattern in the string and then captures that you have enclosed in brackets. If pattern is not found, return value is nil.

Lua Code:
  1. texture = art/maps/glenumbra/daggerfall_base_0.dds
  2. pattern = "([%w%-]+)/([%w%-]+_[%w%-]+)"
  3.  
  4. string.find(texture, pattern)
  5. --or colon syntax:
  6. (texture):find(pattern)
  7. --returns: 5, 34, "glenumbra", "daggerfall_base"
Pattern "(maps/)([%w%-]+)/([%w%-]+_[%w%-]+)" has one more closure, so thats why I have used select(4,...).

Last edited by Garkin : 06/04/14 at 09:00 PM.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Help with Complex Array.


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