05/29/14, 09:21 PM | #1 |
Help with Complex Array.
Help with Complex Array.
Localization/HarvestMapData-en.lua Localization/HarvestMapData-de.lua Localization/HarvestMapData-fr.lua I have three files in my manifest file listed like this. I have them that way to I can use a diff program like BeyoneCompare to line up the names so they are always in the exact sequence. Lua Code:
Lua Code:
Lua Code:
Lua Code:
Zone : alikr : lang : en : subzone : alikr_base : map : Aldunz Lua Code:
Lua Code:
EDIT: Nope none of my variations are working. Last edited by Sharlikran : 05/29/14 at 10:42 PM. |
|
05/29/14, 11:44 PM | #2 |
|
I don't have an answer for you, but after glancing through this, my brain is screaming "anonymous closure".
Not sure that will do anything, though Lua is odd, but this code just bothers me at a gut level. Code:
Harvest.DataStore = { ["alikr"] = Harvest.DataStore[Harvest.langs]["alikr"], ........ } |
05/30/14, 12:36 AM | #3 | |
|
||
05/30/14, 12:39 AM | #4 |
The answer to 'how do I store this info' will largely rest on the question "What are you doing with the info?"
Note that you can store the information as sparsely as you need for storage purposes, and recombine them in game for speed of reference and create lookup tables and the like. |
|
05/30/14, 12:43 AM | #5 |
I am going to try this Lua console from source forge, no idea how to use it yet though. ^_^
Does anyone know a good Lua console that is easy to run like Python and Ruby? Lua Code:
That all works fine, so I have to build off of it and try to apply it to what I want with the map names. |
|
05/30/14, 01:07 AM | #6 | |
|
||
05/30/14, 01:38 AM | #7 | |
Lua Code:
|
||
05/30/14, 01:40 AM | #8 | |
Warning: Spoiler
Lua Code:
If you click the spoiler, as you can see I need to make it modular or I'll end up with a wall of text. Each map file is already over 1200 lines long.
Last edited by Sharlikran : 05/30/14 at 01:58 AM. |
||
05/30/14, 02:00 AM | #9 |
Lua Code:
|
|
05/30/14, 03:10 AM | #10 | |
Essentially: Code:
Harvest.DataStore.en.auridon.base Code:
Harvest = {} Harvest["DataStore"] = {} Harvest["DataStore"]["en"] = {} Harvest["DataStore"]["en"]["auridon"] = {} Harvest["DataStore"]["en"]["auridon"]["base"] = {} Code:
Harvest.DataStore_en_auridon_base Code:
Harvest = {} Harvest["DataStore_en_auridon_base"] = {} I suggest you read up on Lua, PiL is a good resource to learn the syntax of Lua |
||
05/30/14, 03:21 AM | #11 | |
As for your requirements, there are two ways you can go about it, depending on how often the information is requested. If the requests are relatively scarce, you can do as you do above, and just create functions that loop through the tables, til you find a match, then create a chunk of info for your use. If you need more speed, ie, your requests are very very often, you can create lookup tables in memory so that when you reference MapName["Aldunz"] it'll return { [Zone] : "alikr", [lang] : "en", [subzone] : "alikr_base", [map] : "Aldunz"}. This will frontload the work, by doing it all at load, but will speed up lookup. You just need to know what information you're using, and what format you need the result in. I advise you read up on how Lua handles tables and references first though, so you understand just what sort of structures you're creating. |
||
05/30/14, 07:21 AM | #12 | |
Last edited by Sharlikran : 05/30/14 at 08:24 AM. |
||
05/30/14, 07:47 AM | #13 | |
Instead of three line in the manifest like Code:
Localization/HarvestMapData-en.lua Localization/HarvestMapData-de.lua Localization/HarvestMapData-fr.lua Code:
Localization/HarvestMapData-$(language).lua Hope this help, --halja |
||
05/30/14, 08:19 AM | #14 |
Metatables
I understand that you want to store references from three different tables into the single table. If you use unique keys, it can be done using metatables. If you use just indexes (they are not unique), it will be much more complicated.
I don't know if it is exactly what you want, but I think it's worth of trying. Lua Code:
Metatables: http://nova-fusion.com/2011/06/30/lu...bles-tutorial/ http://lua-users.org/wiki/MetatableEvents http://lua-users.org/wiki/MetamethodsTutorial |
|
05/30/14, 08:29 AM | #15 |
Nope, I actually want all three because I want to translate it. I want to pass a foreign map name like "cahute de Cadwell^fd" or "Cadwells Heim^Ng,in" and return "Cadwell's Hovel". I do check for the client language. So if someone were using a french client I want to take "Cadwell's Hovel" or "Cadwells Heim^Ng,in" and return "cahute de Cadwell^fd".
|
|
05/30/14, 08:34 AM | #16 | |
|
||
05/30/14, 08:38 AM | #17 |
|
You don't need for loops to find if something exists in a table if you are not using an array. As long as it is a table, you can use keys like values to check if something exists and work from there. If you are not going to do table-to-table operations, or an operation that HAS to go through all the elements in a table (for example, counting), then you really don't need for loops for them.
http://www.esoui.com/forums/showthre...=8802#post8802 Code:
woodworking = { ["en"] = { ["Ashtree"] = true, ["Beech"] = true, ["Birch"] = true, ["Hickory"] = true, ["Mahogany"] = true, ["Maple"] = true, ["Nightwood"] = true, ["Oak"] = true, ["Yew"] = true, }, } Code:
if woodworking if woodworking.en if woodworking.en.Ashtree local TEST = "Ashtree"; if woodworking.en[TEST] Last edited by lyravega : 05/30/14 at 09:03 AM. |
05/30/14, 08:45 AM | #18 |
Warning: Spoiler
Lua Code:
So that we aren't talking about different code. I am going to try to attempt to convert that exact code to the metatable that Garkin mentioned and do effectively what Garkin and Wobin are talking about. I'll post again when I think I have figured it out. Also I removed the numbers because that was part of Undiscovered. Again the code is used with permission, in case anyone needs to know. So I don't care about the numbers unless the metatable tutorial specifies that I should use a sequential list of values for each map name. Last edited by Sharlikran : 05/30/14 at 08:50 AM. |
|
05/30/14, 09:08 AM | #19 | |
Lua Code:
If you want faster translation, you have to use two tables: lua Code:
Last edited by Garkin : 05/31/14 at 03:21 AM. |
||
06/02/14, 12:40 AM | #20 |
I love it Garkin thanks. I am still trying to cut and paste all the names from the file and organize it. Once I finally get it all done I'll let you know how it works. If I have any issues I'll see if you have time to help. Thanks again.
|
|
ESOUI » Developer Discussions » Lua/XML Help » Help with Complex Array. |
«
Previous Thread
|
Next Thread
»
|
Thread Tools | |
Display Modes | |
|
|