Pocket Calculator!
Description
I've created a very basic calculator, that does some pretty basic math.number * numbernumber + numbernumber - numbernumber / numberThe installation is pretty easy, all you have to do is the following....
Installation
Copy one of these commands into your ComputerCraft terminal:
Pastebin:
pastebin get 0wkqTE1A pocket_calculator!wget:
wget https://pastebin.com/raw/0wkqTE1A pocket_calculator!Archive:
wget https://cc.shobie.xyz/cc/get/pb-0wkqTE1A pocket_calculator!
Quick Install:
wget https://cc.shobie.xyz/cc/get/pb-0wkqTE1A Pocket Calculator!
Usage
Run the program after downloading
Tags
Source
View Original SourceCode Preview
function draw()
term.getSize()
term.clear()
term.setCursorPos(1,1)
print("1 2 3 |")
print("4 5 6 |")
print("7 8 9 |")
print("+ 0 * |")
print("- = / |")
print("------")
if ntc == false then
write(ns)
else
write(n1..nt..ns)
end
end
nt = ""
ntc = false
ns = ""
n1 = ""
n2 = ""
np = ""
draw()
while true do
local event, button, x, y = os.pullEvent("mouse_click")
if x == 1 and y == 1 then
ns = ns.."1"
draw()
elseif x == 3 and y == 1 then
ns = ns.."2"
draw()
elseif x == 5 and y == 1 then
ns = ns.."3"
draw()
elseif x == 1 and y == 2 then
ns = ns.."4"
draw()
elseif x == 3 and y == 2 then
ns = ns.."5"
draw()
elseif x == 5 and y == 2 then
ns = ns.."6"
draw()
elseif x == 1 and y == 3 then
ns = ns.."7"
draw()
elseif x == 3 and y == 3 then
ns = ns.."8"
draw()
elseif x == 5 and y == 3 then
ns = ns.."9"
draw()
elseif x == 3 and y == 4 then
ns = ns.."0"
draw()
elseif x == 1 and y == 4 and ntc == false then
n1 = ns
ntc = true
nt = " + "
ns = ""
draw()
elseif x == 5 and y == 4 and ntc == false then
n1 = ns
ntc = true
nt = " * "
ns = ""
draw()
elseif x == 1 and y == 5 and ntc == false then
n1 = ns
ntc = true
nt = " - "
ns = ""
draw()
elseif x == 5 and y == 5 and ntc == false then
n1 = ns
ntc = true
nt = " / "
ns = ""
draw()
elseif x == 3 and y == 5 then
if nt == " + " then
print(" = "..(n1 + ns))
sleep(3)
os.reboot()
elseif nt == " * " then
print(" = "..(n1 * ns))
sleep(3)
os.reboot()
elseif nt == " - " then
print(" = "..(n1 - ns))
sleep(3)
os.reboot()
elseif nt == " / " then
print(" = "..(n1 / ns))
os.reboot()
end
end
end