Thread Tools Display Modes
06/04/14, 12:37 PM   #1
Dehr'Metzgar
Join Date: Jun 2014
Posts: 2
How to stop multiple triggers?

Hello i am very new to modding and using .lua code so what i do is take existing addons and change them little to my liking...
Now i am looking for a way to prevent the "execute" notification when target is below 25% from beeing triggered every time i strike target.
Can somebody please help me in how to do this?
i tried kind of in line 28 (notepad++)
The addon i use at the moment is CombatCloud by Sideshow which is pretty awesome by itself only things
i changed was font and labeling on powerbars.
And i implented said "execue" notification without getting how to prevent notification from popping up when its shown on screen allready.
Danke für die Hilfe im Vorraus


here the Power.lua.
Red color is the function i changed for "execute"notification to show on screen:


CombatCloud_PowerEventListener = CombatCloud_EventListener:Subclass()

function CombatCloud_PowerEventListener:New()
local obj = CombatCloud_EventListener:New()
obj:RegisterForEvent(EVENT_POWER_UPDATE, function(...) self:OnEventt(...) end)
self.powerInfo = {
[POWERTYPE_HEALTH] = { wasWarned = false, notificationType = CombatCloudConstants.notificationType.LOW_HEALTH },
[POWERTYPE_STAMINA] = { wasWarned = false, notificationType = CombatCloudConstants.notificationType.LOW_STAMINA },
[POWERTYPE_MAGICKA] = { wasWarned = false, notificationType = CombatCloudConstants.notificationType.LOW_MAGICKA }
}
return obj
end


function CombatCloud_PowerEventListener:OnEventt(unit, powerPoolIndex, powerType, power, powerMax)
if (unit == 'reticleover' and self.powerInfo[powerType] ~= nil) then
local t = CombatCloudSettings.toggles
local threshold = CombatCloudSettings.threshold or 35

if (power <= 0
or powerType == POWERTYPE_HEALTH and not t.showLowHealth
or powerType == POWERTYPE_STAMINA and not t.showLowStamina
or powerType == POWERTYPE_MAGICKA and not t.showLowMagicka) then
return
end
local percent = power / powerMax * 100
local ms = GetGameTimeMilliseconds()
if self.powerInfo[powerType].wasWarned then return end
-- Check if we need to show the warning, else clear the warning
if (percent < threshold and not self.powerInfo[powerType].wasWarned) then
self:TriggerEvent(CombatCloudConstants.eventType.NOTIFICATION, self.powerInfo[powerType].notificationType.EXECUTE, power)
self.powerInfo[powerType].wasWarned = true
end
end

if (unit == 'player' and self.powerInfo[powerType] ~= nil) then
local t = CombatCloudSettings.toggles
local threshold = CombatCloudSettings.threshold or 35

if (power <= 0
or powerType == POWERTYPE_HEALTH and not t.showLowHealth
or powerType == POWERTYPE_STAMINA and not t.showLowStamina
or powerType == POWERTYPE_MAGICKA and not t.showLowMagicka) then
return
end
local percent = power / powerMax * 100

-- Check if we need to show the warning, else clear the warning
if (percent < threshold and not self.powerInfo[powerType].wasWarned) then
self:TriggerEvent(CombatCloudConstants.eventType.NOTIFICATION, self.powerInfo[powerType].notificationType, power)
self.powerInfo[powerType].wasWarned = true
elseif (percent > threshold + 10) then -- Add 10 to create some sort of buffer, else the warning can fire more than once depending on the power regen of the player
self.powerInfo[powerType].wasWarned = false
end
end
end
  Reply With Quote
06/04/14, 02:30 PM   #2
Iyanga
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 183
Sorry, I already don't get why the original code works.
  Reply With Quote
06/04/14, 02:38 PM   #3
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
There is needed a bit more code to make it work. I think the best way is to ask Sideshow to add it...

If you want do all the job, you will need to add your new notification type to the Power.lua, Constants.lua, Notification.lua, Menu.lua, Defaults.lua and to the localization files.

If you just want to make it somehow work with no settings, you will need to make at least the following changes:
changed parts of Core\EventViewers\Notification.lua:
Lua Code:
  1. --lines 1 - 42 from the original code here
  2.     elseif (notificationType == 'COMBATCLOUD_NOTIFICATION_TYPE_EXECUTE' ) then
  3.         color = {1,0,0,1} --red color, format is {r, g, b, a}
  4.         text = self:FormatString('%t!', { value = value, text = 'Execute!' }) --displayed text will be "Execute!"
  5. --rest of the original code (lines 43 - 76) here

changed part of Core\EventListeners\Power.lua:
Lua Code:
  1. --lines 1-10 from the original code
  2.     self.executeWarning = false
  3. --lines 11-35 from the original code
  4.     if (unit == 'reticleover' and powerType == POWERTYPE_HEALTH) then
  5.         if not self.executeWarning and (power / powerMax) < 0.25 then --target's health is below 25%
  6.             self:TriggerEvent(CombatCloudConstants.eventType.NOTIFICATION, 'COMBATCLOUD_NOTIFICATION_TYPE_EXECUTE', power)
  7.             self.executeWarning = true
  8.         elseif (power / powerMax) > 0.35 --target's health > 35%
  9.             self.executeWarning = false
  10.         end
  11.     end
  12. end --line 36 from the original code
  Reply With Quote
06/04/14, 06:08 PM   #4
Dehr'Metzgar
Join Date: Jun 2014
Posts: 2
thank you for fast answers!
i did changes to other .lua files but didnt post the code in forum. what im trying to say here is that i actually managed to make an "execute!" appear on screen whenever i hit an target which is < 25 percent health.
so that works fine but it will show up ALLWAYS when i strike the target again. this way i sometimes get about 4-5 "execute!" notifications on screen at the same time.
i need some code that stops "execute!" -notification when there is already an "execute!" -notification on srceen. maybe you can help me with this.

sry for my writing... kind of not to the point since i am no native speaker....
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » How to stop multiple triggers?

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off