Go to Page... |
Updated: | 08-27-07 03:41 AM |
Created: | unknown |
Downloads: | 1,707 |
Favorites: | 8 |
MD5: |
Main Idea
Number crunching and theorycrafting without alt+tabbing or using a stand-alone calculator.
About this add-on
This is simply a calculator or rather a parser that can handle arithmetic expressions. I wrote this for myself and for my friend since we wanted to quickly calculate things in-game. Because time is of the essence, this interface is command line based. I do not plan to add GUI to it.
Usage
/calc 1426.79 / (1 + 918.836 * 2.71828 ^ (-0.00386405*1500) )
You can also use /calculator, /bc or /=
Add-on allows any number of whitespace characters anywhere in the string. As you can see from the example above, it also supports bracketing. Unary operators are also allowed (so something like --5-6 is valid; gives -1).
Currently the add-on supports following operations:
Addition (+), Subtraction (-), Multiplication (*), Division (/), Power (^), Square Root (sqrt(expr))
The add-on also supports variables! To initiate a new variable simply write "var = <exp>". Variable names HAVE TO START with a letter but can contain numbers. So, for e.g., "var" is valid, so is "var3s" and so is "var33" but "33var" is invalid.
You can use upto 20 variables at the same time and you also have 3 answer slots at your disposal, which save 3 previous computation results. The answer slots can be referenced by writing "ans", "ans2" and "ans3", where "ans" is your previous result. If your operation didn't involve any computation (myvar = 2, or 2, or myvar) it will not get saved into the answer slot.
The variables are changed/initiated only if your operation was successful. If you have encountered an error, the memory operation will not take place. So don't be afraid if something like this happens:
/calc veryimportantcalculation = 2 + 2
/calc veryimportantcalculation = 2*(6/2)) <- oh sh*t!
The "veryimportantcalculation" will keep the result 4. Same goes for answer slots, they will not get overwritten in case of an error.
The syntax is case-independent. So SQRT(4) is the same as sqrt(4). Same goes for variables - "myvar" is the same as "MYVAR".
You can also change decimal point precision of your answers. By default it is set to -1, which corresponds to unthresholded precision. However, if you want to change it, simply type "precision = <decimal points>". All your results will get rounded up.
Er. You wrote all... that? Why?
Yes, I wrote my own parser, although Lua has its own. Yes, it isn't as sophisticated as "/dump" in DevTools. The reason was to practice coding in Lua (this is my first work) and to practice my Language Engineering knowledge. So the whole thing was a bit of a challenge to me, rather than a market-orientated design.
Why would I use this?
This add-on is for people who simply need a quick way to calculate things (spell damage, arena points, mobs to kill to get to Exalted rep, you name it). If you need something more complex go for DevTools. It assumes that you know the theory and mechanics, all you need is a tool to quickly use your knowledge to come up with the required result.
Beta Version Disclaimer
I decided to share this add-on with WoW community because I think it might be useful to somebody out there. However, I am still testing it and there might be some annoying bugs in the code. Please, do not hesitate to give feedback/suggestions. When making a bug report please include the string you tried to execute with the add-on.
Any recommendations / queries regarding the quality of my code are welcome too.
Current limitations and plans for the future
Currently the add-on just calculates things and I want to make sure it does just that. However, in the future, if there would be someone out there who wants me to go on with this work, I might try and add new features to it.
Things I plan to include are:
1) Pre-defined functions (for e.g. arena_points(<rating>). Possibly a quick and easy way to write your own).
2) Maybe even simple equations/inequalities.
3) Maybe some more advanced mathematics stuff every calculator has (fraction display, pi, log, e, etc.)
Please note!
A) The add-on supports tokens such as =, <, > and so on. However, the logic that handles those tokens ISN'T THERE YET! If you try to write equations/inequalities the add-on will give you an error.
B) There are lots of stupid comments all over the place in the code. Those will be removed eventually.
Comment Options |
snegoviK |
View Public Profile |
Send a private message to snegoviK |
Find More Posts by snegoviK |
Add snegoviK to Your Buddy List |
snegoviK |
View Public Profile |
Send a private message to snegoviK |
Find More Posts by snegoviK |
Add snegoviK to Your Buddy List |
08-27-07, 11:27 AM | |
A Kobold Labourer
Forum posts: 0
File comments: 2
Uploads: 0
|
Looks like a great calculator addon! I presume variables are cleared when you log off?
Would it be possible to add support for money strings like XCalc has? That's the only thing keeping me using that old calc addon since I use the AH a lot. |
|
Talash |
View Public Profile |
Send a private message to Talash |
Find More Posts by Talash |
Add Talash to Your Buddy List |
08-27-07, 01:48 AM | |
|
Ooops. Will do.
Talking about shortcuts. I can make /bc and I was also asked to make /= but those are likely to clash with something else. Basically, in the next version 0.021b I will include both. Please report any compatibility issues. I know that the latter shortcut is used by XCalc but I guess it is unlikely you will use two calculator add-ons at the same time. P.S. Sorry for zipping in the retarded way. |
|
snegoviK |
View Public Profile |
Send a private message to snegoviK |
Find More Posts by snegoviK |
Add snegoviK to Your Buddy List |
08-26-07, 06:52 PM | |
A Deviate Faerie Dragon
Forum posts: 19
File comments: 43
Uploads: 0
|
Nice idea!
I rate it a 9/10. Would have gotten a 10 if you had included the obvious short-cut:
/bc for us Unix geeks. Whoops. Make that an 8/10. You didn't archive the files into their own subdirectory.
Last edited by SquishyMage : 08-26-07 at 06:53 PM.
|
|
SquishyMage |
View Public Profile |
Send a private message to SquishyMage |
Find More Posts by SquishyMage |
Add SquishyMage to Your Buddy List |