Advertisement
Alyssa

Slots

May 3rd, 2013
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.72 KB | None | 0 0
  1. sFile = "casino"
  2. fileread = assert(fs.open(sFile, "r"))
  3. casinomoney = fileread.readLine()
  4. fileread.close()
  5. money = 25
  6. select = 1
  7. function animationspin(num)
  8. num = num +24
  9. timesspun = math.random(2, 4)
  10. for i = 1, timesspun do
  11. term.setCursorPos(num, 2)
  12. if term.isColor then
  13. term.setTextColor(colors.blue)
  14. end
  15. write("7")
  16. os.sleep(0.2)
  17. term.setCursorPos(num, 2)
  18. if term.isColor then
  19. term.setTextColor(colors.red)
  20. end
  21. write("C")
  22. os.sleep(0.2)
  23. term.setCursorPos(num, 2)
  24. if term.isColor then
  25. term.setTextColor(colors.green)
  26. end
  27. write("L")
  28. os.sleep(0.2)
  29. term.setCursorPos(num, 2)
  30. if term.isColor then
  31. term.setTextColor(colors.yellow)
  32. end
  33. write("L")
  34. os.sleep(0.2)
  35. term.setCursorPos(num, 2)
  36. if term.isColor then
  37. term.setTextColor(colors.purple)
  38. end
  39. write("G")
  40. term.setTextColor(colors.white)
  41. end
  42. end
  43.  
  44.  
  45.  
  46. function spingraphics()
  47. animationspin(1)
  48. if spinned == 1 then
  49. term.setCursorPos(25, 2)
  50. if term.isColor then
  51. term.setTextColor(colors.green)
  52. end
  53. write("L")
  54. end
  55. if spinned == 2 then
  56. term.setCursorPos(25, 2)
  57. if term.isColor then
  58. term.setTextColor(colors.red)
  59. end
  60. write("C")
  61. end
  62. if spinned == 3 then
  63. term.setCursorPos(25, 2)
  64. if term.isColor then
  65. term.setTextColor(colors.yellow)
  66. end
  67. write("L")
  68. end
  69. if spinned == 4 then
  70. term.setCursorPos(25, 2)
  71. if term.isColor then
  72. term.setTextColor(colors.blue)
  73. end
  74. write("7")
  75. end
  76. if spinned == 5 then
  77. term.setCursorPos(25, 2)
  78. if term.isColor then
  79. term.setTextColor(colors.purple)
  80. end
  81. write("G")
  82. end
  83. animationspin(2)
  84. if spinned2 == 1 then
  85. term.setCursorPos(26, 2)
  86. if term.isColor then
  87. term.setTextColor(colors.green)
  88. end
  89. write("L")
  90. end
  91. if spinned2 == 2 then
  92. term.setCursorPos(26, 2)
  93. if term.isColor then
  94. term.setTextColor(colors.red)
  95. end
  96. write("C")
  97. end
  98. if spinned2 == 3 then
  99. term.setCursorPos(26, 2)
  100. if term.isColor then
  101. term.setTextColor(colors.yellow)
  102. end
  103. write("L")
  104. end
  105. if spinned2 == 4 then
  106. term.setCursorPos(26, 2)
  107. if term.isColor then
  108. term.setTextColor(colors.blue)
  109. end
  110. write("7")
  111. end
  112. if spinned2 == 5 then
  113. term.setCursorPos(26, 2)
  114. if term.isColor then
  115. term.setTextColor(colors.purple)
  116. end
  117. write("G")
  118. end
  119. animationspin(3)
  120. if spinned3 == 1 then
  121. term.setCursorPos(27, 2)
  122. if term.isColor then
  123. term.setTextColor(colors.green)
  124. end
  125. write("L")
  126. end
  127. if spinned3 == 2 then
  128. term.setCursorPos(27, 2)
  129. if term.isColor then
  130. term.setTextColor(colors.red)
  131. end
  132. write("C")
  133. end
  134. if spinned3 == 3 then
  135. term.setCursorPos(27, 2)
  136. if term.isColor then
  137. term.setTextColor(colors.yellow)
  138. end
  139. write("L")
  140. end
  141. if spinned3 == 4 then
  142. term.setCursorPos(27, 2)
  143. if term.isColor then
  144. term.setTextColor(colors.blue)
  145. end
  146. write("7")
  147. end
  148. if spinned3 == 5 then
  149. term.setCursorPos(27, 2)
  150. if term.isColor then
  151. term.setTextColor(colors.purple)
  152. end
  153. write("G")
  154. end
  155. term.setTextColor(colors.white)
  156. term.setCursorPos(1, 4)
  157. end
  158.        
  159. function rawspin(slot)
  160. spinr = math.random(1, 20)
  161. if spinr == 7 then
  162. if slot == 1 then
  163. spinned = 4
  164. end
  165. if slot == 2 then
  166. spinned2 = 4
  167. end
  168. if slot == 3 then
  169. spinned3 = 4
  170. end
  171. end
  172. if spinr == 1 or spinr == 2 or spinr == 3 or spinr == 4 or spinr == 5 then
  173. if slot == 1 then
  174. spinned = 1
  175. end
  176. if slot == 2 then
  177. spinned2 = 1
  178. end
  179. if slot == 3 then
  180. spinned3 = 1
  181. end
  182. end
  183. if spinr == 6 or spinr == 8 or spinr == 9 or spinr == 10 or spinr == 11 or spinr == 12 then
  184. if slot == 1 then
  185. spinned = 2
  186. end
  187. if slot == 2 then
  188. spinned2 = 2
  189. end
  190. if slot == 3 then
  191. spinned3 = 2
  192. end
  193. end
  194. if spinr == 13 or spinr == 14 or spinr == 15 or spinr == 16 or spinr == 17 then
  195. if slot == 1 then
  196. spinned = 3
  197. end
  198. if slot == 2 then
  199. spinned2 = 3
  200. end
  201. if slot == 3 then
  202. spinned3 = 3
  203. end
  204. end
  205. if spinr == 18 or spinr == 19 or spinr == 20 then
  206. if slot == 1 then
  207. spinned = 5
  208. end
  209. if slot == 2 then
  210. spinned2 = 5
  211. end
  212. if slot == 3 then
  213. spinned3 = 5
  214. end
  215. end
  216. end
  217.                          
  218. function match()
  219. matched = 0
  220. if spinned == 1 and spinned2 == 1 and spinned3 == 1 then
  221. matched = 1
  222. end
  223. if spinned == 2 and spinned2 == 2 and spinned3 == 2 then
  224. matched = 2
  225. end
  226. if spinned == 3 and spinned2 == 3 and spinned3 == 3 then
  227. matched = 3
  228. end
  229. if spinned == 4 and spinned2 == 4 and spinned3 == 4 then
  230. matched = 4
  231. end
  232. if spinned == 5 and spinned2 == 5 and spinned3 == 5 then
  233. matched = 5
  234. end
  235. if spinned == 2 and spinned2 == 2 or spinned == 2 and spinned3 == 2 or spinned2 == 2 and spinned3 == 2 then
  236. matched = 2
  237. end
  238. end
  239.      
  240. function prize()
  241. if casinomoney == 0 then
  242. print("The casino is bankrupt!")
  243. spinagain = 0
  244. else
  245. crprize = 0
  246. if matched == 1 or matched == 2 or matched == 3 or matched == 4 or matched == 5 then
  247. if matched == 2 then
  248. crprize = 10
  249. money = money +10
  250. casinomoney = casinomoney -10
  251. elseif matched == 1 then
  252. crprize = 25
  253. money = money +25
  254. casinomoney = casinomoney -25
  255. elseif matched == 3 then
  256. crprize = 30
  257. money = money +30
  258. casinomoney = casinomoney -30
  259. elseif matched == 4 then
  260. crprize = 500
  261. money = money +500
  262. casinomoney = casinomoney -500
  263. elseif matched == 5 then
  264. crprize = 75
  265. money = money +75
  266. casinomoney = casinomoney -75
  267. end
  268. end
  269. end
  270. end
  271.    
  272. spinagain = 1
  273. while spinagain == 1 do
  274. num = 0
  275. print("Type: yes if you want to spin again!")
  276. again = read()
  277. if again == "Yes" or again == "y" or again == "yes" or again == "YES" or again == "yeah" or again == "yesh" or again == "YEAH" or again == "Yeah" or again == "YESH" or again == "Yesh" then
  278. spinagain = 1
  279. else
  280. spinagain = 0
  281. end
  282. term.clear()
  283. if money == 0 then
  284. print("You are bankrupt!")
  285. spinagain = 0
  286. end
  287. if spinagain == 1 then
  288. money = money -5
  289. casinomoney = casinomoney +5
  290. end
  291. if spinagain == 1 then
  292. rawspin(1)
  293. rawspin(2)
  294. rawspin(3)
  295. match()
  296. prize()
  297. spingraphics()
  298. print("You won: ")
  299. print(crprize)
  300. print("Money: ")
  301. print(money)
  302. end
  303. end
  304.      
  305. print("Goodbye!")
  306. fwrite = fs.open(sFile, "w")
  307. fwrite.write(casinomoney)
  308. fwrite.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement