Edit: Version 1.1 is out and I'm already working on the next one, this project is mainly for me to use as an actual calculator (!) better than the default OSX one =P
The previous one was version 0.9

Hi everyone!
This is my first post here, although I have been lurking around here for quite a while. I have seen some of the people who frequent the forums, and even taken inspiration from one! :)/>
I was inspired by Cranium's Advanced calculator, http://www.computerc...ced-calculator/, and while I'm not that good, I managed to put together something fairly compact and simple. ;)/>
Feel free to edit everything and either learn something, or give critique for something stupid I've done…hehehe.
Maybe mention me if you use this for something? I would be a happy fox in that case :D/>

Spoiler–[[ CREDITS:
author: John K "supernicejohn"
Fraise / Smultron 3
Saving to ccemuredux instead of desktop…
yeah… debug for nothing.
Inspiration: Cranium on computercraft forums!
]]
local bkg = [[
————————
| |
| |
[7][8][9] [nRx][-][/]|
[4][5][6] [Pi ][+][*]|
[1][2][3] [ack][=][^]|
[0][.][Neg] [Abs][C]EXIT
————————
]]
V = "CC_calculator_v1.1public.txt"
s = term.setCursorPos
function nRx()
sum = math.pow(num2,(1/num1))
end
function neg()
if num == 1 and num1 > 0 then
num1 = num1 - (num1*2)
elseif num == 2 and num2 > 0 then
num2 = num2 - (num2*2)
end
end
function ack(num1,num2)
if num1 == 0 then
return num2 + 1
end
if num2 == 0 then
return ack(num1-1,num2)
end
return ack(num1-1,ack(num1,num2-1))
end
function abs()
if num == 1 then
num1 = math.abs(num1)
elseif num == 2 then
num2 = math.abs(num2)
end
end
function add()
sum = num1 + num2
end
function sub()
sum = num1 - num2
end
function power()
sum = math.pow(num1,num2)
end
function mlt()
sum = num1 * num2
end
function div()
sum = num1 / num2
end
function intadd(number)
if num == 1 then
if number == "." then
decimal1 = true
else
if decimal1 == false then
num1 = (num1 * 10) + number
else
num1 = ((num1 * 10^decvar1) + number) / 10^decvar1
decvar1 = decvar1 + 1
end
end
elseif num == 2 then
if number == "." then
decimal2 = true
else
if decimal2 == false then
num2 = (num2 * 10) + number
else
num2 = ((num2 * 10^decvar2) + number) / 10^decvar2
decvar2 = decvar2 + 1
end
end
end
end
num = 1
number = nil
num1 = 0
num2 = 0
sum = nil
decvar1 = 1
decvar2 = 1
decimal1 = false
decimal2 = false
op = nil
run = true
while run == true do
term.clear()
s(1,1)
print(bkg)
if sum ~= nil then
num1 = sum
sum = nil
num2 = 0
end
s(2,2)
print(num1)
s(2,3)
print(num2)
local _, b, x, y = os.pullEvent("mouse_click")
if y == 4 then
if x < 4 then
intadd(7)
elseif x > 3 and x < 7 then
intadd(8)
elseif x > 6 and x < 10 then
intadd(9)
elseif x > 12 and x < 18 then
op = "nRx"
num = 2
elseif x > 17 and x < 21 then
op = "-"
num = 2
elseif x > 20 then
op = "div"
num = 2
end
elseif y == 5 then
if x < 4 then
intadd(4)
elseif x > 3 and x < 7 then
intadd(5)
elseif x > 6 and x < 10 then
intadd(6)
elseif x > 12 and x < 18 then
if num == 1 then
if num1 == 0 then
num1 = math.pi
else
num1 = num1 * math.pi
end
elseif num == 2 then
if num2 == 0 then
num2 = math.pi
else
num2 = num2 * math.pi
end
end
elseif x > 17 and x < 21 then
op = "+"
num = 2
elseif x > 20 then
op = "mlt"
num = 2
end
elseif y == 6 then
if x < 4 then
intadd(1)
elseif x > 3 and x < 7 then
intadd(2)
elseif x > 6 and x < 10 then
intadd(3)
elseif x > 12 and x < 18 then
op = "ack"
num = 2
elseif x > 17 and x < 21 then
if op == "+" then
add()
elseif op == "-" then
sub()
elseif op == "pow" then
power()
elseif op == "div" then
div()
elseif op == "mlt" then
mlt()
elseif op == "nRx" then
nRx()
elseif op == "ack" then
sum = ack(num1,num2)
end
elseif x > 20 then
op = "pow"
num = 2
end
elseif y == 7 then
if x < 4 then
intadd(0)
elseif x > 3 and x < 7 then
intadd(".")
elseif x > 6 and x < 10 then
neg()
elseif x > 12 and x < 18 then
abs()
elseif x > 17 and x < 21 then
sum = nil
num1 = 0
decimal1 = false
decimal2 = false
decvar1 = 1
decvar2 = 1
num2 = 0
num = 1
op = nil
elseif x > 20 then
term.clear()
s(1,1)
print(V)
sleep(1)
term.clear()
s(1,1)
run = false
end
elseif y == 8 then
if x > 18 then
term.clear()
s(1,1)
shell.run(V)
end
end
end
Download it! (If you want)

pastebin get NaMBbhWE CC_calculator
or http://pastebin.com/NaMBbhWE

Please give feedback if it's not working for some reason… I have done testing but on other versions who knows :rolleyes:/>
I also accept suggestions for adding stuff, but maybe you can figure out how to yourself, in that case, post it here and maybe you'll let me add it with your name in the credits!

Anyways, I look forward to learn a lot stuff on here :D/>
Keep your stick on the ice.