I hate reviving an old thread but this one is really interesting... I do have one question for you
Here's Diiver's code for his casting bar
Code:
CASTING_BAR_ALPHA_STEP = 0.05;
CASTING_BAR_FLASH_STEP = 0.2;
CASTING_BAR_HOLD_TIME = 1;
function DS_CastingBarFrame_OnLoad()
this:RegisterEvent("SPELLCAST_START");
this:RegisterEvent("SPELLCAST_STOP");
this:RegisterEvent("SPELLCAST_FAILED");
this:RegisterEvent("SPELLCAST_INTERRUPTED");
this:RegisterEvent("SPELLCAST_DELAYED");
this:RegisterEvent("SPELLCAST_CHANNEL_START");
this:RegisterEvent("SPELLCAST_CHANNEL_UPDATE");
this.casting = nil;
this.holdTime = 0;
CastingBarFrame_OnEvent = DS_CastingBarFrame_OnEvent
CastingBarFrame_OnUpdate = DS_CastingBarFrame_OnUpdate
--tried just using CastingBarFrame:Hide(); below too. that didn't work either
if DS_CastingBarFrame:IsVisible() then
CastingBarFrame:Hide();
end
end
function DS_CastingBarFrame_OnEvent()
if ( event == "SPELLCAST_START" ) then
DS_CastingBarFrameStatusBar:SetStatusBarColor(1.0, 0.7, 0.0);
DS_CastingBarSpark:Show();
this.startTime = GetTime();
this.maxValue = this.startTime + (arg2 / 1000);
DS_CastingBarFrameStatusBar:SetMinMaxValues(this.s tartTime, this.maxValue);
DS_CastingBarFrameStatusBar:SetValue(this.startTim e);
DS_CastingBarText:SetText(arg1);
this:SetAlpha(1.0);
this.DS_holdTime = 0;
this.DS_casting = 1;
this.fadeOut = nil;
this:Show();
this.mode = "DS_casting";
elseif ( event == "SPELLCAST_STOP" ) then
if ( not this:IsVisible() ) then
this:Hide();
end
if ( this:IsShown() ) then
DS_CastingBarFrameStatusBar:SetValue(this.maxValue );
DS_CastingBarFrameStatusBar:SetStatusBarColor(0.0, 1.0, 0.0);
DS_CastingBarSpark:Hide();
DS_CastingBarFlash:SetAlpha(0.0);
DS_CastingBarFlash:Show();
this.DS_casting = nil;
this.flash = 1;
this.fadeOut = 1;
this.mode = "flash";
end
elseif ( event == "SPELLCAST_FAILED" or event == "SPELLCAST_INTERRUPTED" ) then
if ( this:IsShown() ) then
DS_CastingBarFrameStatusBar:SetValue(this.maxValue );
DS_CastingBarFrameStatusBar:SetStatusBarColor(1.0, 0.0, 0.0);
DS_CastingBarSpark:Hide();
if ( event == "SPELLCAST_FAILED" ) then
DS_CastingBarText:SetText(FAILED);
else
DS_CastingBarText:SetText(INTERRUPTED);
end
this.DS_casting = nil;
this.fadeOut = 1;
this.DS_holdTime = GetTime() + CASTING_BAR_HOLD_TIME;
end
elseif ( event == "SPELLCAST_DELAYED" ) then
if( this:IsShown() ) then
this.startTime = this.startTime + (arg1 / 1000);
this.maxValue = this.maxValue + (arg1 / 1000);
DS_CastingBarFrameStatusBar:SetMinMaxValues(this.s tartTime, this.maxValue);
end
elseif ( event == "SPELLCAST_CHANNEL_START" ) then
DS_CastingBarFrameStatusBar:SetStatusBarColor(1.0, 0.7, 0.0);
DS_CastingBarSpark:Show();
this.maxValue = 1;
this.startTime = GetTime();
this.endTime = this.startTime + (arg1 / 1000);
this.duration = arg1 / 1000;
DS_CastingBarFrameStatusBar:SetMinMaxValues(this.s tartTime, this.endTime);
DS_CastingBarFrameStatusBar:SetValue(this.endTime) ;
DS_CastingBarText:SetText(arg2);
this:SetAlpha(1.0);
this.DS_holdTime = 0;
this.DS_casting = nil;
this.channeling = 1;
this.fadeOut = nil;
this:Show();
elseif ( event == "SPELLCAST_CHANNEL_UPDATE" ) then
if ( arg1 == 0 ) then
this.channeling = nil;
elseif ( this:IsShown() ) then
local origDuration = this.endTime - this.startTime
this.endTime = GetTime() + (arg1 / 1000)
this.startTime = this.endTime - origDuration
--this.endTime = this.startTime + (arg1 / 1000);
DS_CastingBarFrameStatusBar:SetMinMaxValues(this.s tartTime, this.endTime);
end
end
end
function DS_CastingBarFrame_OnUpdate()
if ( this.DS_casting ) then
local status = GetTime();
if ( status > this.maxValue ) then
status = this.maxValue
end
DS_CastingBarFrameStatusBar:SetValue(status);
DS_CastingBarFlash:Hide();
local sparkPosition = ((status - this.startTime) / (this.maxValue - this.startTime)) * 195;
if ( sparkPosition < 0 ) then
sparkPosition = 0;
end
DS_CastingBarSpark:SetPoint("CENTER", "DS_CastingBarFrameStatusBar", "LEFT", sparkPosition, 0);
elseif ( this.channeling ) then
local time = GetTime();
if ( time > this.endTime ) then
time = this.endTime
end
if ( time == this.endTime ) then
this.channeling = nil;
this.fadeOut = 1;
return;
end
local barValue = this.startTime + (this.endTime - time);
DS_CastingBarFrameStatusBar:SetValue( barValue );
DS_CastingBarFlash:Hide();
local sparkPosition = ((barValue - this.startTime) / (this.endTime - this.startTime)) * 195;
DS_CastingBarSpark:SetPoint("CENTER", "DS_CastingBarFrameStatusBar", "LEFT", sparkPosition, 0);
elseif ( GetTime() < this.DS_holdTime ) then
return;
elseif ( this.flash ) then
local alpha = DS_CastingBarFlash:GetAlpha() + CASTING_BAR_FLASH_STEP;
if ( alpha < 1 ) then
DS_CastingBarFlash:SetAlpha(alpha);
else
this.flash = nil;
end
elseif ( this.fadeOut ) then
local alpha = this:GetAlpha() - CASTING_BAR_ALPHA_STEP;
if ( alpha > 0 ) then
this:SetAlpha(alpha);
else
this.fadeOut = nil;
this:Hide();
end
end
end
function DS_CastingBarFrame_UpdatePosition()
local castingBarPosition = 60;
if ( PetActionBarFrame:IsVisible() or ShapeshiftBarFrame:IsVisible() ) then
castingBarPosition = castingBarPosition + 40;
end
if ( MultiBarBottomLeft:IsVisible() ) then
castingBarPosition = castingBarPosition + 40;
end
DS_CastingBarFrame:SetPoint("BOTTOM", "UIParent", "BOTTOM", 0, castingBarPosition);
end
I kinda understand more or less how it could possibly change in someway teh casting but I'm not going to ask you to explain the entire code :P There's just one thing bothring me... Actualy I think I just found out the answer to my question...
this.DS_casting = 1;
this.fadeOut = nil;
"this." is a table, right? I'm kinda mising it up with "this:"...