Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Coded by SuicidalSTDz
- --License:
- --The code of "EnderCalc" in any form is intellectual
- --property of SuicidalSTDz. You may revise code for
- --personal use only! Do not distribute! You may use this calculator
- --in any programs or OS's as long as credit is given the the
- --original author "SuicidalSTDz"
- --Enjoy!
- function calculator()
- function reset()
- term.clear()
- term.setCursorPos(1,1)
- end
- reset()
- term.setTextColor(colors.orange)
- print("What would you like to do?")
- term.setCursorPos(1,3)
- term.setTextColor(colors.lime)
- print("{Add} {Subtract} {Multiply} {Divide}")
- term.setCursorPos(1,5)
- print("{Generate a random number}")
- local event, button, xPos, yPos = os.pullEvent("mouse_click")
- if button == 1 then
- if (xPos >=1 and xPos <=5 and yPos == 3) then
- reset()
- term.setTextColor(colors.orange)
- print("Please enter your first number")
- term.setTextColor(colors.white)
- firstNum = read()
- if #firstNum >6 then
- reset()
- term.setTextColor(colors.red)
- print("I'm sorry, us Endermen cannot calculate that much")
- sleep(3)
- calculator()
- end
- numOneIsValid = tonumber(firstNum)
- if type(numOneIsValid) == "number" then
- term.setTextColor(colors.orange)
- print("Please type your second number")
- term.setTextColor(colors.white)
- secondNum = read()
- if #secondNum >6 then
- reset()
- term.setTextColor(colors.red)
- print("I'm sorry, us Endermen cannot calculate that much")
- sleep(3)
- calculator()
- end
- numTwoIsValid = tonumber(secondNum)
- if type(numTwoIsValid) == "number" then
- reset()
- local sum = (firstNum+secondNum)
- term.setTextColor(colors.lightBlue)
- print("The sum of your numbers is "..sum)
- term.setCursorPos(1,3)
- term.setTextColor(colors.lime)
- print("{Clear} {Exit}")
- local event, button, xPos, yPos = os.pullEvent("mouse_click")
- if button == 1 then
- if (xPos >=1 and xPos <=7 and yPos == 3) then
- calculator()
- elseif (xPos >=9 and xPos <=14 and yPos == 3) then
- calculator()
- else
- calculator()
- end
- else
- calculator()
- end
- else
- reset()
- term.setTextColor(colors.red)
- print("The Endermen are not amused!")
- sleep(3)
- calculator()
- end
- else
- reset()
- term.setTextColor(colors.red)
- print("The Endermen are not amused!")
- sleep(3)
- calculator()
- end
- elseif (xPos >=7 and xPos <=16 and yPos == 3) then
- reset()
- term.setTextColor(colors.orange)
- print("Please enter your first number")
- term.setTextColor(colors.white)
- firstNum = read()
- if #firstNum >6 then
- reset()
- term.setTextColor(colors.red)
- print("I'm sorry, us Endermen cannot calculate that much")
- sleep(3)
- calculator()
- end
- numOneIsValid = tonumber(firstNum)
- if type(numOneIsValid) == "number" then
- term.setTextColor(colors.orange)
- print("Please type your second number")
- term.setTextColor(colors.white)
- secondNum = read()
- if #secondNum >6 then
- reset()
- term.setTextColor(colors.red)
- print("I'm sorry, us Endermen cannot calculate that much")
- sleep(3)
- calculator()
- end
- numTwoIsValid = tonumber(secondNum)
- if type(numTwoIsValid) == "number" then
- reset()
- local diff = (firstNum-secondNum)
- term.setTextColor(colors.lightBlue)
- term.write("The difference of your numbers is "..diff)
- term.setCursorPos(1,3)
- term.setTextColor(colors.lime)
- print("{Clear} {Exit}")
- local event, button, xPos, yPos = os.pullEvent("mouse_click")
- if button == 1 then
- if (xPos >=1 and xPos <=7 and yPos == 3) then
- calculator()
- elseif (xPos >=9 and xPos <=14 and yPos == 3) then
- calculator()
- else
- calculator()
- end
- else
- calculator()
- end
- else
- reset()
- term.setTextColor(colors.red)
- print("The Endermen are not amused!")
- sleep(3)
- calculator()
- end
- else
- reset()
- term.setTextColor(colors.red)
- print("The Endermen are not amused!")
- sleep(3)
- calculator()
- end
- elseif (xPos >=18 and xPos <=27 and yPos == 3) then
- reset()
- term.setTextColor(colors.orange)
- print("Please enter your first number")
- term.setTextColor(colors.white)
- firstNum = read()
- if #firstNum >6 then
- reset()
- term.setTextColor(colors.red)
- print("I'm sorry, us Endermen cannot calculate that much")
- sleep(3)
- calculator()
- end
- numOneIsValid = tonumber(firstNum)
- if type(numOneIsValid) == "number" then
- term.setTextColor(colors.orange)
- print("Please type your second number")
- term.setTextColor(colors.white)
- secondNum = read()
- if #secondNum >6 then
- reset()
- term.setTextColor(colors.red)
- print("I'm sorry, us Endermen cannot calculate that much")
- sleep(3)
- calculator()
- end
- numTwoIsValid = tonumber(secondNum)
- if type(numTwoIsValid) == "number" then
- local product = (firstNum*secondNum)
- reset()
- term.setTextColor(colors.lightBlue)
- term.write("The product of your two numbers is "..product)
- term.setCursorPos(1,3)
- term.setTextColor(colors.lime)
- print("{Clear} {Exit}")
- local event, button, xPos, yPos = os.pullEvent("mouse_click")
- if button == 1 then
- if (xPos >=1 and xPos <=7 and yPos == 3) then
- calculator()
- elseif (xPos >=9 and xPos <=14 and yPos == 3) then
- calculator()
- else
- calculator()
- end
- else
- calculator()
- end
- else
- reset()
- term.setTextColor(colors.red)
- print("The Endermen are not amused!")
- sleep(3)
- calculator()
- end
- else
- reset()
- term.setTextColor(colors.red)
- print("The Endermen are not amused!")
- sleep(3)
- calculator()
- end
- elseif (xPos >=29 and xPos <=36 and yPos == 3) then
- reset()
- term.setTextColor(colors.orange)
- print("Please enter your first number")
- term.setTextColor(colors.white)
- firstNum = read()
- if #firstNum >6 then
- reset()
- term.setTextColor(colors.red)
- print("I'm sorry, us Endermen cannot calculate that much")
- sleep(3)
- calculator()
- end
- numOneIsValid = tonumber(firstNum)
- if type(numOneIsValid) == "number" then
- term.setTextColor(colors.orange)
- print("Please type your second number")
- term.setTextColor(colors.white)
- secondNum = read()
- if #firstNum >6 then
- reset()
- term.setTextColor(colors.red)
- print("I'm sorry, us Endermen cannot calculate that much")
- sleep(3)
- calculator()
- end
- numTwoIsValid = tonumber(secondNum)
- if type(numTwoIsValid) == "number" then
- reset()
- local quotient = (firstNum/secondNum)
- term.setTextColor(colors.lightBlue)
- term.write("The quotient of your two numbers is "..quotient)
- term.setCursorPos(1,3)
- term.setTextColor(colors.lime)
- print("{Clear} {Exit}")
- local event, button, xPos, yPos = os.pullEvent("mouse_click")
- if button == 1 then
- if (xPos >=1 and xPos <=7 and yPos == 3) then
- calculator()
- elseif (xPos >=9 and xPos <=14 and yPos == 3) then
- calculator()
- else
- calculator()
- end
- else
- calculator()
- end
- else
- reset()
- term.setTextColor(colors.red)
- print("The Endermen are not amused!")
- sleep(3)
- calculator()
- end
- else
- reset()
- term.setTextColor(colors.red)
- print("The Endermen are not amused!")
- sleep(3)
- calculator()
- end
- elseif (xPos >=1 and xPos <=26 and yPos == 5) then
- reset()
- term.setTextColor(colors.orange)
- print("Please enter your first number")
- term.setTextColor(colors.white)
- firstNum = read()
- numOneIsValid = tonumber(firstNum)
- if type(numOneIsValid) == "number" then
- term.setTextColor(colors.orange)
- print("Please type your second number")
- term.setTextColor(colors.white)
- secondNum = read()
- if #secondNum >6 then
- reset()
- term.setTextColor(colors.red)
- print("I'm sorry, us Endermen cannot calculate that much")
- sleep(3)
- calculator()
- end
- numTwoIsValid = tonumber(secondNum)
- if type(numTwoIsValid) == "number" then
- if firstNum > secondNum then
- term.setTextColor(colors.red)
- print("Try reversing your numbers, smaller first, larger last")
- sleep(3)
- calculator()
- end
- reset()
- local randomNum = math.random(firstNum,secondNum)
- term.setTextColor(colors.lightBlue)
- term.write("A random number between "..firstNum.." and "..secondNum.." is "..randomNum)
- term.setCursorPos(1,3)
- term.setTextColor(colors.lime)
- print("{Clear} {Exit}")
- local event, button, xPos, yPos = os.pullEvent("mouse_click")
- if button == 1 then
- if (xPos >=1 and xPos <=7 and yPos == 3) then
- calculator()
- elseif (xPos >=9 and xPos <=14 and yPos == 3) then
- calculator()
- else
- calculator()
- end
- else
- calculator()
- end
- else
- reset()
- term.setTextColor(colors.red)
- print("The Endermen are not amused!")
- sleep(3)
- calculator()
- end
- else
- reset()
- term.setTextColor(colors.red)
- print("The Endermen are not amused!")
- sleep(3)
- calculator()
- end
- else
- calculator()
- end
- else
- calculator()
- end
- end
- calculator()
Advertisement
Add Comment
Please, Sign In to add comment