Raevnos's Calculator

A four function (Well, 5 if you count the ^ (Power) key,) calculator with working () keys, and an LCD display.

Commands: @create, @link, @lset, @pemit, @set.
Compatibility: CobraMUSH, PennMUSH.

Instructions

Copy and paste the below code into a compatible MUSH or MUX.

MUSHCode for Raevnos's Calculator

@create Calculator
@lock/Basic Calculator==#1622
@lset Calculator/Basic=no_inherit
@set Calculator = VISUAL
@set Calculator = NO_COMMAND
&CALC Calculator=u(parse_parens, trim(edit(ulocal(insert_mul, edit(%0, %b, , --, +)), \(, %b\(, \), \)%b)))
&CALC_CMD Calculator=\$calc *:@pemit %#=Calc> [u(calc, %0)]
&DESCRIBE Calculator=A four function (Well, 5 if you count the ^ (Power) key,) calculator with working () keys (Thanks to Trispis for the idea for how to do that bit, as well as lots of bug testing), and an LCD display. To use, just 'calc <expression>' where <expression> is something like 1+2-3
@set Calculator/DESCRIBE=no_command visual public nearby
&DIV Calculator=if(strlen(%1), fdiv(u(parse_exp, %0), u(parse_exp, %1)), u(parse_exp, %0))
&EXP Calculator=if(strlen(%1), power(u(parse_fact, %0), u(parse_fact, %1)), u(parse_fact, %0))
&INSERT_MUL Calculator=if(regmatch(%0, lit(([0-9\)])(\()|(\))([0-9\(])), 0 1 2 3 4), u(insert_mul, edit(%0, %q0, if(%q1, %q1, %q3)*[if(%q2, %q2, %q4)])), %0)
&LICENSE Calculator=All code on this object (Raevnos's Calculator) is released under the Library Gnu Public License. A copy of that license is avaliable at [tagwrap(a, href="http://www.gnu.org/copyleft/lgpl.html", http://www.gnu.org/copyleft/lgpl.html)]
&MUL Calculator=if(strlen(%1), mul(u(parse_div, %0), u(parse_div, %1)), u(parse_div, %0))