Advertisement
craniumkid22

Games

Sep 8th, 2012
1,593
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 21.92 KB | None | 0 0
  1. --Tables
  2. local symbol = {"A","2","3","4","5","6","7","8","9","10","J","Q","K"}
  3. local gMenu = {
  4. "Lucky Dice",
  5. "Magic 8 Block",
  6. "Card Slots",
  7. "Main Menu"
  8. }
  9. local answers = {
  10. "It is Certain ",
  11. " Decidedly So ",
  12. "      No      ",
  13. "      Yes     ",
  14. "   No doubt   ",
  15. "     Never    ",
  16. "    Unknown   ",
  17. "  Ask again   ",
  18. "   Doubtful   ",
  19. " Most Likely  ",
  20. "Cannot predict",
  21. " Probably not ",
  22. " Stars say no ",
  23. "   For sure   "
  24. }
  25.  
  26.  
  27. --[[Pretty screen printing functions]]--
  28.  
  29. local function blank()
  30. term.setCursorPos(7,3)
  31. print("+--------------+  +--------------+")
  32. term.setCursorPos(7,4)
  33. print("|              |  |              |")
  34. term.setCursorPos(7,5)
  35. print("|              |  |              |")
  36. term.setCursorPos(7,6)
  37. print("| Press ENTER  |  |   to  Roll   |")
  38. term.setCursorPos(7,7)
  39. print("|              |  |              |")
  40. term.setCursorPos(7,8)
  41. print("|  BACKSPACE   |  |   to  Exit   |")
  42. term.setCursorPos(7,9)
  43. print("|              |  |              |")
  44. term.setCursorPos(7,10)
  45. print("|              |  |              |")
  46. term.setCursorPos(7,11)
  47. print("+--------------+  +--------------+")
  48. end
  49. local function gPage()
  50. term.clear()
  51. term.setCursorPos(1,1)
  52. print("    _______  _______  _______  _______  _______ ")
  53. print("   (  ____ \\(  ___  )(       )(  ____ \\(  ____ \\")
  54. print("   | (    \\/| (   ) || () () || (    \\/| (    \\/")
  55. print("   | |      | (___) || || || || (__    | (_____ ")
  56. print("   | | ____ |  ___  || |(_)| ||  __)   (_____  )")
  57. print("   | | \\_  )| (   ) || |   | || (            ) |")
  58. print("   | (___) || )   ( || )   ( || (____/\\/\\____) |")
  59. print("   (_______)|/     \\||/     \\|(_______/\\_______)")
  60. end
  61. local function sTitle()
  62. term.setCursorPos(1,15)
  63. print("   __    __   ___  ___    __  _    ___ _____ __ ")
  64. print("  / /'  / /\\ | |_)| | \\  ( ('| |  / / \\ | | ( ('")
  65. print("  \\_\\_,/_/--\\|_| \\|_|_/  _)_)|_|__\\_\\_/ |_| _)_)")
  66. end
  67. local function loser()
  68. term.clear()
  69. term.setCursorPos(1,5)
  70. print("          __      ___    __   ____ ____ ")
  71. print("          ||     // \\\\  (( \\ ||    || \\\\")
  72. print("          ||    ((   ))  \\\\  ||==  ||_//")
  73. print("          ||__|  \\\\_//  \\_)) ||___ || \\\\")
  74. sleep(3)
  75. term.clear()
  76. end
  77. local function jackpot()
  78. for x = 1,5 do
  79. term.clear()
  80. sleep(.25)
  81. term.setCursorPos(1,5)
  82. print("     __  ___    ___ __ __ ____    ___   ______")
  83. print("     || // \\\\  //   || // || \\\\  // \\\\  | || |")
  84. print("     || ||=|| ((    ||<<  ||_// ((   ))   ||  ")
  85. print("  |__|| || ||  \\\\__ || \\\\ ||     \\\\_//    ||  ")
  86. sleep(.25)
  87. end
  88. end
  89. local function soon()
  90. for i = 1,5 do
  91. term.clear()
  92. term.setCursorPos(1,1)
  93. sleep(.25)
  94. print("                )         (       )         ")
  95. print("          (  ( /(  (      )\\ ) ( /( (       ")
  96. print("          )\\ )\\()) )\\))( (()/( )\\()))\\ )    ")
  97. print("        (((_|(_)\\ ((_)()\\ /(_)|(_)\\(()/(    ")
  98. print("        )\\___ ((_)(_()((_|_))  _((_)/(_))_  ")
  99. print("       ((/ __/ _ \\|  \\/  |_ _|| \\| (_)) __| ")
  100. print("        | (_| (_) | |\\/| || | | .' | | (_ | ")
  101. print("        (\\___\\__)/|_|  |_|__)||_|\\_|  \\___| ")
  102. print("                                            ")
  103. print("               )\\ ) ( /(  ( /(  ( /(        ")
  104. print("              (()/( )\\()) )\\()) )\\())       ")
  105. print("               /(_)|(_)\\ ((_)\\ ((_)\\        ")
  106. print("              (_))   ((_)  ((_) _((_)       ")
  107. print("              / __| / _ \\ / _ \\| \\| |       ")
  108. print("              \\__ \\| (_) | (_) | .' |       ")
  109. print("              |___/ \\___/ \\___/|_|\\_|       ")
  110. sleep(.5)
  111. end
  112. end
  113.     -- dice functions
  114. local function dTitle()
  115. term.setCursorPos(1,14)
  116. print("      __            __          ___  _        ")
  117. print("     / /  __ ______/ /____ __  / _ \\(_)______ ")
  118. print("    / /__/ // / __/  '_/ // / / // / / __/ -_)")
  119. print("   /____/\\_,_/\\__/_/\\_\\\\_, / /____/_/\\__/\\__/ ")
  120. print("                      /___/                   ")
  121. end
  122. local function die1()
  123. local x = math.random(1,6)
  124. if x == 1 then
  125. term.setCursorPos(7,3)
  126. print("+--------------+")
  127. term.setCursorPos(7,4)
  128. print("|              |")
  129. term.setCursorPos(7,5)
  130. print("|              |")
  131. term.setCursorPos(7,6)
  132. print("|              |")
  133. term.setCursorPos(7,7)
  134. print("|      O       |")
  135. term.setCursorPos(7,8)
  136. print("|              |")
  137. term.setCursorPos(7,9)
  138. print("|              |")
  139. term.setCursorPos(7,10)
  140. print("|              |")
  141. term.setCursorPos(7,11)
  142. print("+--------------+")
  143. elseif x == 2 then
  144. term.setCursorPos(7,3)
  145. print("+--------------+")
  146. term.setCursorPos(7,4)
  147. print("|              |")
  148. term.setCursorPos(7,5)
  149. print("|          O   |")
  150. term.setCursorPos(7,6)
  151. print("|              |")
  152. term.setCursorPos(7,7)
  153. print("|              |")
  154. term.setCursorPos(7,8)
  155. print("|              |")
  156. term.setCursorPos(7,9)
  157. print("|  O           |")
  158. term.setCursorPos(7,10)
  159. print("|              |")
  160. term.setCursorPos(7,11)
  161. print("+--------------+")
  162. elseif x == 3 then
  163. term.setCursorPos(7,3)
  164. print("+--------------+")
  165. term.setCursorPos(7,4)
  166. print("|              |")
  167. term.setCursorPos(7,5)
  168. print("|          O   |")
  169. term.setCursorPos(7,6)
  170. print("|              |")
  171. term.setCursorPos(7,7)
  172. print("|      O       |")
  173. term.setCursorPos(7,8)
  174. print("|              |")
  175. term.setCursorPos(7,9)
  176. print("|  O           |")
  177. term.setCursorPos(7,10)
  178. print("|              |")
  179. term.setCursorPos(7,11)
  180. print("+--------------+")
  181. elseif x == 4 then
  182. term.setCursorPos(7,3)
  183. print("+--------------+")
  184. term.setCursorPos(7,4)
  185. print("|              |")
  186. term.setCursorPos(7,5)
  187. print("|  O       O   |")
  188. term.setCursorPos(7,6)
  189. print("|              |")
  190. term.setCursorPos(7,7)
  191. print("|              |")
  192. term.setCursorPos(7,8)
  193. print("|              |")
  194. term.setCursorPos(7,9)
  195. print("|  O       O   |")
  196. term.setCursorPos(7,10)
  197. print("|              |")
  198. term.setCursorPos(7,11)
  199. print("+--------------+")
  200. elseif x == 5 then
  201. term.setCursorPos(7,3)
  202. print("+--------------+")
  203. term.setCursorPos(7,4)
  204. print("|              |")
  205. term.setCursorPos(7,5)
  206. print("|  O       O   |")
  207. term.setCursorPos(7,6)
  208. print("|              |")
  209. term.setCursorPos(7,7)
  210. print("|      O       |")
  211. term.setCursorPos(7,8)
  212. print("|              |")
  213. term.setCursorPos(7,9)
  214. print("|  O       O   |")
  215. term.setCursorPos(7,10)
  216. print("|              |")
  217. term.setCursorPos(7,11)
  218. print("+--------------+")
  219. elseif x == 6 then
  220. term.setCursorPos(7,3)
  221. print("+--------------+")
  222. term.setCursorPos(7,4)
  223. print("|              |")
  224. term.setCursorPos(7,5)
  225. print("|  O       O   |")
  226. term.setCursorPos(7,6)
  227. print("|              |")
  228. term.setCursorPos(7,7)
  229. print("|  O       O   |")
  230. term.setCursorPos(7,8)
  231. print("|              |")
  232. term.setCursorPos(7,9)
  233. print("|  O       O   |")
  234. term.setCursorPos(7,10)
  235. print("|              |")
  236. term.setCursorPos(7,11)
  237. print("+--------------+")
  238. end
  239. end
  240. local function die2()
  241. local x = math.random(1,6)
  242. if x == 1 then
  243. term.setCursorPos(25,3)
  244. print("+--------------+")
  245. term.setCursorPos(25,4)
  246. print("|              |")
  247. term.setCursorPos(25,5)
  248. print("|              |")
  249. term.setCursorPos(25,6)
  250. print("|              |")
  251. term.setCursorPos(25,7)
  252. print("|      O       |")
  253. term.setCursorPos(25,8)
  254. print("|              |")
  255. term.setCursorPos(25,9)
  256. print("|              |")
  257. term.setCursorPos(25,10)
  258. print("|              |")
  259. term.setCursorPos(25,11)
  260. print("+--------------+")
  261. elseif x == 2 then
  262. term.setCursorPos(25,3)
  263. print("+--------------+")
  264. term.setCursorPos(25,4)
  265. print("|              |")
  266. term.setCursorPos(25,5)
  267. print("|          O   |")
  268. term.setCursorPos(25,6)
  269. print("|              |")
  270. term.setCursorPos(25,7)
  271. print("|              |")
  272. term.setCursorPos(25,8)
  273. print("|              |")
  274. term.setCursorPos(25,9)
  275. print("|  O           |")
  276. term.setCursorPos(25,10)
  277. print("|              |")
  278. term.setCursorPos(25,11)
  279. print("+--------------+")
  280. elseif x == 3 then
  281. term.setCursorPos(25,3)
  282. print("+--------------+")
  283. term.setCursorPos(25,4)
  284. print("|              |")
  285. term.setCursorPos(25,5)
  286. print("|          O   |")
  287. term.setCursorPos(25,6)
  288. print("|              |")
  289. term.setCursorPos(25,7)
  290. print("|      O       |")
  291. term.setCursorPos(25,8)
  292. print("|              |")
  293. term.setCursorPos(25,9)
  294. print("|  O           |")
  295. term.setCursorPos(25,10)
  296. print("|              |")
  297. term.setCursorPos(25,11)
  298. print("+--------------+")
  299. elseif x == 4 then
  300. term.setCursorPos(25,3)
  301. print("+--------------+")
  302. term.setCursorPos(25,4)
  303. print("|              |")
  304. term.setCursorPos(25,5)
  305. print("|  O       O   |")
  306. term.setCursorPos(25,6)
  307. print("|              |")
  308. term.setCursorPos(25,7)
  309. print("|              |")
  310. term.setCursorPos(25,8)
  311. print("|              |")
  312. term.setCursorPos(25,9)
  313. print("|  O       O   |")
  314. term.setCursorPos(25,10)
  315. print("|              |")
  316. term.setCursorPos(25,11)
  317. print("+--------------+")
  318. elseif x == 5 then
  319. term.setCursorPos(25,3)
  320. print("+--------------+")
  321. term.setCursorPos(25,4)
  322. print("|              |")
  323. term.setCursorPos(25,5)
  324. print("|  O       O   |")
  325. term.setCursorPos(25,6)
  326. print("|              |")
  327. term.setCursorPos(25,7)
  328. print("|      O       |")
  329. term.setCursorPos(25,8)
  330. print("|              |")
  331. term.setCursorPos(25,9)
  332. print("|  O       O   |")
  333. term.setCursorPos(25,10)
  334. print("|              |")
  335. term.setCursorPos(25,11)
  336. print("+--------------+")
  337. elseif x == 6 then
  338. term.setCursorPos(25,3)
  339. print("+--------------+")
  340. term.setCursorPos(25,4)
  341. print("|              |")
  342. term.setCursorPos(25,5)
  343. print("|  O       O   |")
  344. term.setCursorPos(25,6)
  345. print("|              |")
  346. term.setCursorPos(25,7)
  347. print("|  O       O   |")
  348. term.setCursorPos(25,8)
  349. print("|              |")
  350. term.setCursorPos(25,9)
  351. print("|  O       O   |")
  352. term.setCursorPos(25,10)
  353. print("|              |")
  354. term.setCursorPos(25,11)
  355. print("+--------------+")
  356. end
  357. end
  358. local function roll()
  359. local r = 1
  360. for r = 1,50 do
  361. parallel.waitForAll(die1,die2,sleep(.1))
  362. end
  363. end
  364. local function dice()
  365. while true do
  366. term.clear()
  367. dTitle()
  368. blank()
  369. event, p1 = os.pullEvent("key")
  370.     if p1 == 28 then
  371.     roll()
  372.     sleep(3)
  373.     elseif p1 == 14 then break
  374.     end
  375. end
  376. end
  377.     -- 8block functions
  378. local function bTitle()
  379. term.clear()
  380. term.setCursorPos(1,1)
  381. print("  _ _ _                  __      __    _          ")
  382. print(" ' ) ) )                (  )    /  )  //       /  ")
  383. print("  / / / __.  _,  o _.   ./'    /--<  // __ _. /_  ")
  384. print(" / ' (_(_/|_(_)_<_(__  (__)   /___/_</_(_)(__/ <_ ")
  385. print("             /|                                   ")
  386. print("            |/                                    ")
  387. end
  388. local function ans()
  389. term.clear()
  390. bTitle()
  391. term.setCursorPos(1,7)
  392. print("                .----------------. ")
  393. print("               | .--------------. |")
  394. print("               | |              | |")
  395. print("               | |              | |")
  396. print("               | |              | |")
  397. print("               | |"..answers[math.random(1,#answers)].."| |")
  398. print("               | |              | |")
  399. print("               | |              | |")
  400. print("               | |              | |")
  401. print("               | '--------------' |")
  402. print("                '----------------' ")
  403. end
  404. local function start()
  405. bTitle()
  406. term.setCursorPos(1,7)
  407. print("                .----------------.                ")
  408. print("Ask me ANY     | .--------------. |               ")
  409. print("question, and  | |     ____     | |   BACKSPACE   ")
  410. print("press ENTER    | |   .' __ '.   | |               ")
  411. print("to receive     | |   | (__) |   | |               ")
  412. print("your answer... | |   .'____'.   | |    to exit    ")
  413. print("               | |  | (____) |  | |               ")
  414. print("               | |  '.______.'  | |               ")
  415. print("               | |              | |               ")
  416. print("               | '--------------' |               ")
  417. print("                '----------------'                ")
  418. end
  419. local function shake()
  420. term.clear()
  421. bTitle()
  422. term.setCursorPos(1,7)
  423. print("                 .----------------.               ")
  424. print("                | .--------------. |          *   ")
  425. print("            *   | |              | |              ")
  426. print("                | |              | |              ")
  427. print("   *            | |              | |  *           ")
  428. print("                | |              | |              ")
  429. print("                | |              | |              ")
  430. print("        *       | |              | |       *      ")
  431. print("                | |              | |              ")
  432. print("   *            | '--------------' |              ")
  433. print("                 '----------------'               ")
  434. sleep(.2)
  435. term.clear()
  436. bTitle()
  437. term.setCursorPos(1,7)
  438. print("  *            .----------------.                 ")
  439. print("              | .--------------. |                ")
  440. print("              | |              | |    *      *    ")
  441. print("       *      | |              | |                ")
  442. print("              | |              | |                ")
  443. print("              | |              | |                ")
  444. print("              | |              | |    *           ")
  445. print("              | |              | |                ")
  446. print("     *        | |              | |      *         ")
  447. print("              | '--------------' |                ")
  448. print("               '----------------'                 ")
  449. sleep(.2)
  450. term.clear()
  451. bTitle()
  452. term.setCursorPos(1,7)
  453. print("                .----------------.                ")
  454. print("     *         | .--------------. | *             ")
  455. print("               | |              | |               ")
  456. print("               | |              | |               ")
  457. print("      *        | |              | |               ")
  458. print("               | |              | |       *       ")
  459. print("               | |              | |               ")
  460. print("   *           | |              | |               ")
  461. print("               | |              | |            *  ")
  462. print("             * | '--------------' |     *         ")
  463. print("                '----------------'                ")
  464. sleep(.2)
  465. term.clear()
  466. bTitle()
  467. term.setCursorPos(1,7)
  468. print("                 .----------------.               ")
  469. print("          *     | .--------------. |          *   ")
  470. print("                | |              | |              ")
  471. print("                | |              | |     *        ")
  472. print("                | |              | |              ")
  473. print("     *          | |              | |              ")
  474. print("                | |              | |              ")
  475. print("                | |              | |              ")
  476. print("   *         *  | |              | |           *  ")
  477. print("                | '--------------' |              ")
  478. print("                 '----------------'   *           ")
  479. sleep(.2)
  480. term.clear()
  481. bTitle()
  482. term.setCursorPos(1,7)
  483. print("               .----------------.                 ")
  484. print("        *     | .--------------. |   *            ")
  485. print("              | |              | |                ")
  486. print("    *         | |              | |          *     ")
  487. print("              | |              | |                ")
  488. print("              | |              | |    *           ")
  489. print("              | |              | |                ")
  490. print("   *       *  | |              | |                ")
  491. print("              | |              | |             *  ")
  492. print("              | '--------------' |                ")
  493. print("       *       '----------------'  *              ")
  494. sleep(.2)
  495. term.clear()
  496. bTitle()
  497. term.setCursorPos(1,7)
  498. print("                .----------------. ")
  499. print("               | .--------------. |")
  500. print("               | |              | |")
  501. print("               | |              | |")
  502. print("               | |              | |")
  503. print("               | |              | |")
  504. print("               | |              | |")
  505. print("               | |              | |")
  506. print("               | |              | |")
  507. print("               | '--------------' |")
  508. print("                '----------------' ")
  509. sleep(1.5)
  510. ans()
  511. end
  512. local function block()
  513. start()
  514. while true do
  515. local event, p1 = os.pullEvent("key")
  516.     if p1 == 28 then
  517.     shake()
  518.     sleep(2)
  519.     start()
  520.     elseif p1 == 14 then break
  521.     end
  522. end
  523. end
  524.     -- slots functions
  525. local function cardtop(x,y)
  526. term.setCursorPos(x,y)
  527. write([[ .------------. ]])
  528. term.setCursorPos(x,y+1)
  529. write([[| .----------. |]])
  530. term.setCursorPos(x,y+2)
  531. write([[| |          | |]])
  532. term.setCursorPos(x,y+3)
  533. write([[| | .------. | |]])
  534. term.setCursorPos(x,y+4)
  535. end
  536. local function cardbase(x,y)
  537. term.setCursorPos(x,y+8)
  538. write([[| | '------' | |]])
  539. term.setCursorPos(x,y+9)
  540. write([[| |          | |]])
  541. term.setCursorPos(x,y+10)
  542. write([[| '----------' |]])
  543. term.setCursorPos(x,y+11)
  544. write([[ '------------' ]])
  545. end
  546. local function numtop(n,x,y)
  547. if symbol[n] == "10" then
  548. term.setCursorPos(x,y+4)
  549. write([[| | |]]..symbol[n]..[[--. | | |]])
  550. else
  551. term.setCursorPos(x,y+4)
  552. write([[| | |]]..symbol[n]..[[.--. | | |]])
  553. end
  554. end
  555. local function numbase(n,x,y)
  556. if symbol[n] == "10" then
  557. term.setCursorPos(x,y+7)
  558. write([[| | | '--]]..symbol[n]..[[| | |]])
  559. else
  560. term.setCursorPos(x,y+7)
  561. write([[| | | '--']]..symbol[n]..[[| | |]])
  562. end
  563. end
  564. local function spade(x,y)
  565. term.setCursorPos(x,y+5)
  566. write([[| | | :/\: | | |]])
  567. term.setCursorPos(x,y+6)
  568. write([[| | | (__) | | |]])
  569. end
  570. local function heart(x,y)
  571. term.setCursorPos(x,y+5)
  572. write([[| | | (\/) | | |]])
  573. term.setCursorPos(x,y+6)
  574. write([[| | | :\/: | | |]])
  575. end
  576. local function club(x,y)
  577. term.setCursorPos(x,y+5)
  578. write([[| | | :(): | | |]])
  579. term.setCursorPos(x,y+6)
  580. write([[| | | ()() | | |]])
  581. end
  582. local function diamond(x,y)
  583. term.setCursorPos(x,y+5)
  584. write([[| | | :/\: | | |]])
  585. term.setCursorPos(x,y+6)
  586. write([[| | | :\/: | | |]])
  587. end
  588. local function slot(pos)
  589. local c = math.random(1,4)
  590. local n = math.random(1,13)
  591. cardtop(pos,1)
  592. numtop(n,pos,1)
  593. if c == 1 then
  594. spade(pos,1)
  595. elseif c == 2 then
  596. heart(pos,1)
  597. elseif c == 3 then
  598. club(pos,1)
  599. elseif c == 4 then
  600. diamond(pos,1)
  601. end
  602. numbase(n,pos,1)
  603. cardbase(pos,1)
  604. return c,n
  605. end
  606. local function spin()
  607. for cnt = 1, 10 do
  608. slot(2)
  609. slot(18)
  610. slot(34)
  611. sleep(cnt/30)
  612. end
  613. end
  614. local function allsuitsmatch(result)
  615. return (result[1] == result[3] and result[3] == result[5] and result[5] ==result[1])
  616. end
  617. local function allvaluesmatch(result)
  618. return (result[2] == result[4] and result[4] == result[6] and result[6] ==result[2] )
  619. end
  620. local function isroyalflush(result)
  621. local Fresult = false
  622. if result[2] > 10 and result[4] > 10 and result[6] > 10 then
  623. if result[2] ~= result[4] and result[4] ~= result[6] and result[6] ~= result[2] then return true  -- royal flush discounting Ace
  624. end
  625. end
  626.  
  627. if result[2] == 1 and result[4] > 11 and result[6] > 11 and result[4] ~= result[6] then return true --royal flush including ace, condition 1
  628. elseif result[4] == 1 and result[6] > 11 and result[2] > 11 and result[6] ~= result[2] then return true --royal flush including ace, condition 2
  629. elseif result[6] == 1 and result[2] > 11 and result[4] > 11 and result[2] ~= result[4] then return true --royal flush including ace, condition 3
  630. end
  631.  
  632. return false
  633. end
  634. local function testwin(results)
  635. ------------------------------
  636. --  This function has been  --
  637. -- brought to you by Pharap --
  638. ------------------------------
  639. local value = 0
  640. if allsuitsmatch(results) then value = 1 end -- suits match
  641. if allvaluesmatch(results) then value = 2 end -- values match
  642. if allsuitsmatch(results) and allvaluesmatch(results) then value = 3 end --suits and values match
  643. if isroyalflush(results) then value = 4 end -- royal flush
  644. if isroyalflush(results) and allsuitsmatch(results) then value = 5 end -- royal flush of all matching suits
  645. if isroyalflush(results) and allvaluesmatch(results) then value = "wtfiswrongwithyou,howthehelldidyoucausesuchabloodystupiderror" return "error"  end-- lol, like this would actually happen
  646. return value
  647. end
  648. local function slots()
  649. term.clear()
  650. sTitle()
  651. slot(2)
  652. slot(18)
  653. slot(34)
  654. while true do
  655. local event, p1 = os.pullEvent()
  656.     if event == "key" then
  657.         if p1 == 28 then
  658.             spin()  
  659.             local s1, n1 = slot(2)
  660.             local s2, n2 = slot(18)
  661.             local s3, n3 = slot(34)
  662.             sleep(2)
  663.         local results = {s1,n1,s2,n2,s3,n3}
  664.          --local results = {3,1,3,12,3,13}
  665.         local condition = testwin(results)
  666.             if condition == 0 then
  667.                 loser()
  668.                 term.clear()
  669.                 sTitle()
  670.                 slot(2)
  671.                 slot(18)
  672.                 slot(34)
  673.             elseif condition == 1 then --suits
  674.                 jackpot()
  675.                 term.clear()
  676.                 sTitle()
  677.                 slot(2)
  678.                 slot(18)
  679.                 slot(34)
  680.             elseif condition == 2 then --values
  681.                 jackpot()
  682.                 term.clear()
  683.                 sTitle()
  684.                 slot(2)
  685.                 slot(18)
  686.                 slot(34)
  687.             elseif condition == 3 then --suits and values
  688.                 jackpot()
  689.                 term.clear()
  690.                 sTitle()
  691.                 slot(2)
  692.                 slot(18)
  693.                 slot(34)
  694.             elseif condition == 4 then --royal flush
  695.                 jackpot()
  696.                 term.clear()
  697.                 sTitle()
  698.                 slot(2)
  699.                 slot(18)
  700.                 slot(34)
  701.             elseif condition == 5 then --royal flush suited
  702.                 jackpot()
  703.                 term.clear()
  704.                 sTitle()
  705.                 slot(2)
  706.                 slot(18)
  707.                 slot(34)
  708.             end
  709.         elseif p1 == 14 then break
  710.         end
  711.     end
  712. end
  713. end
  714.  
  715. --options
  716.  
  717. local function opt(m,mY)
  718. n=1
  719. l=#m
  720. while true do
  721.     for i=1, l, 1 do
  722.     if i==n then
  723.     local x, y = term.getSize()
  724.     local b = string.len(">"..m[i].."<")/2
  725.     local x = (x/2)-b
  726.     term.setCursorPos(x,i+mY)
  727.     term.clearLine()
  728.     print(">"..m[i].."<")
  729.     else
  730.     local x, y = term.getSize()
  731.     b = string.len(m[i])/2
  732.     x = (x/2)-b
  733.     term.setCursorPos(x,i+mY)
  734.     term.clearLine()
  735.     print(m[i]) end
  736.     end
  737. a, b= os.pullEventRaw()
  738. if a == "key" then
  739. if b==200 and n>1 then n=n-1 end
  740. if b==208 and n<l then n=n+1 end
  741. if b==28 then break end
  742. end
  743. end
  744. term.clear() term.setCursorPos(1,1)
  745. return n
  746. end
  747.  
  748. -- game system
  749. while true do
  750. gPage()
  751. local input = opt(gMenu,10)
  752.     if input == 1 then
  753.         dice()
  754.     elseif input == 2 then
  755.         block()
  756.     elseif input == 3 then
  757.         slots()
  758.     elseif input == 4 then break
  759.     end
  760. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement