xXm0dzXx

Untitled

May 22nd, 2012
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. xs, ys = term.getSize()
  2. input = ""
  3. input2 = ""
  4. test = ""
  5. tempinput = ""
  6.  
  7. inputpart = 1
  8. function cwrite(blah, y)
  9. local x = math.ceil(((xs/2)-(string.len(blah)/2)))
  10. term.setCursorPos(x,y)
  11. write(blah)
  12. end
  13.  
  14. cmenu = num
  15. sid = 0
  16. function clear()
  17. term.clear()
  18. term.setCursorPos(1,1)
  19. end
  20.  
  21. function menu(id, text, x, y)
  22. term.setCursorPos(x, y)
  23. print(text)
  24. if sid == id then
  25. term.setCursorPos(x,y)
  26. write">"
  27. else
  28. term.setCursorPos(x,y)
  29. write"*"
  30. end
  31. end
  32.  
  33. while true do
  34. clear()
  35. cwrite("===================================",1)
  36. cwrite("= =",2)
  37. cwrite(input .. test .. input2,2)
  38. cwrite("===================================",3)
  39. cwrite("=======================================",4)
  40. menu(0,"= 7 =", 6, 5)
  41. menu(1,"= 8 =", 10, 5)
  42. menu(2,"= 9 =", 14, 5)
  43. menu(3,"= 4 =", 6, 6)
  44. menu(4,"= 5 =", 10, 6)
  45. menu(5,"= 6 =", 14, 6)
  46. menu(6,"= 1 =", 6, 7)
  47. menu(7,"= 2 =", 10, 7)
  48. menu(8,"= 3 =", 14, 7)
  49. menu(9,"= - =", 6, 8)
  50. menu(10,"= 0 =", 10, 8)
  51. menu(11,"= . =", 14, 8)
  52. cwrite("=======================================",9)
  53. sleep(0)
  54. event, key = os.pullEvent("key")
  55. if key == 200 then
  56. if sid > 2 then
  57. sid = sid - 3
  58. end
  59. elseif key == 203 then
  60. if sid > 0 then
  61. sid = sid - 1
  62. end
  63. elseif key == 205 then
  64. if sid < 11 then
  65. sid = sid + 1
  66. end
  67. elseif key == 208 then
  68. if sid <= 11-3 then
  69. sid = sid + 3
  70. end
  71. elseif key == 29 then
  72. if cmenu == num then
  73. cmenu = action
  74. elseif cmenu == action then
  75. cmenu = num
  76. end
  77. end
  78. if key == 28 then
  79. if sid == 0 then
  80. tempinput = tempinput.."7"
  81. elseif sid == 1 then
  82. tempinput = tempinput.."8"
  83. elseif sid == 2 then
  84. tempinput = tempinput.."9"
  85. elseif sid == 3 then
  86. tempinput = tempinput.."4"
  87. elseif sid == 4 then
  88. tempinput = tempinput.."5"
  89. elseif sid == 5 then
  90. tempinput = tempinput.."6"
  91. elseif sid == 6 then
  92. tempinput = tempinput.."1"
  93. elseif sid == 7 then
  94. tempinput = tempinput.."2"
  95. elseif sid == 8 then
  96. tempinput = tempinput.."3"
  97. elseif sid == 9 then
  98. if input2 == "" then
  99. test = "-"
  100. inputpart = 2
  101. tempinput = ""
  102. else
  103. if test == "-" then
  104. answer = tonumber(input) - tonumber(input2)
  105. input2 = ""
  106. test = ""
  107. tempinput = answer
  108. inputpart = 1
  109. end
  110. end
  111. elseif sid == 10 then
  112. tempinput = tempinput.."0"
  113. elseif sid == 11 then
  114. tempinput = tempinput.."."
  115. end
  116. end
  117.  
  118.  
  119. if inputpart == 1 then
  120. input = tempinput
  121. else
  122. input2 = tempinput
  123. end
  124. end
Advertisement
Add Comment
Please, Sign In to add comment