Call as
addon:Widget_UnitWidget(value, units, update, field)
Available directly through addon; no dependency is needed.
What it does
Create a configured unit selector bound to a condition value record. Returns the widget for the caller to add to the condition callback parent.
Arguments
| Name | Type | What it does |
|---|---|---|
self | RMAddon | Rotation Master addon instance (implicit with colon calls). |
value | table | Condition value record updated when a unit is chosen. |
units | table | Unit key-to-display-name map shown in the selector. |
update | function | Callback invoked after changing the selected unit. |
field | string | nil | Value record field to edit; defaults to unit. |
Returns
| 1 | RMConditionSelector | Configured unit selector; add it with parent:AddChild(widget). |
|---|
Editions
Built In helpers are registered on every edition. What differs is the game API they read; where one is missing the helper falls back or returns nil with a reason.
It reads no game API directly.
How the addon calls it
- Attackable (widget)
local unit = addon:Widget_UnitWidget(value, Functions.collections.deepcopy(addon.units, { "player", "pet" }), - Beyond Melee Range (widget)
parent:AddChild(addon:Widget_UnitWidget(value,addon.units,function() - Buff Present (widget)
local unit = addon:Widget_UnitWidget(value, addon.units, - Buff Time Remaining (widget)
local unit = addon:Widget_UnitWidget(value, addon.units, - Buff Stacks (widget)
local unit = addon:Widget_UnitWidget(value, addon.units, - Casting (widget)
local unit = addon:Widget_UnitWidget(value, addon.units, - Cast Progress (widget)
local unit = addon:Widget_UnitWidget(value, addon.units, - Cast Time Remaining (widget)
local unit = addon:Widget_UnitWidget(value, addon.units,
and 52 more: Specific Spell Casting (widget), Cast Interruptible (widget), Channeling (widget), Channel Progress (widget), Channel Time Remaining (widget), Specific Spell Channeling (widget), Channel Interruptible (widget), Class (widget), Unit Classification (widget), In Combat (widget), Combat Action History (widget), Combat Action History Time (widget), Creature Type (widget), Is Dead or Ghost (widget), Debuff Present (widget), Debuff Time Remaining (widget), Debuff Stacks (widget), Debuff Type Present (widget), Distance (widget), Hostile (widget), Is Friendly (widget), In Group (widget), Health (widget), Health Percentage (widget), Immune (widget), Is Same As (widget), Level (widget), Mana (widget), Mana Percentage (widget), Raid Mark (widget), Points (widget), Power (widget), Power Percentage (widget), Allies Within Range (widget), Health Within Range (widget), Health Percentage Within Range (widget), Health Percentage Count Within Range (widget), Health Count Within Range (widget), Mana Within Range (widget), Mana Percentage Within Range (widget), Mana Percentage Count Within Range (widget), Mana Count Within Range (widget), PVP Flagged (widget), Resistant (widget), Role (widget), Runner (widget), Character Stat (widget), Has Stealable Buff (widget), Threat (widget), Time Until Health (widget), Time Until Health Percentage (widget), Unit Exists (widget)
Source
UI/condition_unit.lua, line 23. Read only in game; Duplicate makes an editable copy.
Conditions.common.Widget_UnitWidget(self, value, units, update, field)
if field == nil then
field = "unit"
end
local unit = addon:CreateConditionDropdown()
unit:SetLabel(L["Unit"])
unit:SetCallback("OnValueChanged", function(_, _, v)
value[field] = v
update()
end)
unit:SetDisabled(value.disabled)
unit.configure = function()
local choices=units
local parent=unit.parent
local top
for _=1,128 do
if not parent then break end
top=parent:GetUserData('top')
if top then break end
parent=parent.parent
end
if field=='unit' and (value[field]=='announcementtarget' or top and top:GetUserData('announcementTarget')==true) then
choices={};for key,label in pairs(units) do choices[key]=label end
choices.announcementtarget=L['Announcement target']
end
unit:SetList(choices, addon.keys(choices))
unit:SetValue(value[field])
end
return unit