Scorpionfien

slotMachine

Aug 16th, 2015
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.19 KB | None | 0 0
  1. mon = peripheral.wrap("monitor_0")
  2. rs.setBundledOutput("bottom", 0)
  3.  
  4. --Determin odds (less numbers = higher odds, more numbers = lower odds)
  5. sm = { 1, 2, 3, 4, 5, 6, 7,}
  6. mon.setTextScale(1.5)
  7.  
  8. --wait screen labels
  9. label = {one = "Insert One", two = "Iron Ingot", three = "to Spin", four = "Prizes:", five = "Match 2", six = "Diamond", seven = "Match 3", eight = "Emerald", nine = "All 7's", ten = "Octuple Compressed", eleven = "Cobblestone",}
  10.  
  11. --idle screen
  12. function wait()
  13. mon.clear()
  14. mon.setCursorPos(3,1)
  15. mon.write(label.one)
  16. mon.setCursorPos(3,2)
  17. mon.write(label.two)
  18. mon.setCursorPos(3,3)
  19. mon.write(label.three)
  20. sleep(3)
  21. prizes()
  22. end
  23.  
  24. function prizes()
  25. mon.clear()
  26. mon.setCursorPos(3,2)
  27. mon.write(label.four)
  28. sleep(3)
  29. mon.clear()
  30. mon.setCursorPos(3,1)
  31. mon.write(label.five)
  32. mon.setCursorPos(3,2)
  33. mon.write(label.six)
  34. sleep(3)
  35. mon.clear()
  36. mon.setCursorPos(3,1)
  37. mon.write(label.seven)
  38. mon.setCursorPos(3,2)
  39. mon.write(label.eight)
  40. sleep(3)
  41. mon.setCursorPos(3,1)
  42. mon.write(label.nine)
  43. mon.setCursorPos(1,2)
  44. mon.write(label.ten)
  45. mon.setCursorPos(2,3)
  46. mon.write(label.eleven)
  47. sleep(3)
  48. wait()
  49. end
  50.  
  51. --simulates spinning, attach to note blocks
  52. function spin()
  53. rs.setBundledOutput("bottom", colors.combine(rs.getBundledOutput("bottom"), colors.magenta))
  54. sleep(0.1)
  55. rs.setBundledOutput("bottom", colors.subtract(rs.getBundledOutput("bottom"), colors.magenta))
  56. sleep(0.1)
  57. rs.setBundledOutput("bottom", colors.combine(rs.getBundledOutput("bottom"), colors.lightBlue))
  58. sleep(0.1)
  59. rs.setBundledOutput("bottom", colors.subtract(rs.getBundledOutput("bottom"), colors.lightBlue))
  60. sleep(0.1)
  61. rs.setBundledOutput("bottom", colors.combine(rs.getBundledOutput("bottom"), colors.yellow))
  62. sleep(0.1)
  63. rs.setBundledOutput("bottom", colors.subtract(rs.getBundledOutput("bottom"), colors.yellow))
  64. sleep(0.1)
  65. rs.setBundledOutput("bottom", colors.combine(rs.getBundledOutput("bottom"), colors.lime))
  66. sleep(0.1)
  67. rs.setBundledOutput("bottom", colors.subtract(rs.getBundledOutput("bottom"), colors.lime))
  68. sleep(0.1)
  69. rs.setBundledOutput("bottom", colors.combine(rs.getBundledOutput("bottom"), colors.magenta))
  70. sleep(0.1)
  71. rs.setBundledOutput("bottom", colors.subtract(rs.getBundledOutput("bottom"), colors.magenta))
  72. sleep(0.1)
  73. rs.setBundledOutput("bottom", colors.combine(rs.getBundledOutput("bottom"), colors.lightBlue))
  74. sleep(0.1)
  75. rs.setBundledOutput("bottom", colors.subtract(rs.getBundledOutput("bottom"), colors.lightBlue))
  76. sleep(0.1)
  77. rs.setBundledOutput("bottom", colors.combine(rs.getBundledOutput("bottom"), colors.yellow))
  78. sleep(0.1)
  79. rs.setBundledOutput("bottom", colors.subtract(rs.getBundledOutput("bottom"), colors.yellow))
  80. sleep(0.1)
  81. rs.setBundledOutput("bottom", colors.combine(rs.getBundledOutput("bottom"), colors.lime))
  82. sleep(0.1)
  83. rs.setBundledOutput("bottom", colors.subtract(rs.getBundledOutput("bottom"), colors.lime))
  84. sleep(0.1)
  85. rs.setBundledOutput("bottom", colors.combine(rs.getBundledOutput("bottom"), colors.magenta))
  86. sleep(0.1)
  87. rs.setBundledOutput("bottom", colors.subtract(rs.getBundledOutput("bottom"), colors.magenta))
  88. sleep(0.1)
  89. rs.setBundledOutput("bottom", colors.combine(rs.getBundledOutput("bottom"), colors.lightBlue))
  90. sleep(0.1)
  91. rs.setBundledOutput("bottom", colors.subtract(rs.getBundledOutput("bottom"), colors.lightBlue))
  92. sleep(0.1)
  93. rs.setBundledOutput("bottom", colors.combine(rs.getBundledOutput("bottom"), colors.yellow))
  94. sleep(0.1)
  95. rs.setBundledOutput("bottom", colors.subtract(rs.getBundledOutput("bottom"), colors.yellow))
  96. sleep(0.1)
  97. rs.setBundledOutput("bottom", colors.combine(rs.getBundledOutput("bottom"), colors.lime))
  98. sleep(0.1)
  99. rs.setBundledOutput("bottom", colors.subtract(rs.getBundledOutput("bottom"), colors.lime))
  100. sleep(0.1)
  101. rs.setBundledOutput("bottom", colors.combine(rs.getBundledOutput("bottom"), colors.pink))
  102. sleep(0.1)
  103. rs.setBundledOutput("bottom", colors.subtract(rs.getBundledOutput("bottom"), colors.pink))
  104. sleep(0.1)
  105. end
  106.  
  107. --sets slot machine display
  108. function display()
  109. mon.clear()
  110. mon.setCursorPos(3,2)
  111. mon.write(w1.." | "..w2.." | "..w3)
  112. sleep(3)
  113. end
  114.  
  115. --sets output for winnings
  116. function small()
  117. rs.setBundledOutput("bottom", colors.combine(rs.getBundledOutput("bottom"), colors.gray))
  118. sleep(0.5)
  119. rs.setBundledOutput("bottom", colors.subtract(rs.getBundledOutput("bottom"), colors.gray))
  120. sleep(1)
  121. end
  122.  
  123. function medium()
  124. rs.setBundledOutput("bottom", colors.combine(rs.getBundledOutput("bottom"), colors.lightGray))
  125. sleep(0.5)
  126. rs.setBundledOutput("bottom", colors.subtract(rs.getBundledOutput("bottom"), colors.lightGray))
  127. sleep(1)
  128. end
  129.  
  130. function jackpot()
  131. rs.setBundledOutput("bottom", colors.combine(rs.getBundledOutput("bottom"), colors.cyan))
  132. sleep(0.5)
  133. rs.setBundledOutput("bottom", colors.subtract(rs.getBundledOutput("bottom"), colors.cyan))
  134. sleep(1)
  135. end
  136.  
  137. --determines if winning or not
  138. function winnings()
  139. if w1 == w2 and w2 == w3 then
  140. mon.clear()
  141. mon.setCursorPos(3,2)
  142. mon.write("Winner!")
  143. medium()
  144. sleep(2)
  145. end
  146.  
  147. if w1 == w2 then
  148. mon.clear()
  149. mon.setCursorPos(3,2)
  150. mon.write("Winner!")
  151. small()
  152. sleep(2)
  153. end
  154.  
  155. if w1 and w2 and w3 == "7" then
  156. mon.clear()
  157. mon.setCursorPos(3,2)
  158. mon.write("JACKPOT!")
  159. jackpot()
  160. sleep(2)
  161. end
  162.  
  163. if w1 ~= w2 then
  164. mon.clear()
  165. mon.setCursorPos(3,2)
  166. mon.write("Sorry Try Again")
  167. sleep(2)
  168. end
  169. end
  170.  
  171. while true do
  172. wait()
  173.  
  174. --random number generator
  175. w1 = math.random(#sm)
  176. w2 = math.random(#sm)
  177. w3 = math.random(#sm)
  178.  
  179. --spin
  180. if rs.testBundledInput("bottom", colors.white) then
  181. mon.clear()
  182. mon.setCursorPos(2,2)
  183. mon.write("Payment Received.")
  184. sleep(1)
  185. mon.clear()
  186. mon.setCursorPos(3,2)
  187. mon.write("Spinning..")
  188. mon.setCursorPos(3,3)
  189. mon.write("Good Luck!")
  190. spin()
  191. display()
  192. winnings()
  193. os.reboot()
  194. end
  195. sleep(0.5)
  196. end
Advertisement
Add Comment
Please, Sign In to add comment