Guest User

EnderDice

a guest
Jul 19th, 2015
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.85 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/API")
  8. if file == false then
  9.  shell.run("pastebin", "get", "5ww6Pb8i", "themccm/API")
  10. end
  11. os.unloadAPI("themccm/API")
  12. os.loadAPI("themccm/API")
  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 = 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. 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  V1.1             ----]]
  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.  lineUp()
  79.  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.   clear()
  85.   break
  86.  elseif input == "help" or input == "h" or input == "Help" or input == "H" or input == "HELP" then
  87.   lineUp()
  88.   term.clearLine()
  89.   term.write("Roll A d")
  90.   lineDown()
  91.   lineDown()
  92.   print[[
  93. Type 'Exit' To Exit (Duh :P)
  94. Type 'Color' To Change Text Color]]
  95.   lineUp()
  96.   lineUp()
  97.   lineUp()
  98.   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.   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("colors."..textcolor)
  109.   end
  110.   term.clearLine()
  111.   lineDown()
  112.   term.clearLine()
  113.   lineDown()
  114.   term.clearLine()
  115.   lineUp()
  116.   lineUp()
  117.   lineUp()
  118.   term.clearLine()
  119.   lineUp()
  120.   term.clearLine()
  121.   lineUp()
  122.   term.clearLine()
  123.   introPrint()
  124.  else
  125.  lineUp()
  126.  term.clearLine()
  127.  term.write("Roll A d")
  128.  lineDown()
  129.  term.clearLine()
  130.  print("That Wasnt A Number! Try Again.")
  131.  lineUp()
  132.  lineUp()
  133.  term.write("Roll A d")
  134.  end
  135. end
  136. end
  137. --------------------------------------------------
  138. --Extras--
  139.  
  140. --Pastebin: www.pastebin.com/KXRzGDcC
  141.  
  142. --CompCraft Forums:
  143. ---http://www.computercraft.info/forums2/index.php?/topic/24031-enderdice/
  144.  
  145. --Thanks All And Hope You Enjoy My Dice Roller!
  146. --------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment