SuicidalSTDz

EnderCalc v1.0

Feb 3rd, 2013
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.06 KB | None | 0 0
  1. function calculator()
  2. term.clear()
  3. term.setCursorPos(1,1)
  4. term.setTextColor(colors.orange)
  5. print("Please type your first number")
  6. term.setTextColor(colors.white)
  7. firstNum = read()
  8. numOneIsValid = tonumber(firstNum)
  9. if type(numOneIsValid) == "number" then
  10. term.setTextColor(colors.orange)
  11. print("Please type your second number")
  12. term.setTextColor(colors.white)
  13. secondNum = read()
  14. numTwoIsValid = tonumber(secondNum)
  15. if type(numTwoIsValid) == "number" then
  16. term.clear()
  17. term.setCursorPos(1,1)
  18. term.setTextColor(colors.orange)
  19. print("What would you like to do with these numbers?")
  20. term.setCursorPos(1,3)
  21. term.setTextColor(colors.lime)
  22. print("{Add} {Subtract} {Multiply} {Divide}")
  23. local event, button, xPos, yPos = os.pullEvent("mouse_click")
  24. if button == 1 then
  25. if (xPos >=1 and xPos <=5 and yPos == 3) then
  26. term.clear()
  27. term.setCursorPos(1,1)
  28. local sum = (firstNum+secondNum)
  29. term.setTextColor(colors.lightBlue)
  30. print("The sum of your numbers is "..sum)
  31. term.setCursorPos(1,3)
  32. term.setTextColor(colors.lime)
  33. print("{Clear} {Exit}")
  34. local event, button, xPos, yPos = os.pullEvent("mouse_click")
  35. if button == 1 then
  36. if (xPos >=1 and xPos <=7 and yPos == 3) then
  37. calculator()
  38. elseif (xPos >=9 and xPos <=14 and yPos == 3) then
  39. term.clear()
  40. term.setCursorPos(1,1)
  41. else
  42. calculator()
  43. end
  44. else
  45. calculator()
  46. end
  47. sleep(3.5)
  48. startScreen()
  49. elseif (xPos >=7 and xPos <=16 and yPos == 3) then
  50. term.clear()
  51. term.setCursorPos(1,1)
  52. local diff = (firstNum-secondNum)
  53. term.setTextColor(colors.lightBlue)
  54. term.write("The difference of your numbers is "..diff)
  55. term.setCursorPos(1,3)
  56. term.setTextColor(colors.lime)
  57. print("{Clear} {Exit}")
  58. local event, button, xPos, yPos = os.pullEvent("mouse_click")
  59. if button == 1 then
  60. if (xPos >=1 and xPos <=7 and yPos == 3) then
  61. calculator()
  62. elseif (xPos >=9 and xPos <=14 and yPos == 3) then
  63. term.clear()
  64. term.setCursorPos(1,1)
  65. else
  66. calculator()
  67. end
  68. else
  69. calculator()
  70. end
  71. elseif (xPos >=18 and xPos <=27 and yPos == 3) then
  72. term.clear()
  73. term.setCursorPos(1,1)
  74. local product = (firstNum*secondNum)
  75. term.setTextColor(colors.lightBlue)
  76. term.write("The product of your two numbers is "..product)
  77. term.setCursorPos(1,3)
  78. term.setTextColor(colors.lime)
  79. print("{Clear} {Exit}")
  80. local event, button, xPos, yPos = os.pullEvent("mouse_click")
  81. if button == 1 then
  82. if (xPos >=1 and xPos <=7 and yPos == 3) then
  83. calculator()
  84. elseif (xPos >=9 and xPos <=14 and yPos == 3) then
  85. term.clear()
  86. term.setCursorPos(1,1)
  87. else
  88. calculator()
  89. end
  90. else
  91. calculator()
  92. end
  93. elseif (xPos >=29 and xPos <=36 and yPos == 3) then
  94. term.clear()
  95. term.setCursorPos(1,1)
  96. local quotient = (firstNum/secondNum)
  97. term.setTextColor(colors.lightBlue)
  98. term.write("The quotient of your two numbers is "..quotient)
  99. term.setCursorPos(1,3)
  100. term.setTextColor(colors.lime)
  101. print("{Clear} {Exit}")
  102. local event, button, xPos, yPos = os.pullEvent("mouse_click")
  103. if button == 1 then
  104. if (xPos >=1 and xPos <=7 and yPos == 3) then
  105. calculator()
  106. elseif (xPos >=9 and xPos <=14 and yPos == 3) then
  107. term.clear()
  108. term.setCursorPos(1,1)
  109. else
  110. calculator()
  111. end
  112. else
  113. calculator()
  114. end
  115. else
  116. term.clear()
  117. term.setCursorPos(1,1)
  118. end
  119. else
  120. term.clear()
  121. term.setCursorPos(1,1)
  122. end
  123. else
  124. term.clear()
  125. term.setCursorPos(1,1)
  126. term.setTextColor(colors.red)
  127. print("The Endermen are not amused!")
  128. sleep(3)
  129. calculator()
  130. end
  131. else
  132. term.clear()
  133. term.setCursorPos(1,1)
  134. term.setTextColor(colors.red)
  135. print("The Endermen are not amused!")
  136. sleep(3)
  137. calculator()
  138. end
  139. end
  140. calculator()
Advertisement
Add Comment
Please, Sign In to add comment