(1 Kb)
Updated: 11-05-09 11:26 AM
Pictures
File Info
 Updated: 11-05-09 11:26 AM Created: 11-01-09 04:03 PM Downloads: 2,225 Favorites: 2 MD5: Categories: Combat Mods, Discontinued and Outdated Mods

CPM

Version: 1.1
by: Malakahh [More]

Shows you the average amount of critical strikes you make per minute.

/CPM - displays the critical strikes per minute
/CPMreset - resets the count

This is my first addon, and I made it to get into Lua, don't be too harsh in those comments.

If you find any bugs, please leave a note in the comments. Thanks =)

1.1
Made the numbers have less decimals.
Archived Files (1)
 File Name Version Size Author Date 1.0 1kB Malakahh 11-01-09 04:24 PM

 Comment Options
 11-04-09, 06:45 AM Malakahh A Fallenroot Satyr Forum posts: 28 File comments: 7 Uploads: 4 Thanks Thanks for the comments =)
11-01-09, 08:30 PM
Akryn
A Firelord

Forum posts: 479
 Originally posted by Cralor Multiplying and dividing by the same number is what essentially does the "rounding". I really can't tell you why though.
The math.floor function rounds down to the nearest integer, so to round to the nearest hundredth using that particular function, you need to multiply by 100 so that the relevant decimal place is the one that the function acts on (units). The 0.5 gets added after the multiplication is done because of the order of operations, and therefore is effectively the same as adding 0.005 to the number before the multiplication. The result of that is that, since floor always rounds down, if the thousandths place is >=5, the resulting hundredths place will be increased by 1, otherwise it will stay the same.

In any case, using string.format is easier if the goal is to output text.

11-01-09, 06:47 PM
Cralor

Forum posts: 772
 Originally posted by xtoq I'll admit that math isn't my strong suit, so I have to ask what is probably a dumb question. Wouldn't multiplying by 100 then dividing by 100 leave you with the same number you had before multiplying? Or is that what the math.floor function is for?
Multiplying and dividing by the same number is what essentially does the "rounding". I really can't tell you why though.
__________________
Never be satisfied with satisfactory.

 11-01-09, 06:27 PM mrruben5 Guest Join Date: Not Yet Forum posts: 0 File comments: 0 Uploads: 0 You don't really need to use math.floor. Just use string.format. lua Code: `local format = string.formatprint( format( "Criticals per minute: %.2f", (critical / (timer / 60)) ) )`
11-01-09, 05:40 PM
xtoq
An Aku'mai Servant

Forum posts: 32
 Originally posted by nightcracker I suggest rounding those numbers off to a certain decimal. For example, to the second decimal works like this: lua Code: `local originalnumber = 24.1258921local newnumber = math.floor(.5+originalnumber*100)/100` And that's about it!
 11-01-09, 05:13 PM nightcracker A Molten Giant   Forum posts: 716 File comments: 429 Uploads: 31 I suggest rounding those numbers off to a certain decimal. For example, to the second decimal works like this: lua Code: `local originalnumber = 24.1258921local newnumber = math.floor(.5+originalnumber*100)/100` And that's about it!