Not sure if this is where to post this but i found it useful. I needed a way to track my Elemental Mastery cooldown since it changes with the Tier 10 shamy 2pc. So i changed around the Spell info feature and created my own Vars CD Info. Has a fract var, spell name, vspellname, spell icon ect.
anyway if there is already a feature in RDX to accomplish this i have not run into it so here is the code that you can put in your autoexec:
Code:
RDX.RegisterFeature({
name = "Vars CD Info";
title = i18n("Vars CD Info"); category = i18n("Variables: Unit Status");
multiple = true;
IsPossible = function(state)
if not state:Slot("EmitPaintPreamble") then return nil; end
return true;
end;
ExposeFeature = function(desc, state, errs)
state:AddSlot("BoolVar_spell_" .. desc.name .. "_casting");
state:AddSlot("TextData_spell_" .. desc.name .. "_name_rank");
state:AddSlot("TextData_spell_" .. desc.name .. "_CDLeftText");
state:AddSlot("TextData_spell_" .. desc.name .. "_vertical_spell_name_rank");
state:AddSlot("TexVar_spell_" .. desc.name .. "_icon");
state:AddSlot("FracVar_spell_" .. desc.name .. "_cdinfofract");
return true;
end;
ApplyFeature = function(desc, state)
local mux = state:GetContainingWindowState():GetSlotValue("Multiplexer");
local cdumask = mux:GetPaintMask("SPELL_UPDATE_COOLDOWN");
local smask = mux:GetPaintMask("SPELL_UPDATE_USABLE");
local umask = mux:GetPaintMask("CAST_TIMER_STOP");
state:Attach(state:Slot("EmitPaintPreamble"), true, function(code)
code:AppendCode([[
local spell_channeled, spell_casting, spell_castingOrChanneled, spell_icon, spell_name_rank, vertical_spell_name_rank, spell_fractvar, spell_start, spell_duration = nil, nil, nil, "", "", "", 0, 0, 0;
spell_name, spell_rank, spell_icon, _, _, _, _, _, _ = GetSpellInfo("]] .. desc.cd .. [[");
start, duration, enabled = GetSpellCooldown(spell_name);
if duration ~= nil and duration > 0 then
spell_]] .. desc.name .. [[_casting = true;
spell_]] .. desc.name .. [[_cdinfofract =(start + duration - GetTime()) / duration;
spell_]] .. desc.name .. [[_CDLeftText = string.format("%.3f", (start + duration - GetTime()));
spell_]] .. desc.name .. [[_icon = spell_icon;
else
spell_]] .. desc.name .. [[_casting = false;
spell_]] .. desc.name .. [[_CDLeftText = "";
spell_]] .. desc.name .. [[_cdinfofract = 0;
spell_name = "";
spell_]] .. desc.name .. [[_icon = "";
end
if spell_name and spell_name ~= "" then
spell_]] .. desc.name .. [[_name_rank = spell_name;
vertical_spell_name_rank = spell_name;
if spell_rank and spell_rank ~= "" then
spell_]] .. desc.name .. [[_name_rank = spell_]] .. desc.name .. [[_name_rank .. " (" .. spell_rank .. ")";
vertical_spell_name_rank = vertical_spell_name_rank .. spell_rank;
end
vertical_spell_name_rank = string.gsub(vertical_spell_name_rank, "[^A-Z:0-9.]","")
if string.len(vertical_spell_name_rank) > 5 then
vertical_spell_name_rank = string.sub(vertical_spell_name_rank,1,5);
end
local vtext = "";
for i=1,string.len(vertical_spell_name_rank) do
vtext = vtext..string.sub(vertical_spell_name_rank,i,i).."\n";
end
spell_]] .. desc.name .. [[_vertical_spell_name_rank = vtext;
end
]]);
end);
mux:Event_UnitMask("SPELL_UPDATE_COOLDOWN", cdumask);
mux:Event_UnitMask("SPELL_UPDATE_USABLE", smask);
mux:Event_UnitMask("CAST_TIMER_STOP", umask);
end;
UIFromDescriptor = function(desc, parent, state)
local ui = VFLUI.CompoundFrame:new(parent);
local iname = VFLUI.LabeledEdit:new(ui, 100);
iname:Show();
iname:SetText(i18n("Variable Name"));
if desc and desc.name then iname.editBox:SetText(desc.name); end
ui:InsertFrame(iname);
local cd = VFLUI.LabeledEdit:new(ui, 150);
cd:SetText(i18n("Spell ID/Name"));
cd:Show();
if desc and desc.cd then
cd.editBox:SetText(desc.cd);
end
ui:InsertFrame(cd);
function ui:GetDescriptor()
return {
feature = i18n("Vars CD Info");
name = iname.editBox:GetText();
cd = cd.editBox:GetText();
};
end
ui.Destroy = VFL.hook(function(s) s.GetDescriptor = nil; end, ui.Destroy);
return ui;
end;
CreateDescriptor = function() return { feature = i18n("Vars CD Info"); name = "cdinfo1"; cd = 16166}; end
});