1. #1
    Field Marshal Quarla's Avatar
    10+ Year Old Account
    Join Date
    Dec 2010
    Location
    California
    Posts
    58

    Getting Percentages with Weakauras

    I'm not a coder or anything of the like and I'm pretty sure you need to know a bit of lua or something to get percentages to show up. I tried doing a search but the strings in the topic I found weren't working. Anyway, I'm trying to make a simple manabar that shows my percentage of mana rather than the big long number of the total mana my character has remaining.

    Anyone have a simple way to achieve my goal with this addon?

  2. #2
    Set one of the text displays to a custom function:
    Code:
    function()
    
     -- first let's get our current mana
     local current_mana = UnitPower("player", SPELL_POWER_MANA) 
    
     -- now we'll find out how much mana we could have if we were full
     local maximum_mana = UnitMaxPower("player", SPELL_POWER_MANA)
     
     -- current divided maximum equals percent, don't forget to multiply by 100.  Just like 8th grade math test scores!
     local percent_mana = ((current_mana / maximum_mana) * 100)
    
     -- now we just need to format that into a string with one decimal point and the percent symbol
     return string.format("%.1f%%", percent_mana)
    
    end
    You could string that into one line without all the comments and intermediate variables, but I think it's easier for a non programmer to read and understand what's going on when you see it this way.

  3. #3
    Field Marshal Quarla's Avatar
    10+ Year Old Account
    Join Date
    Dec 2010
    Location
    California
    Posts
    58
    Hmm, thanks so much for your help Evn but I added it to the custom function and nothing is showing up. I'll post the string in case I'm missing something that I just don't see.

    Code:
    dyKufaqiLc1IijUevL(ePugfjPtrIAvkf0SuQ0Tiv2fjKFrkvggK6yKulJQINrvQPjqxJu12ir(MaghIkoNsfZtPqUhjOdceTqsOEOsbUOsvTrevDssGvcuZKQKBce2jvXpvkvdfrzPkv5POAQi0vvkPVQuK5QuI9s5VcAWQomulMQQhJKjlKltSze5ZKIrdjNwrRMuQ61kf1SbCBLSBu(nvgosDCevA5GEoetx01vy7Ks(UqnEG05rW6vkL9lTP2iA8LXJmEKr04udK0TikGMgN0GrLthtvLl4((((cUVVVxNUEstis2diP2q61izVBa7PgqOWY(fMHl4(((EahfgONAaHcldxygUxH9BLntYCXcuvvObWeeOk72ZjBFV8kKSTVP93leeG0divUVG7777l4(((ED66zU4(yrBaa9KMSOE3i7r5I7xdku9lmd3hl9uUbqupkSws)KuFS0hlqPN0aaOG7777bCuyG(fg05AScxygUxH9BLntqGbLmxSavvfAambbQYU9CY23lVcjB7BA)9cbbi9asLl4((((cUVVVxNUEQbekSSpAQ1msI6xyqNRXQxi3bgaPNwGucl3TpYX0w2tYb1izF66xdGCsdqO3pHE1OrRO(EWdKShyUzPNCsu9AG4iPFHtu9PGK9iuoOGSXfCFFFpGJcd0tlqkHLHlmd3RWEvvLAaHcldxygUx76xyqNRXkCHzyL73WE1OrRCb3333xW9999601ZCX9XsV2pqYEMir9PRNKdUWzFIcN9tw66X9ijCY00hptu9oM0hjuZfgON2nzzpMf1NOKEAbsjSShHWYVdOG7777HsoGSEKeozAuejhCHtvvXxfPMKV(QYU90cKsyz4cZWkxW9999fSWImEcNA0iqJOXtc0IXrsCoqm(arcPDXcmjqlMIn(archSzAk24i0caGh8smpOnUOLWsJtMlwGgFGiH0cKsyjTlwGMFJpqKqeAbaWdEjMInoTlwGjbAX8G24dMOLWsJJhPZ40cKsyjTlwGgFh9gNwGuclPDXcm0rlqC6GgFJS04(XWnWb4GgrZJAJ86vsVA9bucnAF2jqWabrBK0PpG5XBZJAlnE0eHgatGOaA6LqknUVughWHJmIgh6aeJOXxdGCAeT0sJpqKqMOLan)gFBoMyCIOKE(yTeyprbcXuIXhis42CmX8BPXrjtnOsJ8b0hiO3bc4JpQ9X7D8wj0gjDb3X4SXIiCQrJarmpQnou0mDmIeOfJJhqSFm04rteAambIcO5EtnOsJ7704PaAoGIX3BWeeJpJmoiWmSFm04XZOeLr(aKJALqRuq9b0R3hLcguTrsxq9gFs5yMFJhnrObWeuaLJzCfWsbsctjBrbuogYwwo2MdX(NaZKqifkbcjSWmCkylnoIXHEJwVX1Y8OoiA0wAg

  4. #4
    Bloodsail Admiral Killora's Avatar
    10+ Year Old Account
    Join Date
    Oct 2010
    Location
    BFE, Montana
    Posts
    1,105
    Code:
    d4tJdaGAeOEjGKDrvQxJqCprLomO5Iqz2qSker3es(fIW3qK8yr2jGAVk7wv7NkJssnmQQFt0PjmueidwkdxWLrDkPYXKKZHi1cPk5siklgj1YHArs0tPSmeupxf)eHQPQsMmsnDsJdj5QiHNHaCDH2icP)cWMLQ2oIQpIaADiitdOMhGuFNQ4ZQuJgigps0jfvClaX1GuNxuwPOQTbKUTeEv7AwXm6z07AwkEuzXftPoRp(jvi)6oxExZ1CnxdrMGiUwGXj(vxlxxRMIxOOGpSUmGaZyCzhjO4fkk4drbPSUmGaZyCzxhjR89D5DnxZ1CnmRr87A1LKjk7iuVexa16aJt8RDU88tpl(kwCFZ4Dnl(cDwabMX4zXddi(cDEnDMIf33mExZcspmwZc8a2Fw8WacspmwZc88AMMf4zhfQXZSu8OYcaAwGNDuOgpZsXJklaaIGMNPIcMEgto)6mcs6HXZIhgqGXj(1G0dJh1ZsXJklM1h)KkKFDNlVR5AUMRHitqexlW4e)QRLRRvtXluuWhwxgqGzmUSJeu8cff8HOGuwxgqGzmUSRJKv((U8UMR5AUgM1i(DT6sYeLDeQxIlGADGXj(1oxE(PNfFMC(1zWOkNLaHtezwmqdvEw8WaIVqNxZcmoXVgKEy8m0(ZcmoXVgKEymazGXqvINb05oDgiS4geDaJ2FgIesVRzXdd4Hf88AgwIW7Awrerf7A60zpSGNbuceejgoDgT4eqGzMcte5mJSezZW8Tq(xzbEMij)zqAAHkKpebGIf33m(SRPZOfhco(jvqopQNbJQCuptqpdf8HZOK499hwhrrdUIkWGjDfbakHrdM0Kc01deWON5rqRGmGr7plJ499hwhrbcAWvub2h0kQafnve2Vc01deWON9XIlS4(MXNbC1mAXjGaZYjj)z58kJ7HjMy5KK)HywGrqaGcElsaqbFibcf)SKuIql98J6PZoZQ8gS3KY7k)zKpGRa77pDda
    Try this. It should work. If you want it to only show below a certain % mana simply set the fuction under the trigger.

  5. #5
    Field Marshal Quarla's Avatar
    10+ Year Old Account
    Join Date
    Dec 2010
    Location
    California
    Posts
    58
    Ahh. It won't work with bars just icons I guess. Well that's disappointing. Was trying to slide it into a sliver of a spot. lol Well thank you Killora. I'll figure out a way to make this work in my UI.

  6. #6
    Deleted
    Code:
    dCZPbaGnivnBGUjs8liOVbH6Eqi7KQSxYUbTFeJssggu9BbhwLHcjzWs1WrQ1bboLeDmr5CqHfcj1sHuSyfA5QArsQNI6XuPNtfxwPPQOjRGPt50cDvOONjsDDPSriLghKOnlI2ovvltK8zjmnO03HO8qiH)crmAisJxeUes6wquDnr15byLuvwfKk3gqRmnfdu8G4bnf72CSaW5MWeNSbDTyawvs8r6KoPt6Gb3dK0P33DHgPJisVcty0OCWRQMg8aSFDjcXegnkh8OCjQQPbpa7xxwIUmCCIpsN0jDs)xR9qsVQMASUebjdpWZQO33DHwjX3cheBFSOyFnfBaOxXo2znhXR)fAIrvaz7lU5SiPbJMqT4gC9Vqt81SGmXJ3JIay41uEzYdxEPeArzk0NJnfgyGJnDoEEoIvsKNJvEPLxMmXGHBqtXFaC1umWgOf1uMmzIJUbOgf)BrmaNaOxXx7VX7fpeDObpaZnHHMybsnXuDPk(AwqJIJdIPCWB8EXWgW5hlk23rEzYe7i(tJNl2V8YWIJltc
    Converted into a bar

Posting Permissions

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