1. #1

    some lua questions

    hello!

    im currently in the process of making my own addon that has some sort of function other than minor textures and band aid fixes to other addons. just have a few questions on issues im having with

    1. when im calling the cooldown time remaining (using (start + duration) - seconds from GetSpellCooldown() and GetTime() ) it returns more digits than i need, ie 23.36700000002. any way to shorten it?

    2.- fixed-

    3. resetting the Backdrop of a frame its a bit dodgy, it would reset happily like 4 times then it would stop resetting. am i doing something wrong? first thing im doing in a function is pointing a local to a blank texture, then later in the function im pointing it to another file path that was obtained in an event -- fixed? i think?

    might add more questions later, but for now would love some help! you lovely mmo champion people you

    edit:

    -fixed-
    Last edited by SpaceDuck; 2012-09-11 at 02:35 PM.

  2. #2
    1. math.floor(x)

    or something like

    cut = strlen(x)

    x = x / 1x10^cut

    edit

    you could then use cut like

    cut = cut-4 (for 2 decimal places)

    then proceed with x = x / 1x10^cut
    Last edited by Yohassakura; 2012-09-11 at 02:49 PM.
    Computer: Intel I7-3770k @ 4.5GHz | 16GB 1600MHz DDR3 RAM | AMD 7970 GHz @ 1200/1600 | ASUS Z77-V PRO Mobo|

  3. #3
    that makes little sense to me how would i implement it?

    heres what i have for my timeleft code

    Code:
    local timeleft = (start + duration - seconds)
    
    local tr = iconframe:CreateFontString()
    tr:SetPoint("BOTTOM")
    tr:SetSize(40, 40)
    tr:SetFont("Fonts\\FRIZQT__.TTF", 11, "OUTLINE")
    tr:SetText(timeleft)
    edit

    oh another thing, errors out when an item triggers UNIT_SPELLCAST_FAILED. anyway to make it so it only detects abilities and not items?
    Last edited by SpaceDuck; 2012-09-11 at 02:58 PM.

  4. #4
    Code:
    function round(num, dp)
      local mult = 10^dp
      return math.floor(num * mult + 0.5) / mult
    end
    timeleft = num
    dp = decimal point (23.02) = 2dp

    Code:
    local timeleft = (start + duration - seconds)
    
    local mult = 10^2
    timeleft = math.floor(timeleft * mult + 0.5) / mult
    
    local tr = iconframe:CreateFontString()
    tr:SetPoint("BOTTOM")
    ...
    Last edited by Yohassakura; 2012-09-11 at 03:19 PM.
    Computer: Intel I7-3770k @ 4.5GHz | 16GB 1600MHz DDR3 RAM | AMD 7970 GHz @ 1200/1600 | ASUS Z77-V PRO Mobo|

  5. #5
    giving me times of 23773000.00001 now

  6. #6
    Quote Originally Posted by SpaceDuck View Post
    giving me times of 23773000.00001 now
    Brain fart has been expelled.
    Computer: Intel I7-3770k @ 4.5GHz | 16GB 1600MHz DDR3 RAM | AMD 7970 GHz @ 1200/1600 | ASUS Z77-V PRO Mobo|

  7. #7
    awesome thanks alot <3

    now i just need to make it stop nilling out when an item goes on CD

    nvm all solved, thanks yoha
    Last edited by SpaceDuck; 2012-09-11 at 03:35 PM.

  8. #8
    Deleted
    Alternatively:
    Code:
    local function round(num,digits)
        return tonumber(("%%.%df"):format(digits):format(num))
    end

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •