The3vilM0nk3y

Untitled

Sep 3rd, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.84 KB | None | 0 0
  1. --[[
  2. Slot machine
  3. "###########"
  4. "# STONERS #"
  5. "# SLOTS #"
  6. "###########"
  7. Goal: Create Slot machine with various rewards with rare chance to drop expensive items
  8.  
  9. Drops:
  10. Low:
  11. Mid:
  12. High:
  13.  
  14. _G["variable"]
  15. blood orb
  16. --]]
  17.  
  18.  
  19. minNum = 1
  20. maxNum = 16
  21.  
  22.  
  23. multipliers = {
  24. "redTorch",
  25. "eye",
  26. "pick",
  27. "sword"
  28. }
  29. --[[
  30. Valid names for reels:
  31. "cow","mooshroom","creeper","pig","enderman","pigman","slime","chicken",
  32. "zombie","spider","brick","sBrick","snow","ice","grass","mycelium","redTorch",
  33. "eye","pick","sword"
  34. ]]--
  35. mobReel = {
  36. {
  37. "cow",
  38. "mooshroom",
  39. "creeper",
  40. "pig",
  41. "enderman",
  42. "pigman",
  43. "slime",
  44. "chicken",
  45. "zombie",
  46. "spider",
  47. "sword"
  48. },
  49. {
  50. "creeper",
  51. "slime",
  52. "pig",
  53. "zombie",
  54. "pigman",
  55. "cow",
  56. "enderman",
  57. "sword",
  58. "chicken",
  59. "spider",
  60. "mooshroom"
  61. },
  62. {
  63. "slime",
  64. "chicken",
  65. "mooshroom",
  66. "spider",
  67. "sword",
  68. "pig",
  69. "pigman",
  70. "creeper",
  71. "enderman",
  72. "cow",
  73. "zombie"
  74. }
  75. }
  76. reel = mobReel
  77.  
  78. -- all images
  79. blank = {
  80. {f,f,f,f,f,f,f,f,f,f},
  81. {f,f,f,f,f,f,f,f,f,f},
  82. {f,f,f,f,f,f,f,f,f,f},
  83. {f,f,f,f,f,f,f,f,f,f},
  84. {f,f,f,f,f,f,f,f,f,f},
  85. {f,f,f,f,f,f,f,f,f,f}
  86. }
  87. cow = {
  88. {e,e,e,e,0,0,8,e,e,e},
  89. {f,f,e,e,0,8,e,e,f,f},
  90. {f,f,e,e,e,e,e,e,f,f},
  91. {e,e,e,0,0,0,0,e,e,e},
  92. {e,e,0,f,8,8,f,0,e,e},
  93. {e,e,0,8,8,8,8,0,e,e}
  94. }
  95. mooshroom = {
  96. {c,c,c,c,0,0,8,c,c,c},
  97. {0,0,c,c,0,8,c,c,0,0},
  98. {f,0,c,c,c,c,c,c,0,f},
  99. {c,c,c,0,0,0,0,c,c,c},
  100. {c,c,0,f,8,8,f,0,c,c},
  101. {c,c,0,8,8,8,8,0,c,c}
  102. }
  103. creeper = {
  104. {5,d,d,d,5,d,5,d,d,5},
  105. {d,f,f,f,d,d,f,f,f,d},
  106. {5,f,f,f,d,5,f,f,f,d},
  107. {d,d,5,d,f,f,d,d,5,d},
  108. {5,d,d,f,f,f,f,5,d,d},
  109. {d,5,d,f,5,d,f,d,d,5}
  110. }
  111. pig = {
  112. {6,6,6,6,6,6,6,6,6,6},
  113. {6,6,6,6,6,6,6,6,6,6},
  114. {6,f,1,6,6,6,6,1,f,6},
  115. {6,6,6,6,6,6,6,6,6,6},
  116. {6,6,6,2,6,6,2,6,6,6},
  117. {6,6,6,6,6,6,6,6,6,6},
  118. }
  119. enderman = {
  120. {f,7,f,f,f,f,f,f,7,f},
  121. {f,f,f,7,f,f,7,f,f,f},
  122. {f,7,f,f,7,7,f,f,7,f},
  123. {f,1,6,1,f,f,1,6,1,f},
  124. {7,f,f,7,f,f,7,f,f,7},
  125. {f,f,7,f,f,f,f,7,f,f}
  126. }
  127. pigman = {
  128. {1,1,1,5,d,6,6,6,6,6},
  129. {1,1,5,d,6,6,6,6,6,6},
  130. {f,7,5,d,6,6,6,6,1,f},
  131. {1,1,1,2,d,2,6,6,6,6},
  132. {1,5,5,1,5,d,6,6,6,6},
  133. {5,d,d,d,1,5,d,6,6,6}
  134. }
  135. slime = {
  136. {5,5,5,5,5,5,5,5,5,5},
  137. {5,f,f,f,d,f,f,f,5,5},
  138. {5,f,f,f,d,f,f,f,5,5},
  139. {5,d,d,d,d,d,d,d,5,5},
  140. {5,d,d,d,d,d,f,f,5,5},
  141. {5,5,5,5,5,5,5,5,5,5}
  142. }
  143. chicken = {
  144. {f,0,0,0,0,0,0,0,0,f},
  145. {f,0,f,f,0,0,f,f,0,f},
  146. {f,0,1,1,1,1,1,1,0,f},
  147. {f,f,c,c,c,c,c,c,f,f},
  148. {f,f,f,f,e,e,f,f,f,f},
  149. {f,f,f,f,e,e,f,f,f,f}
  150. }
  151. zombie = {
  152. {d,d,d,d,d,d,d,d,d,d},
  153. {d,d,d,d,d,d,d,d,d,d},
  154. {d,d,d,d,d,d,d,d,d,d},
  155. {d,f,f,f,d,d,f,f,f,d},
  156. {d,d,d,d,f,f,d,d,d,d},
  157. {d,d,d,d,d,d,d,d,d,d}
  158. }
  159. spider = {
  160. {7,7,7,f,f,f,f,7,7,7},
  161. {7,e,7,7,7,7,7,7,e,7},
  162. {7,7,7,e,7,7,e,7,7,7},
  163. {f,7,7,7,7,7,7,7,7,f},
  164. {f,f,7,7,f,f,7,7,f,f},
  165. {7,7,7,f,f,f,f,7,7,7}
  166. }
  167. bricks = {
  168. {e,e,0,e,e,e,e,e,e,e},
  169. {0,0,0,0,0,0,0,0,0,0},
  170. {e,e,e,e,e,e,0,e,e,e},
  171. {e,e,e,e,e,e,0,e,e,e},
  172. {0,0,0,0,0,0,0,0,0,0},
  173. {e,e,0,e,e,e,e,e,e,e}
  174. }
  175. stoneBricks = {
  176. {8,8,7,8,8,8,8,8,8,8},
  177. {7,7,7,7,7,7,7,7,7,7},
  178. {8,8,8,8,8,8,7,8,8,8},
  179. {8,8,8,8,8,8,7,8,8,8},
  180. {7,7,7,7,7,7,7,7,7,7},
  181. {8,8,7,8,8,8,8,8,8,8}
  182. }
  183. snow = {
  184. {0,0,0,0,0,0,0,0,0,0},
  185. {c,0,0,0,0,0,c,c,0,c},
  186. {c,c,c,0,c,c,c,c,c,c},
  187. {c,c,c,c,c,c,c,c,c,c},
  188. {c,c,c,c,c,c,c,c,c,c},
  189. {c,c,c,c,c,c,c,c,c,c}
  190. }
  191. ice = {
  192. {3,3,3,3,3,3,3,3,3,3},
  193. {3,3,0,3,3,3,0,3,3,3},
  194. {3,3,3,0,3,3,3,0,3,3},
  195. {3,0,3,3,3,3,3,3,3,3},
  196. {3,3,0,3,3,3,3,3,3,3},
  197. {3,3,3,3,3,3,3,3,3,3}
  198. }
  199. grass = {
  200. {d,d,d,d,d,d,d,d,d,d},
  201. {d,d,d,d,d,d,d,d,d,d},
  202. {d,d,d,d,d,d,d,d,d,d},
  203. {d,d,d,d,d,d,d,d,d,d},
  204. {d,d,d,d,d,d,d,d,d,d},
  205. {d,c,c,c,c,d,d,d,c,c}
  206. }
  207. mycelium = {
  208. {a,a,a,a,a,a,a,a,a,a},
  209. {a,a,a,a,a,a,a,a,a,a},
  210. {a,a,a,a,a,a,a,a,a,a},
  211. {a,a,a,a,a,a,a,a,a,a},
  212. {a,a,a,a,a,a,a,a,a,a},
  213. {a,c,c,c,c,a,a,a,c,c}
  214. }
  215. -- Multiplier Images
  216. redstoneTorch = {
  217. {f,f,f,e,e,e,e,f,f,f},
  218. {f,f,e,e,e,e,e,e,f,f},
  219. {f,f,e,e,1,1,e,e,f,f},
  220. {f,f,f,e,c,c,e,f,f,f},
  221. {f,f,f,f,c,c,f,f,f,f},
  222. {f,f,f,f,c,c,f,f,f,f}
  223. }
  224. eyeOfEnder = {
  225. {f,f,b,9,d,d,9,b,f,f},
  226. {f,b,9,d,5,5,d,9,b,f},
  227. {b,9,d,5,f,f,5,d,9,b},
  228. {b,9,d,5,f,f,5,d,9,b},
  229. {f,b,9,d,5,5,d,9,b,f},
  230. {f,f,b,9,d,d,9,b,f,f}
  231. }
  232. pick = {
  233. {f,f,f,9,9,9,f,f,f,f},
  234. {f,f,9,f,c,f,9,f,f,f},
  235. {f,9,f,f,c,f,f,9,f,f},
  236. {f,f,f,f,c,f,f,f,f,f},
  237. {f,f,f,f,c,f,f,f,f,f},
  238. {f,f,f,f,c,f,f,f,f,f}
  239. }
  240. sword = {
  241. {f,f,f,f,9,f,f,f,f,f},
  242. {f,f,f,f,9,f,f,f,f,f},
  243. {f,f,f,f,9,f,f,f,f,f},
  244. {f,f,f,f,9,f,f,f,f,f},
  245. {f,f,f,8,8,8,f,f,f,f},
  246. {f,f,f,f,c,f,f,f,f,f}
  247. }
  248.  
  249.  
  250. logo = {
  251. {0,0,e,e,e,0,e,e,e,0,e,e,e,0,e,e,e,0,e,e,e,0,e,e,e,0,e,e,e},
  252. {0,0,e,0,0,0,0,e,0,0,e,0,e,0,e,0,e,0,e,0,0,0,e,0,e,0,e,0,0},
  253. {0,0,e,e,e,0,0,e,0,0,e,0,e,0,e,0,e,0,e,e,0,0,e,e,e,0,e,e,e},
  254. {0,0,0,0,e,0,0,e,0,0,e,0,e,0,e,0,e,0,e,0,0,0,e,e,0,0,0,0,e},
  255. {0,0,e,e,e,0,0,e,0,0,e,e,e,0,e,0,e,0,e,e,e,0,e,0,e,0,e,e,e},
  256. {},
  257. {0,0,0,0,0,0,e,e,e,0,e,0,0,0,e,e,e,0,e,e,e,0,e,e,e},
  258. {0,0,0,0,0,0,e,0,0,0,e,0,0,0,e,0,e,0,0,e,0,0,e,0,0},
  259. {0,0,0,0,0,0,e,e,e,0,e,0,0,0,e,0,e,0,0,e,0,0,e,e,e},
  260. {0,0,0,0,0,0,0,0,e,0,e,0,0,0,e,0,e,0,0,e,0,0,0,0,e},
  261. {0,0,0,0,0,0,e,e,e,0,e,e,e,0,e,e,e,0,0,e,0,0,e,e,e}
  262. }
  263.  
  264. reelSize = #reel
  265.  
  266.  
  267. function loadImage(s)
  268. paintutils.loadImage(_G[s])
  269. end
  270. function toName(num,rnum)
  271. return reel[rnum][num]
  272. end
  273. function isMultiplier(num,rnum)
  274. name = toName(num,rnum)
  275. for i=1,#multipliers do
  276. if name == multipliers[i] then
  277. return true
  278. end
  279. end
  280. end
  281. function drawGame()
  282. term.redirect(m)
  283. term.setBackgroundColor(colors.black)
  284. term.clear()
  285. term.setCursorPos(1,1)
  286.  
  287. -- draw each reel
  288. for i=1,3 do
  289. -- draw images to reels
  290. for j=1,3 do -- <----------------------------------------------------
  291. paintutils.drawImage()
  292. end
  293. end
  294. end
  295. w,h = term.getSize()
  296. m = peripheral.find("monitor")
  297. while true do
  298. e,p1,p2,p3 = os.pullEvent()
  299. if e == "redstone" then
  300. if not running then
  301. for i=1,20
  302. print("Starting Randomizer")
  303. num1 = math.random(1,#reel)
  304. num2 = math.random(1,#reel)
  305. num2 = math.random(1,#reel)
  306. --
  307. if toName(num1,1) == toName(num2,2) and toName(num2,2) == toName(num3,3) then
  308. -- three in a row
  309. if isMultiplier(num1,1) and isMultiplier(num2,2) and isMultiplier(num3,3)
  310. -- JACKPOT!!!!
  311. end
  312. elseif toName(num1,1) == toName(num2,2) or toName(num2,2) == toName(num3,3) or toName(num1,1) == toName(num3,3) then
  313. -- We have a pair
  314. if isMultiplier(num1) or isMultiplier(num2) or isMultiplier(num3) then
  315. -- the pair contains a multiplier
  316. if (isMultiplier(num1,1) and isMultiplier(num2,2)) or ( isMultiplier(num2,2) and isMultiplier(num3,3) ) then
  317. -- the pair is a pair of multipliers
  318. end
  319. end
  320. end
  321. end
  322. end
  323. end
Advertisement
Add Comment
Please, Sign In to add comment