comparison Import.lua @ 165:3be9cc6f7d20 v77

Updated for 8.2, initial essence support.
author yellowfive
date Tue, 25 Jun 2019 10:27:20 -0700
parents f27a7c64b21f
children 5c586ff5fee5
comparison
equal deleted inserted replaced
164:a6aa4fa7e2dd 165:3be9cc6f7d20
244 end 244 end
245 245
246 return importData 246 return importData
247 end 247 end
248 248
249 local function parseEssenceList(essenceString)
250 local ret = {}
251
252 local parts = { strsplit("_", essenceString) }
253 for i = 1, #parts do
254 local essence = { strsplit(".", parts[i]) }
255 table.insert(ret, { tonumber(essence[0]), tonumber(essence[1]), tonumber(essence[2]) })
256 end
257
258 return ret
259 end
260
249 -- 261 --
250 -- Import a character, returning nil on success, otherwise an error message, import result stored in the db. 262 -- Import a character, returning nil on success, otherwise an error message, import result stored in the db.
251 -- 263 --
252 function Amr:ImportCharacter(data, isTest, isChild) 264 function Amr:ImportCharacter(data, isTest, isChild)
253 265
261 -- if multiple setups are included in the data, parse each individually, then quit 273 -- if multiple setups are included in the data, parse each individually, then quit
262 local specParts = { strsplit("\n", data) } 274 local specParts = { strsplit("\n", data) }
263 275
264 if #specParts > 1 and specParts[1] == "_junk_" then 276 if #specParts > 1 and specParts[1] == "_junk_" then
265 -- if the string starts with "_junk_" then it is the junk list 277 -- if the string starts with "_junk_" then it is the junk list
266 Amr:ImportJunkList(specParts[2], currentPlayerData) 278 return Amr:ImportJunkList(specParts[2], currentPlayerData)
267 return
268 279
269 elseif #specParts > 1 then 280 elseif #specParts > 1 then
270 -- clear out any previously-imported BiB setups when importing new ones (non-BiB will always be imported one at a time) 281 -- clear out any previously-imported BiB setups when importing new ones (non-BiB will always be imported one at a time)
271 for i = #Amr.db.char.GearSetups, 1, -1 do 282 for i = #Amr.db.char.GearSetups, 1, -1 do
272 if Amr.db.char.GearSetups[i].IsBib then 283 if Amr.db.char.GearSetups[i].IsBib then
341 end 352 end
342 end 353 end
343 354
344 -- if we make it this far, the data is valid, so read item information 355 -- if we make it this far, the data is valid, so read item information
345 local specSlot = tonumber(parts[11]) 356 local specSlot = tonumber(parts[11])
346 357
347 local importData = parseItemList(parts, 16, "n/a", true) 358 local essences = parseEssenceList(parts[15])
359
360 local importData = parseItemList(parts, 17, "n/a", true)
348 361
349 -- extra information contains setup id, display label, then extra enchant info 362 -- extra information contains setup id, display label, then extra enchant info
350 parts = { strsplit("@", data1[3]) } 363 parts = { strsplit("@", data1[3]) }
351 364
352 local setupId = parts[2] 365 local setupId = parts[2]
396 local result = { 409 local result = {
397 IsBib = string.sub(setupId, 1, 3) ~= "AMR", 410 IsBib = string.sub(setupId, 1, 3) ~= "AMR",
398 SpecSlot = tonumber(specSlot), 411 SpecSlot = tonumber(specSlot),
399 Id = setupId, 412 Id = setupId,
400 Label = setupName, 413 Label = setupName,
401 Gear = importData 414 Gear = importData,
415 Essences = essences
402 } 416 }
403 417
404 if not result.IsBib then 418 if not result.IsBib then
405 -- replace if this setup already exists 419 -- replace if this setup already exists
406 local key = -1 420 local key = -1