Download
(1 Kb)
Download
Updated: 11-05-09 10:26 AM
Pictures
File Info
Updated:11-05-09 10:26 AM
Created:11-01-09 03:03 PM
Downloads:1,168
Favorites:2
MD5:
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
 CPM
1.0
1kB
Malakahh
11-01-09 03:24 PM


Post A Reply Comment Options
Old 11-04-09, 05:45 AM  
Malakahh
A Deviate Faerie Dragon
AddOn Author - Click to view AddOns

Forum posts: 15
File comments: 6
Uploads: 2
Thanks

Thanks for the comments =)
Malakahh is offline Report comment to moderator  
Reply With Quote
Old 11-01-09, 07:30 PM  
Akryn
A Firelord
AddOn Author - Click to view AddOns

Forum posts: 479
File comments: 93
Uploads: 9
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.
Akryn is offline Report comment to moderator  
Reply With Quote
Old 11-01-09, 05:47 PM  
Cralor
Mmm... cookies!!!
 
Cralor's Avatar
AddOn Author - Click to view AddOns

Forum posts: 767
File comments: 321
Uploads: 7
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.
Cralor is offline Report comment to moderator  
Reply With Quote
Old 11-01-09, 05: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:
  1. local format = string.format
  2. print( format( "Criticals per minute: %.2f", (critical / (timer / 60)) ) )
Report comment to moderator  
Edit/Delete Message Reply With Quote
Old 11-01-09, 04:40 PM  
xtoq
An Aku'mai Servant
 
xtoq's Avatar
AddOn Author - Click to view AddOns

Forum posts: 32
File comments: 641
Uploads: 3
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:
  1. local originalnumber = 24.1258921
  2. local newnumber = math.floor(.5+originalnumber*100)/100
And that's about it!
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?
__________________
There is absolutely no evidence to support the theory that life is serious.
xtoq is offline Report comment to moderator  
Reply With Quote
Old 11-01-09, 04:13 PM  
nightcracker
A Molten Giant
 
nightcracker's Avatar
AddOn Author - Click to view AddOns

Forum posts: 714
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:
  1. local originalnumber = 24.1258921
  2. local newnumber = math.floor(.5+originalnumber*100)/100
And that's about it!
nightcracker is offline Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: