Download
(7 Kb)
Download
Updated: 02/28/20 12:26 AM
Pictures
File Info
Compatibility:
Harrowstorm (5.3.5)
Updated:02/28/20 12:26 AM
Created:08/13/14 02:42 PM
Monthly downloads:49
Total downloads:10,994
Favorites:17
MD5:
Categories:Chat Mods, Auction House & Vendors, TradeSkill Mods, Miscellaneous, Utility Mods
Calculator  Popular! (More than 5000 hits)
Version: 3.3.7
by: zeroIndex [More]
--------- Calculator -----------


The text used in the Chat section of the calculator can handle non standard and standard symbols to achieve your goal: Addition: 'a' or '+', Subtraction: 's' or '-', Multiplication: 'm', 'x', or '*', and Division: 'd' or '/'. I added the extra symbols because its much easier to type m or a than search for the proper symbol.

This calculator uses the chat box with the command /calc.
An example: /calc 1+10-4/2*6
You can also use parenthesis for deeper calculations: /calc (12-3)(4/2)
An example of easy symbol input: /calc 1a2m3d2s1

You can calculate using your answer instead of having to type in your answer manually.
You can use the keywords " Answer, answer, Ans or ans " in the chat input.

Like so:
/calc answer + 2
/calc ans + 2

This works with the use of the easy input symbols as well.
/calc ans m 2 a 3
/calc answer m 2 a 3

You don't have to worry about spaces, just the order of operations.

There is also a UI for those of you who would prefer to click for your results

You can set a keybind to allow for a quick open/close of the calculator UI or you can use:
/calc open
/calc close
/calc

There are some options to customize the colors of the calculator to better fit your taste.
There is an option to add the answer from the UI to the chat box. In case you want to look back over your previous numbers or turn it off if its too intrusive.

Please see the attached pictures as they show examples of how the calculator works and what it looks like.


I was tired of tabbing out or looking for my phone when I had to use a calculator so I put this addon together. If you are a seller or if you like to crunch numbers for builds this addon will save you some grief and time. Check it out and feel free to ask if you have any questions, any feed back will be appreciated.


This addon depends on LibAddonMenu if you dont have that library you can find it here https://www.esoui.com/downloads/info7-LibAddonMenu.html add it to your addon folder just like any other addon.
--Version 3.3.7--
Updated the API number 100030
Fixed an error that was occurring due to changes in the chat system.
Removed the option to send the answer to all chat tabs. That option is now always on due to the changes in the chat system.
Removed LibAddonMenu-2.0 from Calculator as it's now a standalone library.


--Version 3.3.6--
Updated the API info
Fixed a bug if you just type /calc. Now typing /calc opens and closes the UI (thanks Phuein!)
Fixed a bug if you were to just hit the '=' button in the UI without an input.
Updated LibAddonMenu2.0 to the newest version to fix a menu error.
Added the ability to reuse your answer in the chat input instead of manually typing it back in.

--Version 3.3.5--
Updated the API info

--Version 3.3.4--
Updated the API info
Removed an extra space in the name causing the addon to appear out of order in the list of addons

--Version 3.3.3 --
Updated the API info


--Version 3.3.2--
Updated the API info


--Version 3.3.1--
Updated the API info


--Version 3.3--
Removed functions from global land
Limited the number of decimals to two, no more .33333333333


--Version 3.2--
The lazy options for the chat box input are back.
You can now type 'a' instead of '+'
and 'm' or 'x' instead of '*'
and 'd' instead of '/'
and 's' instead of '-'

Options were added to be able to send the answer from the UI input into the chat tab in case you want to look back over previous numbers.
Optional Files (0)


Post A Reply Comment Options
Unread 11/27/22, 11:05 AM  
RavenMind
 
RavenMind's Avatar

Forum posts: 6
File comments: 391
Uploads: 0
Originally Posted by RavenMind
Hi. Does anyone know if this addon still works? Thanks.
And that would be a big old NO, no it does not.
(For anyone interested in taking it over.. The errors i'm seeing make me think the problem is with API updates the code hasn't been rewritten for. The core functionality is probably still there. Just a guess.)

If only I could get MS Calc to work without Alt-Tabbing out of ESO to punch the numbers in...
Last edited by RavenMind : 11/27/22 at 11:08 AM.
Report comment to moderator  
Reply With Quote
Unread 11/26/22, 05:44 PM  
RavenMind
 
RavenMind's Avatar

Forum posts: 6
File comments: 391
Uploads: 0
Hi. Does anyone know if this addon still works? Thanks.
Report comment to moderator  
Reply With Quote
Unread 02/27/20, 10:19 PM  
zeroIndex
AddOn Author - Click to view AddOns

Forum posts: 1
File comments: 18
Uploads: 2
Re: ui error

Originally Posted by kindredspirit
I'll be looking into this issue very soon and hopefully will have a fix out in the next few hours. Thanks for letting me know.
Report comment to moderator  
Reply With Quote
Unread 02/26/20, 10:27 AM  
kindredspirit

Forum posts: 3
File comments: 113
Uploads: 0
ui error

Report comment to moderator  
Reply With Quote
Unread 08/03/19, 11:13 PM  
Phuein
 
Phuein's Avatar
AddOn Author - Click to view AddOns

Forum posts: 132
File comments: 268
Uploads: 16
I get an error from doing this:
Code:
/calc 15051 + (11 * 4785)
Report comment to moderator  
Reply With Quote
Unread 06/17/19, 04:20 PM  
kindredspirit

Forum posts: 3
File comments: 113
Uploads: 0
Thank You

I use this addon so much. Thank you for the update!
Report comment to moderator  
Reply With Quote
Unread 06/16/19, 10:32 PM  
zeroIndex
AddOn Author - Click to view AddOns

Forum posts: 1
File comments: 18
Uploads: 2
Originally Posted by Phuein
Hey. Cool addon. Small bug report: Doing /calc in chat, without any arguments, gives an error. Better catch that case.

(I assumed it just toggles /calc open and close heh. Might want to add/replace that.)

EDIT: Without modifying your code, I added this chunk to get what I wanted:
Code:
local function lexer(text)
    -- Fixed catch error.
    if not text then
        text = ''
    end

    if text == '' then
        -- Toggle.
        Calc.CalcToggleView()
        -- NOTE Never reaches the empty case below.
        return
    end
Thanks for noticing this. I updated my code to reflect this change. It's a good catch and a nice added feature. I never thought about what would happen by just typing /calc.
Report comment to moderator  
Reply With Quote
Unread 06/16/19, 10:29 PM  
zeroIndex
AddOn Author - Click to view AddOns

Forum posts: 1
File comments: 18
Uploads: 2
Re: Love Calculator!

Originally Posted by Augestflex
I love and use calculator daily. It is a must for guild stores.

Question, would it be possible to add the ability to operate on the previous /calc entry if you start the next /calc with an operator instead of a number?
Thanks for the suggestion. I added the feature to the chat box input. If you type "Answer, answer, Ans or ans" you will be able to use your last obtained answer on the next calculation.
So you can type /calc answer + 3 or /calc ans + 3 or /calc 3 + answer. It doesn't matter where you put the answer.

Sorry for the late response, but I have been away from the game lately. I really appreciate your input and hope this is close to what you were looking for.
Report comment to moderator  
Reply With Quote
Unread 05/14/19, 09:59 AM  
Phuein
 
Phuein's Avatar
AddOn Author - Click to view AddOns

Forum posts: 132
File comments: 268
Uploads: 16
Hey. Cool addon. Small bug report: Doing /calc in chat, without any arguments, gives an error. Better catch that case.

(I assumed it just toggles /calc open and close heh. Might want to add/replace that.)

EDIT: Without modifying your code, I added this chunk to get what I wanted:
Code:
local function lexer(text)
    -- Fixed catch error.
    if not text then
        text = ''
    end

    if text == '' then
        -- Toggle.
        Calc.CalcToggleView()
        -- NOTE Never reaches the empty case below.
        return
    end
Last edited by Phuein : 05/14/19 at 10:14 AM.
Report comment to moderator  
Reply With Quote
Unread 01/20/19, 10:36 PM  
Augestflex

Forum posts: 4
File comments: 164
Uploads: 0
Love Calculator!

I love and use calculator daily. It is a must for guild stores.

Question, would it be possible to add the ability to operate on the previous /calc entry if you start the next /calc with an operator instead of a number?
Report comment to moderator  
Reply With Quote
Unread 07/04/18, 07:03 PM  
zeroIndex
AddOn Author - Click to view AddOns

Forum posts: 1
File comments: 18
Uploads: 2
Re: Needed

Originally Posted by kindredspirit
I love this addon! I use it all the time buying and selling in-game. It seems to work well even though it hasn't had a update in a long time. I just wanted to tell you that its a great addon
Thank you, I really appreciate the comment.
Report comment to moderator  
Reply With Quote
Unread 06/02/18, 09:27 AM  
kindredspirit

Forum posts: 3
File comments: 113
Uploads: 0
Needed

I love this addon! I use it all the time buying and selling in-game. It seems to work well even though it hasn't had a update in a long time. I just wanted to tell you that its a great addon
Report comment to moderator  
Reply With Quote
Unread 01/21/16, 01:44 PM  
zeroIndex
AddOn Author - Click to view AddOns

Forum posts: 1
File comments: 18
Uploads: 2
Originally Posted by coolmodi
The easiest solution I can think of is adding every input to a string and then using LoadString(string) (not sure if the L also was uppercase) to turn it into a function so it can be solved like if you would just write it in LUA code:

Lua Code:
  1. local inputString = ""
  2.  
  3. local function OnInput(input) --every button press except "=" has this as handler
  4.    inputString = inputString...input
  5.    InsertUiUpdateFunctionHere() --so it also shows up in the UI
  6. end
  7.  
  8. local function GetSolution()
  9.    local f = LoadString("return " ... inputString)
  10.    return f()
  11. end
This works like a dream. Thank you for bringing this up.

Originally Posted by coolmodi
Everything that is not local will be in the global namepsace, and if you happen to use a function name that already exists they would overwrite themself.
I have some understanding of this and that's the main reason I gave my functions long names starting with Calc. Ill work on making the functions a bit more neat and local in the future.

Originally Posted by coolmodi
Edit: And if you do this to learn/train programming, then making a parser yourself is a good idea. I also made my addons to learn a bit, and it really helps. It's just LUA, but it still helps with "thinking in code". I know what you mean with "handling the order and depth", I wouldn't have know a few months ago, but now I already can think of how it could work. So if you want to learn something then the loadString() way may be to easy
I have built a parse tree once before and I remember losing a lot of sleep over it. That was with a language I "know" a bit more about. I also had a debugger, not just the in-game errors with ESO.

The loadstring() is almost to easy. But I feel that I have a good understanding of what its doing so I don't feel cheapened by using it . However, it does blow my mind how simple this made everything.
I feel I can also use this to enhance the chat box input, but that will be for another time. School and work are keeping me busy atm.

I value your feedback and will be uploading the new version shortly. Thanks again.
Last edited by zeroIndex : 01/23/16 at 11:40 PM.
Report comment to moderator  
Reply With Quote
Unread 01/21/16, 08:32 AM  
coolmodi
AddOn Author - Click to view AddOns

Forum posts: 47
File comments: 55
Uploads: 3
Originally Posted by zeroIndex
I would like to have that kind of functionality but I find myself running into issues when trying to handle order of operations. My mind quickly starts thinking parse trees and runs away. Maybe I'm overthinking what I would have to do but I currently cannot think of a simple way of going about handling the order and depth.
The easiest solution I can think of is adding every input to a string and then using LoadString(string) (not sure if the L also was uppercase) to turn it into a function so it can be solved like if you would just write it in LUA code:

Lua Code:
  1. local inputString = ""
  2.  
  3. local function OnInput(input) --every button press except "=" has this as handler
  4.    inputString = inputString...input
  5.    InsertUiUpdateFunctionHere() --so it also shows up in the UI
  6. end
  7.  
  8. local function GetSolution()
  9.    local f = LoadString("return " ... inputString)
  10.    return f()
  11. end

What LoadString does is just turning a string into a fucntion, e.g. if inputString would be (4-3)*2, then f would behave like you wrote a function:

Lua Code:
  1. local function f()
  2.    return (4-3)*2
  3. end

and so GetSolution() would return the current solution of inputString as long as it has correct syntax.

Edit: You should also start setting your your functions either local, or adding them to the namespace of your addon by adding it in front like Calc.FunctionName() or Calc:FunctionName().

Using : means the function will get what is in front of the : as the argument "self", you can then use that as you would use Calc within the funtion. Not that useful with just Calc, but it can get handy.

Everything that is not local will be in the global namepsace, and if you happen to use a function name that already exists they would overwrite themself.

Edit: And if you do this to learn/train programming, then making a parser yourself is a good idea. I also made my addons to learn a bit, and it really helps. It's just LUA, but it still helps with "thinking in code". I know what you mean with "handling the order and depth", I wouldn't have know a few months ago, but now I already can think of how it could work. So if you want to learn something then the loadString() way may be to easy
Last edited by coolmodi : 01/21/16 at 08:50 AM.
Report comment to moderator  
Reply With Quote
Unread 01/20/16, 06:56 PM  
zeroIndex
AddOn Author - Click to view AddOns

Forum posts: 1
File comments: 18
Uploads: 2
Originally Posted by coolmodi
Why don't you just make the UI behave like a real calculator by adding brackets and just showing whatever you enter, pressing = will then solve it, as long as the syntax was correct. Would be much more useful that way if you could just enter stuff like (x+y)*(z-w).
I would like to have that kind of functionality but I find myself running into issues when trying to handle order of operations. My mind quickly starts thinking parse trees and runs away. Maybe I'm overthinking what I would have to do but I currently cannot think of a simple way of going about handling the order and depth.

Originally Posted by coolmodi
Edit: You also haven't defined LAM2 used on line 146, that throws an error. You need:
Lua Code:
  1. local LAM2 = LibStub("LibAddonMenu-2.0")
I wasn't getting an error for this. Thank you for noticing and letting me know.

Originally Posted by coolmodi
Code:
font="$(BOLD_FONT)|30|soft-shadow-thin"
verticalAlignment="CENTER"
Thanks a ton for that information. I was trying to find ways to do that but was not coming up successful. The only reason I had the word button on the buttons was to center the numbers. I thought: "Well, it's a solution". After looking at the link you provided along with what you said, it now all seems obvious.

I also noticed that I could probably just call something like:
Lua Code:
  1. CalcHandleMultipleEntryOperator()
Then I would be able to eliminate a few steps that are not needed. I also started to notice that some boolean values I used for checks were not needed because I could just if(function) == true instead of setting a value for what the function returns then checking the value. But its all a learning experience.

I have no experience with XML and very little with LUA. I started this to get a feel for what can be accomplished. And maybe rushed it a little so I could release the UI before my classes started back. School and work tend to suck up all my fun time.

I really value the feedback and will be uploading the removal of the ugly "button" words and adding the definition of LAM2
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: