Maybe pemanent solution to SetAlpha errors (indicators.lua) #1813


  • Bad Fix
  • Waiting
Open
  • MoefinaEU created this issue Oct 27, 2022

    For the Issues with SetAlpha in the indicators.lua:

     

    delete line 247 from indicators.lua, it reads "self.ready:SetAlpha(self.timeLeft / self.startTime)"

     

    insert this instead at its position:

    -- Fix for DF not liking values > 1 / < 0
    local fadeAlpha = (self.timeLeft / self.startTime)
    if fadeAlpha < 0 then
    fadeAlpha = 0
    elseif fadeAlpha > 1 then
    fadeAlpha = 1
    end

    self.ready:SetAlpha(fadeAlpha)

     

     

     

     

     

    ----------------------------------------------

    Delete original line 276 (should be at roughly line 286 after the change above), it reads "fadeFrame:SetAlpha(f.fadeList[fadeFrame] / FADEOUT_TIME)"

     

    insert this instead at its position:

    -- Fix for DF not liking values > 1 / < 0
    local fadeAlpha = (f.fadeList[fadeFrame] / FADEOUT_TIME)
    if fadeAlpha < 0 then
    fadeAlpha = 0
    elseif fadeAlpha > 1 then
    fadeAlpha = 1
    end

    fadeFrame:SetAlpha(fadeAlpha)

     

     

    This should help with the problems. Maybe just a bandaid for now but at least it assures same functionality as before.

  • MoefinaEU added the tags Bad Fix Waiting Oct 27, 2022
  • ereshmilor posted a comment Oct 28, 2022

    You can fix this using min(max())

     

    247:

    self.ready:SetAlpha(min(max((self.timeLeft / self.startTime),0),1))

     

    276:

    fadeFrame:SetAlpha(min(max((f.fadeList[fadeFrame] / FADEOUT_TIME),0),1))

     

    *edit: forgot a )


    Edited Oct 29, 2022

To post a comment, please login or register a new account.