ESO Lua File v100011

libraries/zo_recentmessages/zo_recentmessages.lua

[◄ back to folders ]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
ZO_RecentMessages = ZO_Object:Subclass()
function ZO_RecentMessages:New(...)
    local object = ZO_Object.New(self)
    object:Initialize(...)
    return object
end
function ZO_RecentMessages:Initialize(expiryDelayMilliseconds)
    self.recentMessages = {}
    self.expiryDelayMilliseconds = expiryDelayMilliseconds or 3000
end
function ZO_RecentMessages:AddRecent(message)
    self.recentMessages[message] = GetFrameTimeMilliseconds()
end
function ZO_RecentMessages:IsRecent(message)
    return self.recentMessages[message] ~= nil
end
function ZO_RecentMessages:Update(timeNowMilliseconds)
    local recentMessages = self.recentMessages
    local expiry = self.expiryDelayMilliseconds
    for message, timeStamp in pairs(recentMessages) do
        if(timeNowMilliseconds >= (timeStamp + expiry)) then
            recentMessages[message] = nil
        end
    end
end
-- Returns true if the message wasn't recent and should be displayed
-- Adds the given message to the recent queue if the message would be displayed
-- Future calls to this function will update the queue automatically
function ZO_RecentMessages:ShouldDisplayMessage(message)
    if(message == SOUNDS.ABILITY_NOT_ENOUGH_STAMINA or message == SOUNDS.ABILITY_NOT_ENOUGH_MAGICKA or 
        message == SOUNDS.ABILITY_NOT_ENOUGH_ULTIMATE or message == SOUNDS.ITEM_ON_COOLDOWN or
        message == SOUNDS.ABILITY_WEAPON_SWAP_FAIL or message == SOUNDS.ABILITY_NOT_READY or
        message == SOUNDS.ABILITY_TARGET_OUT_OF_LOS or message == SOUNDS.ABILITY_TARGET_OUT_OF_RANGE or
        message == SOUNDS.ABILITY_TARGET_IMMUNE or message == SOUNDS.ABILITY_CASTER_SILENCED or
        message == SOUNDS.ABILITY_CASTER_STUNNED or message == SOUNDS.ABILITY_CASTER_BUSY or
        message == SOUNDS.ABILITY_TARGET_BAD_TARGET or message == SOUNDS.ABILITY_TARGET_DEAD or
        message == SOUNDS.ABILITY_CASTER_DEAD or message == SOUNDS.ABILITY_NOT_ENOUGH_HEALTH or
        message == SOUNDS.ABILITY_FAILED or message == SOUNDS.ABILITY_FAILED_IN_COMBAT or
        message == SOUNDS.ABILITY_FAILED_REQUIREMENTS or message == SOUNDS.ABILITY_CASTER_FEARED or
        message == SOUNDS.ABILITY_CASTER_DISORIENTED or message == SOUNDS.ABILITY_TARGET_TOO_CLOSE or
        message == SOUNDS.ABILITY_WRONG_WEAPON or message == SOUNDS.ABILITY_TARGET_NOT_PVP_FLAGGED or
        message == SOUNDS.ABILITY_CASTER_PACIFIED or message == SOUNDS.ABILITY_CASTER_LEVITATED) then
        return true
    end
    if(self:IsRecent(message)) then 
        return false 
    end
    self:AddRecent(message)
    return true
end