I'm considering writing these oUF modules for WidgetBar, WidgetHistogram, WidgetIcon, etc... I don't use oUF though. If someone wants to give it a go, don't hesitate.
Code:
local parent, ns = ...
local oUF = oUF
local LibCore = assert(LibStub("LibScriptableLCDCoreLite-1.0"))
local WidgetText = assert(LibStub("LibScriptableWidgetText-1.0"))
local core = LibCore:New({}, "oUF_ScriptableText")
local Update = function(self)
local fontstring = self.fontstring
fontstring:SetText(self.widget.buffer)
end
local Enable = function(self, unit)
-- note that row, col, and layer don't mean anything to us here.
self.widget = self.widget or WidgetText:New(core, self.name, {
value=self.value, -- the Lua script to run.
update=self.update, -- How fast the widget will update.
speed=self.speed, -- How fast marquee text will scroll.
direction=self.direction, -- Left or right, 1 or 2.
align=self.align, -- ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT, ALIGN_MARQUEE, ALIGN_AUTOMATIC, ALIGN_PINGPONG = 1, 2, 3, 4, 5, 6
cols=self.cols, -- How many columns wide the text should be. This is optional, and really only matters in marquees.
prefix=self.prefix, -- A lua script for text prefix.
postfix=self.postfix -- A Lua script for text postfix.
-- WidgetText does its own updating, but that's optional as you can simply call widget:Update() in your own time.
}, row, col, layer, errorLevel, Update, self)
self.widget.environment.unit = unit -- This will be the 'unit' variable within the run environment.
self.widget:Start()
return true
end
local Disable = function(self)
self.widget:Stop()
return true
end
oUF:AddElement('ScriptableText', nil, Enable, Disable)
Sorry for the dry code.
__________________
Wake up Sheeple! Cataclysm was an inside job!
Legalize WoW gold purchases directly from Blizzard!
Yeah, my doctor thinks I'm crazy too. >.<
"It was either going to school for programming or working at the Genetically Modified Wildlife Preserve. I've always had a love for the wildlife, but technology won out in the end."
Note: If you know of a library that you want to make available in your own scripts. let me know and I'll see about writing a plugin for it.