View Single Post
09-07-09, 06:52 AM   #66
Katae
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Jun 2007
Posts: 208
Originally Posted by Yhor View Post
Does the current version allow for "105%" (or any % greater than 100)? I ask this because it may be useful for an

{ if blah blah blah = "10", then "100%";
if blah blah blah = "15", then "201%";
end... }
etc.. situation. Does that even make any sense?
Well, yes and no, you can use any n% as the width/height, but it currently cannot be changed on the fly like in your example since the config is only read once.

It's totally possible to implement that sort of behavior. For instance, allowing width/height to be a function and change itself conditionally.

But for the time being, to alter the width/height as a % conditionally, something like this could be used...
Code:
OnUpdate = function(self)
    local height, width
    if true then
        height = "100%"
    elseif condition == 5 then
        height = "201%"
    end
    width = "100%"

    local pwidth, pheight = self:GetParent():GetWidth(), self:GetParent():GetHeight()

    if width then self:SetWidth(strmatch(width,"%%") and pwidth * strmatch(width, "(%d+)%%") * .01 or width) end
    if height then self:SetHeight(strmatch(height,"%%") and pheight * strmatch(height, "(%d+)%%") * .01 or height) end
end

Last edited by Katae : 09-10-09 at 06:41 AM. Reason: onupdate script
  Reply With Quote