Prega
11-21-2010, 09:41 AM
i ve written some code to display Holy power for my other paladins in my main screen.
wasted some hours trying to manage Holy power from others with combat log parsing.
this approach doesn t requires communication between clients, but it s incredibly complicated.
Following Jamba example, with communication between clients, this task is really simple.
I m not an expert about addon scripting, Lua and wow api.
how it works? simple mode. atm there are not configuration options.
http://img98.imageshack.us/img98/1528/immagineex.jpg
- there are 2 .lua files: 1) file_1 for main; 2)file_2 for slaves
- atm many things are not implemented. Addon shows values for Holy power using simply a numer (0-3 range).
- no texture use atm.
- font type and dimension is defined in "text1:SetFont("Fonts\\ARIALN.TTF", 32)" line: it s customizable path and dimension.
-
- Lua files are different for Main and slaves. if you want test it with a main char ='other then paladin', you need to change code a bit.
nothing complicated but frame1 and event UNIT_POWER and handler1 function are not needed and can generate errors if left.
- MyGrp table is my grp composition.
now the code.
Lua code file_1:
-- player [1] is always leader. others are 2-5
-- Holy Power values are shown with text
local MyGrp = {
[1] = "Prega",
[2] = "Alad",
[3] = "Redcrox" ,
[4] = "Whitecrox" ,
[5] = "Yargo"
}
---------------------------------------
---------------------------------------
local gn = #MyGrp
local myname =UnitName ("player")
local w = "WHISPER"
-------------FRAMES--------------------------------------------
----------- all frames are movable by default with left mouse drag
--------------------------frame1=PREGA--local frame for main(prega) hp--
frame1 = CreateFrame("Frame", "frame1", UIParent)
text1 = frame1:CreateFontString()
frame1:SetPoint("CENTER",0, -100)
frame1:SetWidth(128)
frame1:SetHeight(128)
frame1:SetMovable(true)
frame1:EnableMouse(true)
text1:SetAllPoints(frame1)
text1:SetFont("Fonts\\ARIALN.TTF", 32)
frame1:RegisterForDrag("LeftButton")
frame1:SetScript("OnDragStart", function(self) self:StartMoving() end)
frame1:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
--------------------------frame2=ALAD
frame2 = CreateFrame("Frame", "frame2", UIParent)
text2 = frame2:CreateFontString()
frame2:SetPoint("CENTER",0, -80)
frame2:SetWidth(128)
frame2:SetHeight(128)
frame2:SetMovable(true)
frame2:EnableMouse(true)
text2:SetAllPoints(frame2)
text2:SetFont("Fonts\\ARIALN.TTF", 32)
frame2:RegisterForDrag("LeftButton")
frame2:SetScript("OnDragStart", function(self) self:StartMoving() end)
frame2:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
---------------------------frame3=REDCROX
frame3 = CreateFrame("Frame", "frame3", UIParent)
text3 = frame3:CreateFontString()
frame3:SetPoint("CENTER",0, -80)
frame3:SetWidth(128)
frame3:SetHeight(128)
frame3:SetMovable(true)
frame3:EnableMouse(true)
text3:SetAllPoints(frame3)
text3:SetFont("Fonts\\ARIALN.TTF", 32)
frame3:RegisterForDrag("LeftButton")
frame3:SetScript("OnDragStart", function(self) self:StartMoving() end)
frame3:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
---------------------------frame4=WHITECROX
frame4 = CreateFrame("Frame", "frame4", UIParent)
text4 = frame4:CreateFontString()
frame4:SetPoint("CENTER",0, -80)
frame4:SetWidth(128)
frame4:SetHeight(128)
frame4:SetMovable(true)
frame4:EnableMouse(true)
text4:SetAllPoints(frame4)
text4:SetFont("Fonts\\ARIALN.TTF", 32)
frame4:RegisterForDrag("LeftButton")
frame4:SetScript("OnDragStart", function(self) self:StartMoving() end)
frame4:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
---------------------------frame5=YARGO
frame5 = CreateFrame("Frame", "frame5", UIParent)
text5 = frame5:CreateFontString()
frame5:SetPoint("CENTER",0, -80)
frame5:SetWidth(128)
frame5:SetHeight(128)
frame5:SetMovable(true)
frame5:EnableMouse(true)
text5:SetAllPoints(frame5)
text5:SetFont("Fonts\\ARIALN.TTF", 32)
frame5:RegisterForDrag("LeftButton")
frame5:SetScript("OnDragStart", function(self) self:StartMoving() end)
frame5:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
--------handle event UNIT POWER for main:not useful if main is not a paladin
function handler1(self,event, ...)
local source, type = select(1, ...);
if source == "player" and type == "HOLY_POWER" then
p = UnitPower("player",9)
text1:SetText(p)
end
end
-----handle event CHAT_MSG_ADDON: sources are other members of team, values of HP for all are displayed on main screen only atm.
function handler2 (self, event, ...)
local prefix, msg, distr, sender = ...;
if prefix == "Multihp" and msg and sender == MyGrp[2] then
msgn = tonumber(msg)
text2:SetText(msgn)
elseif prefix == "Multihp" and msg and sender == MyGrp[3] then
msgn = tonumber(msg)
text3:SetText(msgn)
elseif prefix == "Multihp" and msg and sender == MyGrp[4] then
msgn = tonumber(msg)
text4:SetText(msgn)
elseif prefix == "Multihp" and msg and sender == MyGrp[5] then
msgn = tonumber(msg)
text5:SetText(msgn)
end
end
-------- set handlers and register events for each frames
frame1:SetScript("OnEvent", handler1)
frame2:SetScript("OnEvent", handler2)
frame3:SetScript("OnEvent", handler2)
frame4:SetScript("OnEvent", handler2)
frame5:SetScript("OnEvent", handler2)
frame1:RegisterEvent("UNIT_POWER")
frame2:RegisterEvent("CHAT_MSG_ADDON")
frame3:RegisterEvent("CHAT_MSG_ADDON")
frame4:RegisterEvent("CHAT_MSG_ADDON")
frame5:RegisterEvent("CHAT_MSG_ADDON")and this part is for other paladins (slaves): file_2
---------------------------------------
local gl = "Prega"
local myname =UnitName ("player")
local w = "WHISPER"
--------------------------frame1=LOCAL CHAR--local frame for current char hp--
frame1 = CreateFrame("Frame", "frame1", UIParent)
text1 = frame1:CreateFontString()
frame1:SetPoint("CENTER",0, -100)
frame1:SetWidth(128)
frame1:SetHeight(128)
frame1:SetMovable(true)
frame1:EnableMouse(true)
text1:SetAllPoints(frame1)
text1:SetFont("Fonts\\ARIALN.TTF", 32)
frame1:RegisterForDrag("LeftButton")
frame1:SetScript("OnDragStart", function(self) self:StartMoving() end)
frame1:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
-------- handle event UNIT_POWER and dispatch current char HPower to main char
function handler1(self,event, ...)
local source, type = select(1, ...);
if source == "player" and type == "HOLY_POWER" then
p = UnitPower("player",9)
text1:SetText(p)
SendAddonMessage("Multihp", p, w, gl)
end
end
-------Register event and define handler for event
frame1:SetScript("OnEvent", handler1)
frame1:RegisterEvent("UNIT_POWER")
wasted some hours trying to manage Holy power from others with combat log parsing.
this approach doesn t requires communication between clients, but it s incredibly complicated.
Following Jamba example, with communication between clients, this task is really simple.
I m not an expert about addon scripting, Lua and wow api.
how it works? simple mode. atm there are not configuration options.
http://img98.imageshack.us/img98/1528/immagineex.jpg
- there are 2 .lua files: 1) file_1 for main; 2)file_2 for slaves
- atm many things are not implemented. Addon shows values for Holy power using simply a numer (0-3 range).
- no texture use atm.
- font type and dimension is defined in "text1:SetFont("Fonts\\ARIALN.TTF", 32)" line: it s customizable path and dimension.
-
- Lua files are different for Main and slaves. if you want test it with a main char ='other then paladin', you need to change code a bit.
nothing complicated but frame1 and event UNIT_POWER and handler1 function are not needed and can generate errors if left.
- MyGrp table is my grp composition.
now the code.
Lua code file_1:
-- player [1] is always leader. others are 2-5
-- Holy Power values are shown with text
local MyGrp = {
[1] = "Prega",
[2] = "Alad",
[3] = "Redcrox" ,
[4] = "Whitecrox" ,
[5] = "Yargo"
}
---------------------------------------
---------------------------------------
local gn = #MyGrp
local myname =UnitName ("player")
local w = "WHISPER"
-------------FRAMES--------------------------------------------
----------- all frames are movable by default with left mouse drag
--------------------------frame1=PREGA--local frame for main(prega) hp--
frame1 = CreateFrame("Frame", "frame1", UIParent)
text1 = frame1:CreateFontString()
frame1:SetPoint("CENTER",0, -100)
frame1:SetWidth(128)
frame1:SetHeight(128)
frame1:SetMovable(true)
frame1:EnableMouse(true)
text1:SetAllPoints(frame1)
text1:SetFont("Fonts\\ARIALN.TTF", 32)
frame1:RegisterForDrag("LeftButton")
frame1:SetScript("OnDragStart", function(self) self:StartMoving() end)
frame1:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
--------------------------frame2=ALAD
frame2 = CreateFrame("Frame", "frame2", UIParent)
text2 = frame2:CreateFontString()
frame2:SetPoint("CENTER",0, -80)
frame2:SetWidth(128)
frame2:SetHeight(128)
frame2:SetMovable(true)
frame2:EnableMouse(true)
text2:SetAllPoints(frame2)
text2:SetFont("Fonts\\ARIALN.TTF", 32)
frame2:RegisterForDrag("LeftButton")
frame2:SetScript("OnDragStart", function(self) self:StartMoving() end)
frame2:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
---------------------------frame3=REDCROX
frame3 = CreateFrame("Frame", "frame3", UIParent)
text3 = frame3:CreateFontString()
frame3:SetPoint("CENTER",0, -80)
frame3:SetWidth(128)
frame3:SetHeight(128)
frame3:SetMovable(true)
frame3:EnableMouse(true)
text3:SetAllPoints(frame3)
text3:SetFont("Fonts\\ARIALN.TTF", 32)
frame3:RegisterForDrag("LeftButton")
frame3:SetScript("OnDragStart", function(self) self:StartMoving() end)
frame3:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
---------------------------frame4=WHITECROX
frame4 = CreateFrame("Frame", "frame4", UIParent)
text4 = frame4:CreateFontString()
frame4:SetPoint("CENTER",0, -80)
frame4:SetWidth(128)
frame4:SetHeight(128)
frame4:SetMovable(true)
frame4:EnableMouse(true)
text4:SetAllPoints(frame4)
text4:SetFont("Fonts\\ARIALN.TTF", 32)
frame4:RegisterForDrag("LeftButton")
frame4:SetScript("OnDragStart", function(self) self:StartMoving() end)
frame4:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
---------------------------frame5=YARGO
frame5 = CreateFrame("Frame", "frame5", UIParent)
text5 = frame5:CreateFontString()
frame5:SetPoint("CENTER",0, -80)
frame5:SetWidth(128)
frame5:SetHeight(128)
frame5:SetMovable(true)
frame5:EnableMouse(true)
text5:SetAllPoints(frame5)
text5:SetFont("Fonts\\ARIALN.TTF", 32)
frame5:RegisterForDrag("LeftButton")
frame5:SetScript("OnDragStart", function(self) self:StartMoving() end)
frame5:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
--------handle event UNIT POWER for main:not useful if main is not a paladin
function handler1(self,event, ...)
local source, type = select(1, ...);
if source == "player" and type == "HOLY_POWER" then
p = UnitPower("player",9)
text1:SetText(p)
end
end
-----handle event CHAT_MSG_ADDON: sources are other members of team, values of HP for all are displayed on main screen only atm.
function handler2 (self, event, ...)
local prefix, msg, distr, sender = ...;
if prefix == "Multihp" and msg and sender == MyGrp[2] then
msgn = tonumber(msg)
text2:SetText(msgn)
elseif prefix == "Multihp" and msg and sender == MyGrp[3] then
msgn = tonumber(msg)
text3:SetText(msgn)
elseif prefix == "Multihp" and msg and sender == MyGrp[4] then
msgn = tonumber(msg)
text4:SetText(msgn)
elseif prefix == "Multihp" and msg and sender == MyGrp[5] then
msgn = tonumber(msg)
text5:SetText(msgn)
end
end
-------- set handlers and register events for each frames
frame1:SetScript("OnEvent", handler1)
frame2:SetScript("OnEvent", handler2)
frame3:SetScript("OnEvent", handler2)
frame4:SetScript("OnEvent", handler2)
frame5:SetScript("OnEvent", handler2)
frame1:RegisterEvent("UNIT_POWER")
frame2:RegisterEvent("CHAT_MSG_ADDON")
frame3:RegisterEvent("CHAT_MSG_ADDON")
frame4:RegisterEvent("CHAT_MSG_ADDON")
frame5:RegisterEvent("CHAT_MSG_ADDON")and this part is for other paladins (slaves): file_2
---------------------------------------
local gl = "Prega"
local myname =UnitName ("player")
local w = "WHISPER"
--------------------------frame1=LOCAL CHAR--local frame for current char hp--
frame1 = CreateFrame("Frame", "frame1", UIParent)
text1 = frame1:CreateFontString()
frame1:SetPoint("CENTER",0, -100)
frame1:SetWidth(128)
frame1:SetHeight(128)
frame1:SetMovable(true)
frame1:EnableMouse(true)
text1:SetAllPoints(frame1)
text1:SetFont("Fonts\\ARIALN.TTF", 32)
frame1:RegisterForDrag("LeftButton")
frame1:SetScript("OnDragStart", function(self) self:StartMoving() end)
frame1:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
-------- handle event UNIT_POWER and dispatch current char HPower to main char
function handler1(self,event, ...)
local source, type = select(1, ...);
if source == "player" and type == "HOLY_POWER" then
p = UnitPower("player",9)
text1:SetText(p)
SendAddonMessage("Multihp", p, w, gl)
end
end
-------Register event and define handler for event
frame1:SetScript("OnEvent", handler1)
frame1:RegisterEvent("UNIT_POWER")