Advertisement
honeyphos1234

Computercraft slots game

Jun 24th, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[
  2. Slots made By Honeyphos1234
  3. ]]--
  4. if fs.exists("slots.nfp") or fs.exists("slotss.nfp") or fs.exists("slotsss.nfp") then
  5.  
  6.   sleep(0.1)
  7.   else
  8.   term.clear()
  9.   term.setCursorPos(10,7)
  10.   print("Getting files...")
  11.   sleep(1)
  12.   term.setCursorPos(10,8)
  13.   print("Loading...")
  14.   sleep(1)
  15.   shell.run("pastebin","get","ZyaRvsfq","slots.nfp")
  16.   shell.run("pastebin","get","EjCaYXsF","slotss.nfp")
  17.   shell.run("pastebin","get","Asj0k6Px","slotsss.nfp")
  18.   term.setCursorPos(10,9)
  19.   print("Done")
  20.   end
  21.  
  22. term.setBackgroundColor(colors.magenta)
  23. term.clear()
  24. term.setCursorPos(10,8)
  25. print("How many attempts do you want?")
  26. term.setCursorPos(10,9)
  27. attempts = tonumber(read())
  28. function image()
  29.  
  30. p = paintutils.loadImage("slots.nfp")
  31. paintutils.drawImage(p,1,1)
  32. term.setCursorPos(1,1)
  33. term.setTextColor(colors.purple)
  34. print("V Alpha 0.2 Made by Sandis")
  35. term.setTextColor(colors.black)
  36. term.setBackgroundColor(colors.purple)
  37. term.setCursorPos(1,18)
  38. print(" Win Table ")
  39. term.setBackgroundColor(colors.magenta)
  40. term.setCursorPos(12,9)
  41. print("You've spent "..tests.." out of "..attempts.." tries.")
  42. end
  43.  
  44. tests = 0
  45. while true do
  46.   if tests == attempts then
  47.     term.clear()
  48.     term.setCursorPos(10,8)
  49.     print("You've spent your "..tests.." tries.")
  50.     sleep(2.5)
  51.     shell.run("slot")
  52.     end
  53. image()
  54. term.setCursorPos(16,13)
  55. print("K")
  56. term.setCursorPos(26,13)
  57. print("Q")
  58. term.setCursorPos(36,13)
  59. print("D")
  60.  
  61. term.setBackgroundColor(colors.purple)
  62. term.setCursorPos(1,18)
  63. print(" Win table ")
  64. term.setBackgroundColor(colors.magenta)
  65.  
  66. local event, button, x, y = os.pullEvent("monitor_touch")
  67.  
  68. if button == 1 and x == 47 or x == 48 or x == 49 or x == 50 or x == 51 or x == 52 or x == 53 and y == 2 or y == 3 or y == 4 or y == 5 or y == 6 then
  69.   tests = tests + 1
  70.   s = paintutils.loadImage("slotsss.nfp")
  71.   paintutils.drawImage(s,1,1)
  72.   sleep(0.2)
  73.   q = paintutils.loadImage("slotss.nfp")
  74.   paintutils.drawImage(q,1,1)
  75.   sleep(0.2)
  76.   paintutils.drawImage(s,1,1)
  77.   sleep(0.2)
  78.   image()
  79.  
  80.   repeat
  81.    
  82.     num = math.random(1,7)
  83.     num1 = math.random(1,7)
  84.     num2 = math.random(1,7)
  85.     if num == 1 then
  86.       --term.clear()
  87.       --image()
  88.      
  89.       term.setCursorPos(15,13)
  90.       print(" K ")
  91.       sleep(0.1)
  92.     elseif num == 2 then
  93.       --term.clear()
  94.       --image()
  95.      
  96.       term.setCursorPos(15,13)
  97.       print(" Q ")
  98.       sleep(0.1)
  99.     elseif num == 3 then
  100.       --term.clear()
  101.       --image()
  102.       term.setCursorPos(15,13)
  103.       print(" C ")
  104.       sleep(0.1)
  105.     elseif num == 4 then
  106.       --term.clear()
  107.       --image()
  108.       term.setCursorPos(15,13)
  109.       print(" G ")
  110.       sleep(0.1)
  111.     elseif num == 5 then
  112.       --term.clear()
  113.       --image()
  114.       term.setCursorPos(15,13)
  115.       print(" D ")
  116.       sleep(0.1)
  117.     elseif num == 6 then
  118.       --term.clear()
  119.       --image()
  120.       term.setCursorPos(15,13)
  121.       print(" I ")
  122.       sleep(0.1)
  123.     elseif num == 7 then
  124.       num = num + 2
  125.       end
  126.         if num > 9 then
  127.       break
  128.         end
  129.    
  130.     if num1 == 1 then
  131.       --term.clear()
  132.       --image()
  133.      
  134.       term.setCursorPos(25,13)
  135.       print(" K ")
  136.       sleep(0.1)
  137.      
  138.     elseif num1 == 2 then
  139.       --term.clear()
  140.       --image()
  141.       term.setCursorPos(25,13)
  142.       print(" Q ")
  143.       sleep(0.1)
  144.     elseif num1 == 3 then
  145.       --term.clear()
  146.       --image()
  147.       term.setCursorPos(25,13)
  148.       print(" C ")
  149.       sleep(0.1)
  150.     elseif num1 == 4 then
  151.       --term.clear()
  152.       --image()
  153.       term.setCursorPos(25,13)
  154.       print(" G ")
  155.       sleep(0.1)
  156.     elseif num1 == 5 then
  157.       --term.clear()
  158.       --image()
  159.       term.setCursorPos(25,13)
  160.       print(" D ")
  161.       sleep(0.1)
  162.     elseif num1 == 6 then
  163.       --term.clear()
  164.       --image()
  165.       term.setCursorPos(25,13)
  166.       print(" I ")
  167.       sleep(0.1)
  168.     elseif num1 == 7 then
  169.       num1 = num1 + 2
  170.       end
  171.       if num1 > 9 then
  172.       break
  173.       end
  174.    
  175.     if num2 == 1 then
  176.       --term.clear()
  177.       --image()
  178.      
  179.       term.setCursorPos(35,13)
  180.       print(" K ")
  181.       sleep(0.1)
  182.      
  183.     elseif num2 == 2 then
  184.       --term.clear()
  185.       --image()
  186.          
  187.       term.setCursorPos(35,13)
  188.       print(" Q ")
  189.       sleep(0.1)
  190.      
  191.     elseif num2 == 3 then
  192.       --term.clear()
  193.       --image()
  194.       term.setCursorPos(35,13)
  195.       print(" C ")
  196.       sleep(0.1)
  197.      
  198.     elseif num2 == 4 then
  199.       --term.clear()
  200.       --image()
  201.       term.setCursorPos(35,13)
  202.       print(" G ")
  203.       sleep(0.1)
  204.      
  205.     elseif num2 == 5 then
  206.       --term.clear()
  207.       --image()
  208.       term.setCursorPos(35,13)
  209.       print(" D ")
  210.       sleep(0.1)
  211.      
  212.     elseif num2 == 6 then
  213.       --term.clear()
  214.       --image()
  215.       term.setCursorPos(35,13)
  216.       print(" I ")
  217.       sleep(0.1)
  218.       elseif num2 == 7 then
  219.       num2 = num2 + 9
  220.      
  221.       if num2 > 9 then
  222.       break
  223.       end
  224.     elseif tests == attempts then
  225.       term.clear()
  226.       term.setCursorPos(10,8)
  227.       print("You've spent your "..attempts.." attempts.")
  228.       sleep(3)
  229.       shell.run("slots")
  230.     end
  231.    
  232.   until num == num1 and num == num2
  233.   if num == num1 and num == num2 and num2 == num1 then
  234.     term.setCursorPos(18,18)
  235.     print("You won price "..num.."!")
  236.     sleep(1)
  237.    
  238.     --shell.run("slots")
  239.   else
  240.     term.setCursorPos(18,18)
  241.     print("You didn't win :(")
  242.     sleep(1)
  243.    
  244.   end
  245. elseif x == 1 or x == 2 or x == 3 or x == 4 or x == 5 or x == 6 or x == 7 or x == 8 and y == 19 then
  246.   if fs.exists("/slots-config") then
  247.     f = fs.open("/slots-config","r")
  248.     message1 = f.readLine()
  249.     message2 = f.readLine()
  250.     message3 = f.readLine()
  251.     message4 = f.readLine()
  252.     message5 = f.readLine()
  253.     message6 = f.readLine()
  254.       if message1 == nil or message2 == nil or message3 == nil or message4 == nil or message5 == nil or message6 == nil then
  255.        term.clear()
  256.        term.setCursorPos(1,1)
  257.        print("You have to define these messages in the slots-config file")
  258.        sleep(2)
  259.        break
  260.        end
  261.        f.close()
  262.     term.clear()
  263.     term.setCursorPos(5,5)
  264.     print("D D D = "..message1)
  265.     term.setCursorPos(5,6)
  266.     print("G G G = "..message2)
  267.     term.setCursorPos(5,7)
  268.     print("I I I = "..message3)
  269.     term.setCursorPos(5,8)
  270.     print("R R R = "..message4)
  271.     term.setCursorPos(5,9)
  272.     print("L L L = "..message5)
  273.     term.setCursorPos(5,10)
  274.     print("C C C = "..message6)
  275.     sleep(3)
  276.   elseif not fs.exists("/slots-config") then
  277.     term.clear()
  278.     term.setCursorPos(1,1)
  279.     print("Please define these messages")
  280.     print("In the file called 'slots-config'")
  281.     sleep(2)
  282.     q = fs.open("/slots-config","w")
  283.     q.writeLine("Put your messages for the win table")
  284.     q.writeLine("here. 1st line = D(Diamond win)")
  285.     q.writeLine("2nd Line = G(Gold win)")
  286.     q.writeLine("3rd Line = I(Iron win)")
  287.     q.writeLine("4th Line = R(Redstone win)")
  288.     q.writeLine("5th Line = L(Lapis win)")
  289.     q.writeLine("6th Line = C(CAKE WIN)")
  290.     q.writeLine("All lines under line 6 is useless")
  291.     q.writeLine("Make sure you delete all this text")
  292.     q.writeLine("And put in your own messages")
  293.     q.close()
  294.     end
  295.   end
  296. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement