Unit Frames
ok i have searched like crazy and even tried to write my own code: but i can get nothing at all to work.
can someone point out a tutorial or something that will help me learn how to make individual Player/party/raid frames that actually function? PS i really dont want to use XML |
You could try oUF. It eases the creation of unit-frames significantly so long as you understand its basic functions.
A good example, at least it was for me, is oUF Ascii as it is as basic as possible without having all the extra code for the bells and whistles. Then simply move on to adding bars like in the example layout oUF: Lily. Further documentation can be found at the oUF Wiki on GitHub |
Quote:
|
You have to use (inherit in your CreateFrame call) the SecureUnitButtonTemplate which is xml but other than that the usual rules should apply to actualy create the unit elements.
Use a function to create your base widgets much like you would use xml to create element templates, other functions on top of that to add the bits to make status bars etc. and build up from there. |
Ah, sorry about that misunderstanding.
Then I suppose pretty much what Fizzlemizz said. |
Create the frame:
Code:
local f = CreateFrame("Button", "MyPlayerFrame", UIParent, "SecureUnitButtonTemplate") Code:
f:SetAttribute("unit", "player") Code:
f:SetAttribute("toggleForVehicle", true) Code:
f:RegisterForClicks("AnyUp") Code:
f:SetPoint("CENTER") |
I tried this myself and everything worked except the right click for the menu. I have no Lua errors. I have done some Googling, but cannot see what I am doing wrong.
Thoughts? |
Quote:
you give the best lessons in the world..... i just wish i had money to pay you for all your advice |
Quote:
... am i correct in this Phanx? |
Quote:
If you need to do things in the restricted environment in response to a right click then the SecureHandler page on wowpedia has an example snippet. |
You might have to register right clicks? Not sure.
|
So, what does this code do?
f:SetAttribute("*type1", "target") f:SetAttribute("*type2", "togglemenu") |
Code:
f:SetAttribute("*type1", "target") --target the unit on left click Code:
f:SetAttribute("*type2", "togglemenu") --toggle the unit specific menu (leave party, target icons etc.) on right click. Code:
f:SetAttribute("*type3", "assist") -- on middle click, target the target of the clicked unit. |
Specifically, "*type1" means any kind of left click (modified or not) and "*type2" is any right click.
The second argument is the action to take in response to the type of click. |
don't forget register
Lua Code:
|
Quote:
|
Beautiful! This works great, now I just have to add attributes, change it from a white box. Fun time now.
Thanks! |
Depending on what you want to achieve you have:
player, pet, target, party[1-4], partypet [1-4], boss [1-5], focus and target of target units at least (not talking raid frames). each can have: health bar mana bar buffs, debuffs (with aura timers?) portrait (static 2d or 3d playermodel with/without animations) icons (status, leader , loot, pvp, role, race...) target bars (health, mana) cast bar texts (name, level, class, target, elite, dead/offline, health/mana (as %) ...) stuff I've probably forgotten. The target unit has combo and anticipation points (supposedly changing to the player in WoD). The player unit has class bars/frames (Rune, Harmony, Eclipse, Druid Mana etc.), XP (bar + text + rested), Temp. Enchants (they still exist). The upside is, pets no longer get grumpy and bugger off when not fed so you no longer have to track their happiness :). There's also one other (icon I think) we lost last expansion (or maybe the one before). |
Even though you don't want to use the oUF framework, its highly modular nature means it's a good place to look to see which events and functions are related to what:
https://github.com/haste/oUF/tree/master/elements For example, if you want to see which events you should listen to, and which functions you should call, to display and update the unit's health, just look in the health module: https://github.com/haste/oUF/blob/ma...nts/health.lua I'd recommend this over the default UI code, since while the default UI obviously works, it's generally not a good example of well-written Lua code, and any complex systems (unit frames, for example) are extremely disorganized, with one part over here in this file, one part over there in that file, three parts up here, one part down there, etc. API references are also your friend, but won't give you as much of a sense of what you need for a specific task. |
thank you both this information will be invaluable
just a side note... what i have so far! will get into events and widgets next Lua Code:
|
All times are GMT -6. The time now is 05:48 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI