Download
(1Kb)
Download
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:3,193
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.
Post A Reply Comment Options
Unread 11-01-09, 05:13 PM  
nightcracker
A Molten Giant
 
nightcracker's Avatar
AddOn Author - Click to view AddOns

Forum posts: 716
File comments: 428
Uploads: 22
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!
Report comment to moderator  
Reply With Quote
Unread 11-01-09, 05:40 PM  
xtoq
An Aku'mai Servant
 
xtoq's Avatar
AddOn Author - Click to view AddOns

Forum posts: 32
File comments: 642
Uploads: 4
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.
Report comment to moderator  
Reply With Quote
Unread 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:
  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
Unread 11-01-09, 06:47 PM  
Cralor
Mmm... cookies!!!
 
Cralor's Avatar
AddOn Author - Click to view AddOns

Forum posts: 772
File comments: 313
Uploads: 5
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.
Report comment to moderator  
Reply With Quote
Unread 11-01-09, 08:30 PM  
Akryn
A Firelord
AddOn Author - Click to view AddOns

Forum posts: 479
File comments: 95
Uploads: 10
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.
Report comment to moderator  
Reply With Quote
Unread 11-04-09, 06:45 AM  
Malakahh
An Aku'mai Servant
AddOn Author - Click to view AddOns

Forum posts: 30
File comments: 26
Uploads: 5
Thanks

Thanks for the comments =)
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: