WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   The easiest way to create a "castbar"? (https://www.wowinterface.com/forums/showthread.php?t=38819)

Anuki 02-09-11 01:04 AM

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 :confused:

Rilgamon 02-09-11 05:06 AM

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)

nightcracker 02-09-11 07:02 AM

Just one thing, shouldn't the statusbar range from 0-100 instead of 1-100?

Anuki 02-09-11 08:20 AM

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


Seerah 02-09-11 10:40 AM

CreateFrame() is a function, not a method. See the above example for how to use it properly.

Ketho 02-09-11 12:47 PM

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

Anuki 02-09-11 11:33 PM

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? :rolleyes:
When I have a framework or running example, it would be still easier, to understand, how it works! :)


All times are GMT -6. The time now is 11:31 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI