theMCcm

theMCcm's EnderDice

Jul 18th, 2015
533
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.09 KB | None | 0 0
  1. --------------------------------------------------
  2. --API Load--
  3. file = fs.exists("themccm")
  4. if file == false then
  5. fs.makeDir("themccm")
  6. end
  7. file = fs.exists("themccm/enderapi")
  8. if file == false then
  9. shell.run("pastebin", "get", "5ww6Pb8i", "themccm/enderapi")
  10. end
  11. os.unloadAPI("themccm/enderapi")
  12. os.loadAPI("themccm/enderapi")
  13. --------------------------------------------------
  14. --Color Loading--
  15. file = fs.exists("themccm/enderdice")
  16. if file == false then
  17. fs.makeDir("themccm/enderdice")
  18. end
  19. file = fs.exists("themccm/enderdice/textcolor")
  20. if file == false then
  21. colorfile = fs.open("themccm/enderdice/textcolor", "w")
  22. colorfile.writeLine("red")
  23. colorfile.close()
  24. end
  25. colorfile = fs.open("themccm/enderdice/textcolor", "r")
  26. textcolor = tostring(colorfile.readLine())
  27. colorfile.close()
  28. --------------------------------------------------
  29. --Functions--
  30. function introPrint()
  31. print[[
  32. Enter 'help' For A List Of Commands
  33. What Dice Do You Want To Roll? -In Numbers-]]
  34. term.write("Roll A d")
  35. end
  36. --------------------------------------------------
  37. --Clear--
  38. enderapi.clear()
  39. --------------------------------------------------
  40. --Visuals--
  41. term.setTextColor(colors.lime)
  42. print[[
  43. --------------------------------------------------]]
  44. term.setTextColor(colors.purple)
  45. print[[
  46. ---- ----
  47. / 20 \ -------------------- / 20 \
  48. \ 20 / /Welcome To EnderDice\ \ 20 /
  49. ---- |For Your Dicey Needs| ----
  50. ---- \ Made By: theMCcm / ----
  51. / 10 \ -------------------- / 10 \
  52. \ 10 / \ 10 /
  53. ---- Beta V2.0 ----]]
  54. term.setTextColor(colors.lime)
  55. print[[
  56. --------------------------------------------------]]
  57. if colors[textcolor] then
  58. term.setTextColor(colors[textcolor])
  59. end
  60. introPrint()
  61. --------------------------------------------------
  62. --Main Code--
  63. while true do
  64. input = read()
  65. inp = tonumber(input)
  66. if type(inp) == "number" then
  67. if inp < 1 then
  68. term.clearLine()
  69. print("Sorry, But Dice Need To Be Atleast One-Sided!")
  70. elseif inp > 100000000000 then
  71. term.clearLine()
  72. print("That Would Crash The Program! Try A Smaller Number")
  73. else
  74. dice = math.random(input)
  75. term.clearLine()
  76. print("You Rolled A d"..inp.." And Got "..dice)
  77. end
  78. enderapi.lineUp()
  79. enderapi.lineUp()
  80. term.clearLine()
  81. term.write("Roll A d")
  82. else
  83. if input == "exit" or input == "Exit" or input == "E" or input == "e" or input == "EXIT" then
  84. enderapi.clear()
  85. break
  86. elseif input == "help" or input == "h" or input == "Help" or input == "H" or input == "HELP" then
  87. enderapi.lineUp()
  88. term.clearLine()
  89. term.write("Roll A d")
  90. enderapi.lineDown()
  91. enderapi.lineDown()
  92. print[[
  93. Type 'Exit' To Exit (Duh :P)
  94. Type 'Color' To Change Text Color]]
  95. enderapi.lineUp()
  96. enderapi.lineUp()
  97. enderapi.lineUp()
  98. enderapi.lineUp()
  99. term.write("Roll A d")
  100. elseif input == "color" or input == "c" or input == "Color" or input == "C" or input == "COLOR" then
  101. enderapi.lineUp()
  102. term.clearLine()
  103. term.write("Pick A Color: ")
  104. textcolor = read()
  105. if colors[textcolor] then
  106. term.setTextColor(colors[textcolor])
  107. colorfile = fs.open("themccm/enderdice/textcolor", "w")
  108. colorfile.writeLine(textcolor)
  109. colorfile.close()
  110. end
  111. term.clearLine()
  112. enderapi.lineDown()
  113. term.clearLine()
  114. enderapi.lineDown()
  115. term.clearLine()
  116. enderapi.lineUp()
  117. enderapi.lineUp()
  118. enderapi.lineUp()
  119. term.clearLine()
  120. enderapi.lineUp()
  121. term.clearLine()
  122. enderapi.lineUp()
  123. term.clearLine()
  124. introPrint()
  125. else
  126. enderapi.lineUp()
  127. term.clearLine()
  128. term.write("Roll A d")
  129. enderapi.lineDown()
  130. term.clearLine()
  131. print("That Wasnt A Number! Try Again.")
  132. enderapi.lineUp()
  133. enderapi.lineUp()
  134. term.write("Roll A d")
  135. end
  136. end
  137. end
  138. --------------------------------------------------
  139. --Extras--
  140.  
  141. --Pastebin: www.pastebin.com/KXRzGDcC
  142.  
  143. --CompCraft Forums:
  144. ---http://www.computercraft.info/forums2/index.php?/topic/24031-enderdice/
  145.  
  146. --Thanks All And Hope You Enjoy My Dice Roller!
  147. --------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment