Mercurial > wow > askmrrobot
comparison AskMrRobot-Serializer/AskMrRobot-Serializer.lua @ 133:a0894ffebd15 v62
Bug fixes and tweaks for 8.0.
author | yellowfive |
---|---|
date | Wed, 25 Jul 2018 12:17:24 -0700 |
parents | 318c93e0cd6b |
children | 57be71eccc0a |
comparison
equal
deleted
inserted
replaced
132:2279d58793c6 | 133:a0894ffebd15 |
---|---|
1 -- AskMrRobot-Serializer will serialize and communicate character data between users. | 1 -- AskMrRobot-Serializer will serialize and communicate character data between users. |
2 | 2 |
3 local MAJOR, MINOR = "AskMrRobot-Serializer", 61 | 3 local MAJOR, MINOR = "AskMrRobot-Serializer", 62 |
4 local Amr, oldminor = LibStub:NewLibrary(MAJOR, MINOR) | 4 local Amr, oldminor = LibStub:NewLibrary(MAJOR, MINOR) |
5 | 5 |
6 if not Amr then return end -- already loaded by something else | 6 if not Amr then return end -- already loaded by something else |
7 | 7 |
8 -- event and comm used for player snapshotting on entering combat | 8 -- event and comm used for player snapshotting on entering combat |
282 end | 282 end |
283 end | 283 end |
284 | 284 |
285 -- returns true if currently in a supported instance for logging | 285 -- returns true if currently in a supported instance for logging |
286 function Amr.IsSupportedInstance() | 286 function Amr.IsSupportedInstance() |
287 local zone, _, difficultyIndex, _, _, _, _, instanceMapID = GetInstanceInfo() | 287 local _, _, _, _, _, _, _, instanceMapID = GetInstanceInfo() |
288 return Amr.IsSupportedInstanceId(instanceMapID) | 288 return Amr.IsSupportedInstanceId(instanceMapID) |
289 end | 289 end |
290 | 290 |
291 -- helper to iterate over a table in order by its keys | 291 --[[ |
292 local function spairs(t, order) | |
293 -- collect the keys | |
294 local keys = {} | |
295 for k in pairs(t) do keys[#keys+1] = k end | |
296 | |
297 -- if order function given, sort by it by passing the table and keys a, b, | |
298 -- otherwise just sort the keys | |
299 if order then | |
300 table.sort(keys, function(a,b) return order(t, a, b) end) | |
301 else | |
302 table.sort(keys) | |
303 end | |
304 | |
305 -- return the iterator function | |
306 local i = 0 | |
307 return function() | |
308 i = i + 1 | |
309 if keys[i] then | |
310 return keys[i], t[keys[i]] | |
311 end | |
312 end | |
313 end | |
314 | |
315 -- scanning tooltip b/c for some odd reason the api has no way to get basic item properties... | 292 -- scanning tooltip b/c for some odd reason the api has no way to get basic item properties... |
316 -- so you have to generate a fake item tooltip and search for pre-defined strings in the display text | 293 -- so you have to generate a fake item tooltip and search for pre-defined strings in the display text |
317 local _scanTt | 294 local _scanTt |
318 function Amr.GetScanningTooltip() | 295 function Amr.GetScanningTooltip() |
319 if not _scanTt then | 296 if not _scanTt then |
334 else | 311 else |
335 tt:SetHyperlink(link) | 312 tt:SetHyperlink(link) |
336 end | 313 end |
337 return tt | 314 return tt |
338 end | 315 end |
339 | 316 ]] |
317 | |
318 --[[ | |
340 function Amr.GetItemLevel(bagId, slotId, link) | 319 function Amr.GetItemLevel(bagId, slotId, link) |
341 local itemLevelPattern = _G["ITEM_LEVEL"]:gsub("%%d", "(%%d+)") | 320 local itemLevelPattern = _G["ITEM_LEVEL"]:gsub("%%d", "(%%d+)") |
342 local tt = Amr.GetItemTooltip(bagId, slotId, link) | 321 local tt = Amr.GetItemTooltip(bagId, slotId, link) |
343 | 322 |
344 local regions = { tt:GetRegions() } | 323 local regions = { tt:GetRegions() } |
355 end | 334 end |
356 | 335 |
357 -- 0 means we couldn't find it for whatever reason | 336 -- 0 means we couldn't find it for whatever reason |
358 return 0 | 337 return 0 |
359 end | 338 end |
339 ]] | |
360 | 340 |
361 | 341 |
362 ---------------------------------------------------------------------------------------- | 342 ---------------------------------------------------------------------------------------- |
363 -- Character Reading | 343 -- Character Reading |
364 ---------------------------------------------------------------------------------------- | 344 ---------------------------------------------------------------------------------------- |
365 | 345 |
366 local function readProfessionInfo(prof, ret) | 346 local function readProfessionInfo(prof, ret) |
367 if prof then | 347 if prof then |
368 local name, icon, skillLevel, maxSkillLevel, numAbilities, spelloffset, skillLine, skillModifier = GetProfessionInfo(prof); | 348 local _, _, skillLevel, _, _, _, skillLine = GetProfessionInfo(prof); |
369 if Amr.ProfessionSkillLineToName[skillLine] ~= nil then | 349 if Amr.ProfessionSkillLineToName[skillLine] ~= nil then |
370 ret.Professions[Amr.ProfessionSkillLineToName[skillLine]] = skillLevel; | 350 ret.Professions[Amr.ProfessionSkillLineToName[skillLine]] = skillLevel; |
371 end | 351 end |
372 end | 352 end |
373 end | 353 end |
487 ret.Guild = GetGuildInfo("player") | 467 ret.Guild = GetGuildInfo("player") |
488 ret.ActiveSpec = GetSpecialization() | 468 ret.ActiveSpec = GetSpecialization() |
489 ret.Level = UnitLevel("player"); | 469 ret.Level = UnitLevel("player"); |
490 readHeartOfAzerothLevel(ret) | 470 readHeartOfAzerothLevel(ret) |
491 | 471 |
492 local cls, clsEn = UnitClass("player") | 472 local _, clsEn = UnitClass("player") |
493 ret.Class = clsEn; | 473 ret.Class = clsEn; |
494 | 474 |
495 local race, raceEn = UnitRace("player") | 475 local _, raceEn = UnitRace("player") |
496 ret.Race = raceEn; | 476 ret.Race = raceEn; |
497 ret.Faction = UnitFactionGroup("player") | 477 ret.Faction = UnitFactionGroup("player") |
498 | 478 |
499 ret.Professions = {}; | 479 ret.Professions = {}; |
500 local prof1, prof2, archaeology, fishing, cooking, firstAid = GetProfessions(); | 480 local prof1, prof2, archaeology, fishing, cooking, firstAid = GetProfessions(); |