Quantcast The easiest way to create a "castbar"? - WoWInterface
Thread Tools Display Modes
02-09-11, 01:04 AM   #1
Anuki
A Defias Bandit
Join Date: Feb 2011
Posts: 3
The easiest way to create a "castbar"?

Hi Developers.

I'm fairly new at programming addons.. I have completed my first addon last week, which was purely chatframe-based.
Now I've a new idea for an addon, which should show a kind of castbar for a few seconds, after an event is fired.

I really have no idea how frames, etc works in wow and the tutorials I've found couldn't give me the information I need and the code of, for example, quartz is not that beginner-friendly.

Is there a fairly simple way to create a kind of castbar quick and easy? Does anyone know a good tutorial (I don't like to use, for example, Ace, because I want to learn it for myself, how it works )?
A simple help, how to show a graphic for a few seconds ingame (best as a function) would be perfect and I would be happy if someone takes the time to help me here.

Best regards,
Anuki

P.S.: I hope my English is good enough to understand me
  Reply With Quote
02-09-11, 05:06 AM   #2
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 663
http://www.wowpedia.org/Widget_API#StatusBar

WoW offers a simple widget you can use.
lua Code:
  1. local b = CreateFrame("StatusBar", "MyOwnStatusBar")
  2.   b:SetWidth(100)
  3.   b:SetHeight(20)
  4.   b:SetPoint("CENTER",UIParent,"CENTER",0 , 0)
  5.   b:SetMinMaxValues(1,100)
  6.   b:SetOrientation("HORIZONTAL")
  7.   b:SetValue(75)
  8.   b:SetStatusBarTexture("Interface\\TargetingFrame\\UI-StatusBar")
  9.   b:GetStatusBarTexture():SetHorizTile(false)
  10.   b:GetStatusBarTexture():SetVertTile(false)
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
02-09-11, 07:02 AM   #3
nightcracker
A Molten Giant
 
nightcracker's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 716
Just one thing, shouldn't the statusbar range from 0-100 instead of 1-100?
__________________
Three things are certain,
Death, taxes and site not found,
You, victim of one.
  Reply With Quote
02-09-11, 08:20 AM   #4
Anuki
A Defias Bandit
Join Date: Feb 2011
Posts: 3
Hey you both .
Thank you for your answers!

I told you, that I'm really a beginner so I have some questions and maybe, you'll think "omg.." .

I've tried to create a frame into my parentframe ( createframe() ) but I have no idea, how to handle it.

Here are my .lua and .xml code, can you please tell me, how I can commit the local frame "SchoolLockStatusBar" into the function SchoolLock_ParseParameters (called at line 13)?

Thanks a lot, if you can help me.

PHP Code:
function SchoolLock_OnLoad(this)    
    
local b this.CreateFrame("StatusBar""SchoolLockStatusBar")
    
b:SetWidth(100);
    
b:SetHeight(20);
    
b:SetPoint("CENTER",UIParent,"CENTER",0);
    
b:SetMinMaxValues(1,100);
    
b:SetOrientation("HORIZONTAL");
    
b:SetValue(75);
    
b:SetStatusBarTexture("Interface\\TargetingFrame\\UI-StatusBar");
    
b:GetStatusBarTexture():SetHorizTile(false);
    
b:GetStatusBarTexture():SetVertTile(false);
           
SLASH_SCHOOLLOCK1="/slock";      
    
SlashCmdList["SCHOOLLOCK"]=SchoolLock_ParseParameters;
    
end

--[[Event Handling]]
function 
SchoolLock_OnEvent(thiseventarg1)
    --Do 
nothing now
end

function SchoolLock_ParseParameters(commandbar)
    
    
local cmd command;
    
local bar bar;
    
    
cmd=string.lower(cmd);
    
    if (
cmd == 'on'then
        SchoolLock_showBar
(bar);
        
    elseif (
cmd == 'off'then        
        SchoolLock_hideBar
(bar);
        
    else 
        
SchoolLock_Message('Befehl ' ..cmd.. ' ist unbekannt..!');
    
    
end
end

function SchoolLock_Message(message)
    
DEFAULT_CHAT_FRAME:AddMessage("[SchoolLock] " .. message0.70.00.4);
end --function Message

function SchoolLock_showBar(bar)    
    
bar:Show();
end

function SchoolLock_hideBar(bar)    
    
bar:Hide();
end 

PHP Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd">
  <
Frame name="SchoolLock" parent="UIParent" enableMouse="true">
    <
Scripts>
        <
OnLoad>
            
SchoolLock_OnLoad(self);
        </
OnLoad>
        <
OnEvent>
            
SchoolLock_OnEvent(selfeventarg1);
        </
OnEvent>
    </
Scripts>
  </
Frame>
  
</
Ui
  Reply With Quote
02-09-11, 10:40 AM   #5
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,401
CreateFrame() is a function, not a method. See the above example for how to use it properly.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
02-09-11, 12:47 PM   #6
Ketho
A Molten Giant
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 846
Just want to share these links in addition to Seerah,
in case you don't know what methods are, and why it's not a method
  Reply With Quote
02-09-11, 11:33 PM   #7
Anuki
A Defias Bandit
Join Date: Feb 2011
Posts: 3
Hey, thank you for your answers and for the links .

Hmm, do I understand it right, that b is a function that calls another function with name CreateFrame()?

PHP Code:
function Alpha() end 
is the same as
PHP Code:
Alpha = function() end 
So I have to set two times an end?

Is
PHP Code:
local b CreateFrame("StatusBar""SchoolLockStatusBar"SchoolLock
the right way, to get the statusbar into my mainframe?

At which point in the code do I have to create the statusbar and how can I use the frame in the both functions
PHP Code:
function SchoolLock_showBar()     
    
b:Show(); 
end 

function SchoolLock_hideBar()     
    
b:Hide(); 
end 
I can understand, that it must be hard as a veteran to explain a beginner the simplest things, but I hope you will do it though.

If someone of you have enough time and desire, could you show me how the code have to be, that it works?
When I have a framework or running example, it would be still easier, to understand, how it works!

Last edited by Anuki : 02-10-11 at 12:10 AM.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » The easiest way to create a "castbar"?

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