Implement nameplate sussing
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
--NAME_PLATE_UNIT_ADDED
|
||||||
|
function(e, unit)
|
||||||
|
if not UnitIsPlayer(unit) then return end
|
||||||
|
local name = UnitName(unit)
|
||||||
|
local health = UnitHealth(unit)
|
||||||
|
local player = aura_env.GetPlayer(name)
|
||||||
|
player.health = health
|
||||||
|
player:QueryIfNecessary()
|
||||||
|
WeakAurasSaved.Cyka.Players[name] = player
|
||||||
|
end
|
||||||
@@ -2,7 +2,8 @@
|
|||||||
function()
|
function()
|
||||||
for i = 1, GetNumWhoResults() do
|
for i = 1, GetNumWhoResults() do
|
||||||
local name, guild, level, race, class, zone = GetWhoInfo(i)
|
local name, guild, level, race, class, zone = GetWhoInfo(i)
|
||||||
local player = WeakAurasSaved.Cyka.Players[name] or Player.new(name)
|
print(string.format("Got player info for %s", name))
|
||||||
|
local player = aura_env.GetPlayer(name)
|
||||||
player.guild = guild
|
player.guild = guild
|
||||||
player.race = race
|
player.race = race
|
||||||
WeakAurasSaved.Cyka.Players[name] = player
|
WeakAurasSaved.Cyka.Players[name] = player
|
||||||
|
|||||||
@@ -1,9 +1,20 @@
|
|||||||
|
---@class aura_env
|
||||||
|
---@field config table
|
||||||
|
---@field whoQueued boolean
|
||||||
|
---@field GetPlayer fun(name: string): Player
|
||||||
|
|
||||||
local channelname = aura_env.config.channelname or "lAKDJjZfNgobMblAangc"
|
local channelname = aura_env.config.channelname or "lAKDJjZfNgobMblAangc"
|
||||||
aura_env.whoQueued = false
|
aura_env.whoQueued = false
|
||||||
|
|
||||||
if not WeakAurasSaved.Cyka then WeakAurasSaved.Cyka = {} end
|
if not WeakAurasSaved.Cyka then WeakAurasSaved.Cyka = {} end
|
||||||
if not WeakAurasSaved.Cyka.RaceCache then WeakAurasSaved.Cyka.RaceCache = {} end
|
if not WeakAurasSaved.Cyka.RaceCache then WeakAurasSaved.Cyka.RaceCache = {} end
|
||||||
|
|
||||||
|
aura_env.GetPlayer = function(name)
|
||||||
|
local player = WeakAurasSaved.Cyka.RaceCache[name] or Player.new(name)
|
||||||
|
WeakAurasSaved.Cyka.RaceCache[name] = player
|
||||||
|
return player
|
||||||
|
end
|
||||||
|
|
||||||
---@class Player
|
---@class Player
|
||||||
---@field name string
|
---@field name string
|
||||||
---@field guild string|nil
|
---@field guild string|nil
|
||||||
@@ -22,6 +33,11 @@ Player = {
|
|||||||
self.health = 0
|
self.health = 0
|
||||||
return self
|
return self
|
||||||
end,
|
end,
|
||||||
|
QueryIfNecessary = function(self)
|
||||||
|
if self.whoQueued then return end
|
||||||
|
if self.race ~= nil then return end
|
||||||
|
self:QueryWho()
|
||||||
|
end,
|
||||||
QueryWho = function(self)
|
QueryWho = function(self)
|
||||||
if aura_env.whoQueued then
|
if aura_env.whoQueued then
|
||||||
print(string.format("There is already a who query queued, waiting for player %s", self.name))
|
print(string.format("There is already a who query queued, waiting for player %s", self.name))
|
||||||
|
|||||||
Reference in New Issue
Block a user