The3vilM0nk3y

Slots

Sep 4th, 2015
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 20.21 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.   shuffle deck -
  19.     load deck values to array
  20.     until deck full
  21.     choose random number between 1 and array length
  22.     add card at chosen random number
  23.     remove element at chosen random number
  24.    
  25.    
  26.     (serverTime / id ) * numPulls
  27. --]]
  28.  
  29. bgColor = colors.black
  30.  
  31.  
  32. multipliers = {
  33.   "redTorch",
  34.   "eye",
  35.   "pick",
  36.   "sword"
  37.   }
  38. --[[
  39.   Valid names for reels:
  40.   "cow","mooshroom","creeper","pig","enderman","pigman","slime","chicken",
  41.   "zombie","spider","brick","sBrick","snow","ice","grass","mycelium","redTorch",
  42.   "eye","pick","sword"
  43.   ]]--
  44. mobReel = {
  45.   [1] = {
  46.   "cow",
  47.   "mooshroom",
  48.   "creeper",
  49.   "pig",
  50.   "enderman",
  51.   "pigman",
  52.   "slime",
  53.   "chicken",
  54.   "zombie",
  55.   "spider",
  56.   "cow",
  57.   "mooshroom",
  58.   "creeper",
  59.   "pig",
  60.   "enderman",
  61.   "pigman",
  62.   "slime",
  63.   "chicken",
  64.   "zombie",
  65.   "spider",
  66.   "sword"
  67.   },
  68.   [2] = {
  69.   "creeper",
  70.   "slime",
  71.   "pig",
  72.   "zombie",
  73.   "pigman",
  74.   "cow",
  75.   "enderman",
  76.   "chicken",
  77.   "spider",
  78.   "mooshroom",
  79.   "bow",
  80.   "creeper",
  81.   "slime",
  82.   "pig",
  83.   "zombie",
  84.   "pigman",
  85.   "cow",
  86.   "enderman",
  87.   "sword",
  88.   "chicken",
  89.   "spider",
  90.   "mooshroom"
  91.   },
  92.   [3] = {
  93.   "slime",
  94.   "chicken",
  95.   "mooshroom",
  96.   "spider",
  97.   "pig",
  98.   "pigman",
  99.   "creeper",
  100.   "enderman",
  101.   "cow",
  102.   "zombie",
  103.   "slime",
  104.   "chicken",
  105.   "mooshroom",
  106.   "spider",
  107.   "sword",
  108.   "pig",
  109.   "pigman",
  110.   "creeper",
  111.   "enderman",
  112.   "cow",
  113.   "zombie"
  114.   }
  115. }
  116. reel = mobReel
  117. --[[
  118.  
  119. ]]--
  120. -- all images
  121. slotImages = {
  122.   ["blank"] = {
  123.     {32768,32768,32768,32768,32768,32768,32768,32768,32768,32768},
  124.     {32768,32768,32768,32768,32768,32768,32768,32768,32768,32768},
  125.     {32768,32768,32768,32768,32768,32768,32768,32768,32768,32768},
  126.     {32768,32768,32768,32768,32768,32768,32768,32768,32768,32768},
  127.     {32768,32768,32768,32768,32768,32768,32768,32768,32768,32768},
  128.     {32768,32768,32768,32768,32768,32768,32768,32768,32768,32768}
  129.   },
  130.   ["cow"] = {
  131.     {16384,16384,16384,16384,1,1,256,16384,16384,16384},
  132.     {32768,32768,16384,16384,1,256,16384,16384,32768,32768},
  133.     {32768,32768,16384,16384,16384,16384,16384,16384,32768,32768},
  134.     {16384,16384,16384,1,1,1,1,16384,16384,16384},
  135.     {16384,16384,1,32768,256,256,32768,1,16384,16384},
  136.     {16384,16384,1,256,256,256,256,1,16384,16384}
  137.   },
  138.   ["mooshroom"] = {
  139.     {4096,4096,4096,4096,1,1,256,4096,4096,4096},
  140.     {1,1,4096,4096,1,256,4096,4096,1,0},
  141.     {32768,1,4096,4096,4096,4096,4096,4096,1,32768},
  142.     {4096,4096,4096,1,1,1,1,4096,4096,4096},
  143.     {4096,4096,1,32768,256,256,32768,1,4096,4096},
  144.     {4096,4096,1,256,256,256,256,1,4096,4096}
  145.   },
  146.   ["creeper"] = {
  147.     {32,8192,8192,8192,32,8192,32,8192,8192,32},
  148.     {8192,32768,32768,32768,8192,8192,32768,32768,32768,8192},
  149.     {32,32768,32768,32768,8192,32,32768,32768,32768,8192},
  150.     {8192,8192,32,8192,32768,32768,8192,8192,32,8192},
  151.     {32,8192,8192,32768,32768,32768,32768,32,8192,8192},
  152.     {8192,32,8192,32768,32,8192,32768,8192,8192,32}
  153.   },
  154.   ["pig"] = {
  155.     {64,64,64,64,64,64,64,64,64,64},
  156.     {64,64,64,64,64,64,64,64,64,64},
  157.     {64,32768,1,64,64,64,64,1,32768,64},
  158.     {64,64,64,64,64,64,64,64,64,64},
  159.     {64,64,64,4,64,64,4,64,64,64},
  160.     {64,64,64,64,64,64,64,64,64,64},
  161.   },
  162.   ["enderman"] = {
  163.     {32768,128,32768,32768,32768,32768,32768,32768,128,32768},
  164.     {32768,32768,32768,128,32768,32768,128,32768,32768,32768},
  165.     {32768,128,32768,32768,128,128,32768,32768,128,32768},
  166.     {32768,1,64,1,32768,32768,1,64,1,32768},
  167.     {128,32768,32768,128,32768,32768,128,32768,32768,128},
  168.     {32768,32768,128,32768,32768,32768,32768,128,32768,32768}
  169.   },
  170.   ["pigman"] = {
  171.     {1,1,1,32,16384,64,64,64,64,64},
  172.     {1,12,32,16384,64,64,64,64,64,64},
  173.     {32768,128,32,16384,64,64,64,64,1,32768},
  174.     {1,1,1,4,16384,4,64,64,64,64},
  175.     {1,32,32,1,32,16384,64,64,64,64},
  176.     {32,16384,16384,16384,1,32,16384,64,64,64}
  177.   },
  178.   ["slime"] = {
  179.     {32,32,32,32,32,32,32,32,32,32},
  180.     {32,32768,32768,32768,32,32768,32768,32768,32,32},
  181.     {32,32768,32768,32768,32,32768,32768,32768,32,32},
  182.     {32,32,32,32,32,32,32,32,32,32},
  183.     {32,32,32,32,32,32,32768,32768,32,32},
  184.     {32,32,32,32,32,32,32,32,32,32}
  185.   },
  186.   ["chicken"] = {
  187.     {32768,1,1,1,1,1,1,1,1,32768},
  188.     {32768,1,32768,32768,1,1,32768,32768,1,32768},
  189.     {32768,1,2,2,2,2,2,2,1,32768},
  190.     {32768,32768,4096,4096,4096,4096,4096,4096,32768,32768},
  191.     {32768,32768,32768,32768,16384,16384,32768,32768,32768,32768},
  192.     {32768,32768,32768,32768,16384,16384,32768,32768,32768,32768}
  193.   },
  194.   ["zombie"] = {
  195.     {8192,8192,8192,8192,8192,8192,8192,8192,8192,8192},
  196.     {8192,8192,8192,8192,8192,8192,8192,8192,8192,8192},
  197.     {8192,8192,8192,8192,8192,8192,8192,8192,8192,8192},
  198.     {8192,32768,32768,32768,8192,8192,32768,32768,32768,8192},
  199.     {8192,8192,8192,8192,32768,32768,8192,8192,8192,8192},
  200.     {8192,8192,8192,8192,8192,8192,8192,8192,8192,8192}
  201.   },
  202.   ["spider"] = {
  203.     {128,128,128,32768,32768,32768,32768,128,128,128},
  204.     {128,16384,128,128,128,128,128,128,16384,128},
  205.     {128,128,128,16384,128,128,16384,128,128,128},
  206.     {32768,128,128,128,128,128,128,128,128,32768},
  207.     {32768,32768,128,128,32768,32768,128,128,32768,32768},
  208.     {128,128,128,32768,32768,32768,32768,128,128,128}
  209.   },
  210.   ["bricks"] = {
  211.     {16384,16384,0,16384,16384,16384,16384,16384,16384,16384},
  212.     {0,0,0,0,0,0,0,0,0,0},
  213.     {16384,16384,16384,16384,16384,16384,0,16384,16384,16384},
  214.     {16384,16384,16384,16384,16384,16384,0,16384,16384,16384},
  215.     {0,0,0,0,0,0,0,0,0,0},
  216.     {16384,16384,0,16384,16384,16384,16384,16384,16384,16384}
  217.   },
  218.   ["stoneBricks"] = {
  219.     {256,256,128,256,256,256,256,256,256,256},
  220.     {128,128,128,128,128,128,128,128,128,128},
  221.     {256,256,256,256,256,256,128,256,256,256},
  222.     {256,256,256,256,256,256,128,256,256,256},
  223.     {128,128,128,128,128,128,128,128,128,128},
  224.     {256,256,128,256,256,256,256,256,256,256}
  225.   },
  226.   ["snow"] = {
  227.     {0,0,0,0,0,0,0,0,0,0},
  228.     {4096,0,0,0,0,0,4096,4096,0,4096},
  229.     {4096,4096,4096,0,4096,4096,4096,4096,4096,4096},
  230.     {4096,4096,4096,4096,4096,4096,4096,4096,4096,4096},
  231.     {4096,4096,4096,4096,4096,4096,4096,4096,4096,4096},
  232.     {4096,4096,4096,4096,4096,4096,4096,4096,4096,4096}
  233.   },
  234.   ["ice"] = {
  235.     {8,8,8,8,8,8,8,8,8,8},
  236.     {8,8,0,8,8,8,0,8,8,8},
  237.     {8,8,8,0,8,8,8,0,8,8},
  238.     {8,0,8,8,8,8,8,8,8,8},
  239.     {8,8,0,8,8,8,8,8,8,8},
  240.     {8,8,8,8,8,8,8,8,8,8}
  241.   },
  242.   ["grass"] = {
  243.     {8192,8192,8192,8192,8192,8192,8192,8192,8192,8192},
  244.     {8192,8192,8192,8192,8192,8192,8192,8192,8192,8192},
  245.     {8192,8192,8192,8192,8192,8192,8192,8192,8192,8192},
  246.     {8192,8192,8192,8192,8192,8192,8192,8192,8192,8192},
  247.     {8192,8192,8192,8192,8192,8192,8192,8192,8192,8192},
  248.     {8192,4096,4096,4096,4096,8192,8192,8192,4096,4096}
  249.   },
  250.   ["mycelium"] = {
  251.     {1024,1024,1024,1024,1024,1024,1024,1024,1024,1024},
  252.     {1024,1024,1024,1024,1024,1024,1024,1024,1024,1024},
  253.     {1024,1024,1024,1024,1024,1024,1024,1024,1024,1024},
  254.     {1024,1024,1024,1024,1024,1024,1024,1024,1024,1024},
  255.     {1024,1024,1024,1024,1024,1024,1024,1024,1024,1024},
  256.     {1024,4096,4096,4096,4096,1024,1024,1024,4096,4096}
  257.   },
  258.   -- Multipli1er Images
  259.   ["redstoneTorch"] = {
  260.     {32768,32768,32768,16384,16384,16384,16384,32768,32768,32768},
  261.     {32768,32768,16384,16384,16384,16384,16384,16384,32768,32768},
  262.     {32768,32768,16384,16384,2,2,16384,16384,32768,32768},
  263.     {32768,32768,32768,16384,4096,4096,16384,32768,32768,32768},
  264.     {32768,32768,32768,32768,4096,4096,32768,32768,32768,32768},
  265.     {32768,32768,32768,32768,4096,4096,32768,32768,32768,32768}
  266.   },
  267.   ["eyeOfEnder"] = {
  268.     {32768,32768,2048,512,8192,8192,512,2048,32768,32768},
  269.     {32768,2048,512,8192,32,32,8192,512,2048,32768},
  270.     {2048,512,8192,32,32768,32768,32,8192,512,2048},
  271.     {2048,512,8192,32,32768,32768,32,8192,512,2048},
  272.     {32768,2048,512,8192,32,32,8192,512,2048,32768},
  273.     {32768,32768,2048,512,8192,8192,512,2048,32768,32768}
  274.   },
  275.   ["pick"] = {
  276.     {32768,32768,32768,512,512,512,32768,32768,32768,32768},
  277.     {32768,32768,512,32768,4096,32768,512,32768,32768,32768},
  278.     {32768,512,32768,32768,4096,32768,32768,512,32768,32768},
  279.     {32768,32768,32768,32768,4096,32768,32768,32768,32768,32768},
  280.     {32768,32768,32768,32768,4096,32768,32768,32768,32768,32768},
  281.     {32768,32768,32768,32768,4096,32768,32768,32768,32768,32768}
  282.   },
  283.   ["sword"] = {
  284.     {32768,32768,32768,32768,512,32768,32768,32768,32768,32768},
  285.     {32768,32768,32768,32768,512,32768,32768,32768,32768,32768},
  286.     {32768,32768,32768,32768,512,32768,32768,32768,32768,32768},
  287.     {32768,32768,32768,32768,512,32768,32768,32768,32768,32768},
  288.     {32768,32768,32768,256,256,256,32768,32768,32768,32768},
  289.     {32768,32768,32768,32768,4096,32768,32768,32768,32768,32768}
  290.   },
  291.   ["bow"] = {
  292.     {0,0,0,1,4096,0,0,0,0,0},
  293.     {0,0,0,1,0,4096,0,0,0,0},
  294.     {0,0,0,1,0,0,4096,0,0,0},
  295.     {0,0,0,1,0,0,4096,0,0,0},
  296.     {0,0,0,1,0,4096,0,0,0,0},
  297.     {0,0,0,1,4096,0,0,0,0,0}
  298.   },
  299. -- BG Images
  300.   ["arrowl"] = {
  301.     {2,2,0,0},
  302.     {0,2,2,0},
  303.     {0,0,2,2},
  304.     {0,0,2,2},
  305.     {0,2,2,0},
  306.     {2,2,0,0}
  307.   },
  308.   ["arrowr"] = {
  309.     {0,0,2,2},
  310.     {0,2,2,0},
  311.     {2,2,0,0},
  312.     {2,2,0,0},
  313.     {0,2,2,0},
  314.     {0,0,2,2}
  315.   },
  316.   ["logo"] = {
  317.     {0,0,16384,16384,16384,0,16384,16384,16384,0,16384,16384,16384,0,16384,16384,16384,0,16384,16384,16384,0,16384,16384,16384,0,16384,16384,16384},
  318.     {0,0,16384,0,0,0,0,16384,0,0,16384,0,16384,0,16384,0,16384,0,16384,0,0,0,16384,0,16384,0,16384,0,0},
  319.     {0,0,16384,16384,16384,0,0,16384,0,0,16384,0,16384,0,16384,0,16384,0,16384,16384,0,0,16384,16384,16384,0,16384,16384,16384},
  320.     {0,0,0,0,16384,0,0,16384,0,0,16384,0,16384,0,16384,0,16384,0,16384,0,0,0,16384,16384,0,0,0,0,16384},
  321.     {0,0,16384,16384,16384,0,0,16384,0,0,16384,16384,16384,0,16384,0,16384,0,16384,16384,16384,0,16384,0,16384,0,16384,16384,16384},
  322.     {},
  323.     {0,0,0,0,0,0,16384,16384,16384,0,16384,0,0,0,16384,16384,16384,0,16384,16384,16384,0,16384,16384,16384},
  324.     {0,0,0,0,0,0,16384,0,0,0,16384,0,0,0,16384,0,16384,0,0,16384,0,0,16384,0,0},
  325.     {0,0,0,0,0,0,16384,16384,16384,0,16384,0,0,0,16384,0,16384,0,0,16384,0,0,16384,16384,16384},
  326.     {0,0,0,0,0,0,0,0,16384,0,16384,0,0,0,16384,0,16384,0,0,16384,0,0,0,0,16384},
  327.     {0,0,0,0,0,0,16384,16384,16384,0,16384,16384,16384,0,16384,16384,16384,0,0,16384,0,0,16384,16384,16384}
  328.   }
  329. }
  330.  
  331. function toName(num,rnum)
  332.   --print("Getting Name for reel " .. rnum .. " Position " .. num)
  333.   if num > #reel[rnum] then
  334.     num = num - #reel[rnum]
  335.     --print("Too big, converted too " .. rnum)
  336.   elseif num <= 0 then
  337.     num = #reel[rnum] + num
  338.     --print("Too small, converted too " .. rnum)
  339.   end
  340.   return reel[rnum][num]
  341. end
  342. function isMultiplier(num,rnum)
  343.   name = toName(num,rnum)
  344.   for i=1,#multipliers do
  345.     if name == multipliers[i] then
  346.       return true
  347.     end
  348.   end
  349. end
  350. function loadImage(s)
  351.   return slotImages[s]
  352. end
  353. function drawImage(i,x,y)
  354.   for j=1,#i do
  355.     m.setCursorPos(x,y+j-1)
  356.     for k=1,#i[j] do
  357.       if i[j][k] == 0 then
  358.         m.setBackgroundColor(bgColor)
  359.       else
  360.         m.setBackgroundColor(i[j][k])
  361.       end
  362.       m.write(" ")
  363.     end
  364.   end
  365.      
  366. end
  367. function drawBG()
  368.   m.setBackgroundColor(bgColor)
  369.   m.clear()
  370.   m.setCursorPos(1,1)
  371.   -- Logo 27 long 11 high
  372.   logo = loadImage("logo")
  373.   drawImage(logo,logox,1+yspacing)
  374.   m.setBackgroundColor(bgColor)
  375.   showStats()
  376.   local y = ((6 + yspacing) * 2) - 6 + topborder
  377.   arrowl = loadImage("arrowl")
  378.   local x = xspacing + sideborders - 5
  379.   drawImage(arrowl,x,y)
  380.   arrowr = loadImage("arrowr")
  381.   x = ((10 + xspacing) * 3) + sideborders + 1
  382.   drawImage(arrowr,x,y)
  383. end
  384. function draw(n1,n2,n3)
  385.   nums = {n1,n2,n3}
  386.  
  387.   -- draw each reel
  388.   for i=1,3 do
  389.     local tnum  =  nums[i]
  390.     --print("Drawing Reel " .. i .. " with value of " .. tnum)
  391.     -- draw images to reels
  392.     for j=1,3 do
  393.      
  394.       local x = ((10 + xspacing) * i) - 10 + sideborders
  395.       local y = ((6 + yspacing) * j) - 6 + topborder
  396.       local imname = toName(tnum + j - 2, i )
  397.       --print("Drawing Image " .. j .. "- " .. imname .. " at X: " .. x.. " Y: " .. y)
  398.       local timg = loadImage(imname)
  399.       if timg == nil then
  400.         --print("Image returned a nil value?!")
  401.       end
  402.       -- load and draw current random number image and images before and after it.
  403.       drawImage( timg , x, y )
  404.       m.setBackgroundColor(bgColor)
  405.     end
  406.   end
  407. end
  408. function showStats()
  409.   m.setCursorPos(2,h-1)
  410.   m.write("Stand On The PIM Then Click Screen To Play")
  411.   if player.name then
  412.     m.setCursorPos(2,h)
  413.     m.clearLine()
  414.     m.setCursorPos(2,h)
  415.     m.write("Player: " .. player.name)
  416.     m.setCursorPos(w - string.len("Credits: " .. player.balance)- 1,h)
  417.     m.write("Credits: " .. player.balance)
  418.   end
  419. end
  420. function tellResults(s,n)
  421.   if s ~= "none" then
  422.     local x = math.floor( (w/2 - 18) + .5)
  423.     local y = ((6 + yspacing) * 3) + topborder + 1
  424.     local amountx = math.floor( (w/2 - ( (string.len("+"..tostring(n))/2) * 6 ) ) + .5)
  425.     local last = term.redirect(m)
  426.     alphanumeric.stringToImg("WINNER",colors.red,x,y)
  427.     alphanumeric.stringToImg("+"..tostring(n),colors.red,amountx,y + 6)
  428.     term.redirect(last)
  429.   end
  430.   showStats()
  431. end
  432.  
  433. function checkAPI()
  434.   if not fs.exists("alphanumeric") then
  435.     multishell.run("pastebin get YVtwWRBQ disk/alphanumeric")
  436.   end
  437. end
  438. function modifyPlayer(p,num,t)
  439.   print("Sending info for " .. p)
  440.   rednet.send(server,"modify " ..  p .. " " .. num .. " " .. t)
  441.   local msg = nil
  442.   local attempts = 1
  443.   -- wait for message for 10 ticks retry 3 times
  444.   repeat
  445.     id,msg,proto = rednet.receive(.5)
  446.     attempts = attempts + 1
  447.   until msg or (attempts > 3 )
  448.   if msg and id == server then
  449.     print(msg)
  450.     return textutils.unserialize(msg)
  451.   end
  452. end
  453. function getPlayer(p)
  454.   print("getting player info for " .. p)
  455.   rednet.send(server,"get " ..  p)
  456.   local msg = nil
  457.   local attempts = 1
  458.   -- wait for message for 10 ticks retry 3 times
  459.   repeat
  460.     print("attempt " .. attempts)
  461.     id,msg,proto = rednet.receive(.5)
  462.     attempts = attempts + 1
  463.   until msg or (attempts > 3 )
  464.   if msg and id == server then
  465.     print(msg)
  466.     return msg
  467.   else
  468.     return nil
  469.   end
  470. end
  471.  
  472. function getWireless()
  473.   local peripherals = peripheral.getNames()
  474.   local wirelessSide = nil
  475.   local gotWireless = false
  476.   for i=1, #peripherals do
  477.     if peripheral.getType(peripherals[i]) == "modem" then
  478.       if peripheral.call(peripherals[i],"isWireless") then
  479.         wirelessSide = peripherals[i]
  480.         gotWireless = true
  481.       end
  482.     end
  483.     if gotWireless then
  484.       break
  485.     end
  486.   end
  487.   return wirelessSide
  488. end
  489. -- Load Peripherals
  490.  
  491. m = peripheral.find("monitor")
  492. pim = peripheral.find("pim")
  493. -- Define Constants
  494. pullCost = 5
  495. m.setTextScale(.5)
  496. w,h = m.getSize()
  497. logox = math.floor( (w - 27)/2 )
  498. xspacing = 2
  499. yspacing = 2
  500. slotwidth = 3 * (10 + xspacing)
  501. slotheight = 3 * (6 + yspacing)
  502. sideborders = math.floor((w - slotwidth )/2)
  503. topborder = (#slotImages["logo"] + yspacing) + 1
  504. server = 267
  505. tune = {1,5,8}
  506. -- Define Variables
  507. player = {}
  508. playerName = ""
  509. num1 = math.random(1,#reel[1])
  510. num2 = math.random(1,#reel[2])
  511. num3 = math.random(1,#reel[3])
  512. running = false
  513. if os.getComputerLabel() ~= "slot" then
  514.   os.setComputerLabel("slot")
  515. end
  516. -- Pre Setup Functions
  517. rednet.open(getWireless())
  518. os.loadAPI("disk/alphanumeric")
  519. print("Size = w " .. w .. " h " .. h)
  520. print("Slot Width = " ..  slotwidth )
  521. print("Border Size = " .. sideborders)
  522. print("Calculated Size = " .. sideborders * 2 + slotwidth)
  523. print("Computer ID = " .. os.getComputerID())
  524. print("Computer Label = " .. os.getComputerLabel())
  525. drawBG()
  526. draw(num1,num2,num3)
  527.  
  528. -- Begin Logic Loop
  529. while true do
  530.   -- Wait for a monitor touch event
  531.   e,p1,p2,p3 = os.pullEvent()
  532.   if e == "monitor_touch" then
  533.     -- Check if slot is running already
  534.     if not running then
  535.       playerName = pim.getInventoryName()
  536.       -- Make sure player is on PIM
  537.       if playerName ~= "pim" then
  538.         -- Get player info from server
  539.         msg = getPlayer(playerName)
  540.         -- continue if message was recieved back from server
  541.         if msg ~=nil then
  542.           player = textutils.unserialize(msg)
  543.           print(player)
  544.           -- make sure player has enough credits
  545.           if player.balance >= pullCost or player.name == "BigD999" then
  546.             -- begin slot pull
  547.             player = modifyPlayer(player.name,pullCost*-1,"pull")
  548.             running = true
  549.             drawBG()
  550.             print("Starting Randomizer")
  551.             -- Spin cycle 1 - all three
  552.             spin = math.random(30,50)
  553.             local tuneIndex = 1
  554.             for i=1,spin do
  555.               num1 = num1 - 1
  556.               num2 = num2 - 1
  557.               num3 = num3 - 1
  558.               if num1 < 0 then
  559.                 num1 = #reel[1]
  560.               end
  561.               if num2 < 0 then
  562.                 num2 = #reel[2]
  563.               end
  564.               if num3 < 0 then
  565.                 num3 = #reel[3]
  566.               end
  567.               --print(num1," ",num2," ",num3," ")
  568.              
  569.               draw(num1,num2,num3)
  570.               sleep(.05)
  571.             end
  572.             -- Spin cycle 2 - reels 2 and 3
  573.             spin = math.random(5,20)
  574.             for i=1,spin do
  575.               num2 = num2 - 1
  576.               num3 = num3 - 1
  577.               if num2 < 0 then
  578.                 num2 = #reel[2]
  579.               end
  580.               if num3 < 0 then
  581.                 num3 = #reel[3]
  582.               end
  583.               --print(num1," ",num2," ",num3," ")
  584.               draw(num1,num2,num3)
  585.               sleep(.05)
  586.             end
  587.             -- Spin cycle 3 - reel 3
  588.             spin = math.random(5,20)
  589.             for i=1,spin do
  590.               num3 = num3 - 1
  591.               if num3 < 0 then
  592.                 num3 = #reel[3]
  593.               end
  594.               --print(num1," ",num2," ",num3," ")
  595.               draw(num1,num2,num3)
  596.               sleep(.05)
  597.             end
  598.              
  599.             -- Begin Result Checking
  600.             print("Checking Results")
  601.             amount = 0
  602.             if toName(num1,1) == toName(num2,2) and toName(num2,2) == toName(num3,3) then
  603.             -- three in a row
  604.               if isMultiplier(num1,1) and isMultiplier(num2,2) and isMultiplier(num3,3) then
  605.                 -- JACKPOT!!!!
  606.                 result = "jackpot"
  607.                 amount = pullCost * 50
  608.                 print(result)
  609.               else
  610.                 result = "three"
  611.                 print(result)
  612.                 amount = pullCost * 25
  613.               end
  614.             elseif toName(num1,1) == toName(num2,2) or toName(num2,2) == toName(num3,3) or toName(num1,1) == toName(num3,3) then
  615.             -- We have a pair
  616.               if isMultiplier(num1,1) or isMultiplier(num2,2) or isMultiplier(num3,3) then
  617.               -- the pair contains a multiplier
  618.                 if (isMultiplier(num1,1) and isMultiplier(num2,2)) or ( isMultiplier(num2,2) and isMultiplier(num3,3) ) or ( isMultiplier(num1,1) and isMultiplier(num1,1) )then
  619.                 -- the pair is a pair of multipliers
  620.                   result = "pair++!"
  621.                   print(result)
  622.                   amount =  pullCost * 4
  623.                 else
  624.                   result = "pair+"
  625.                   print(result)
  626.                   amount =  pullCost * 4
  627.                 end
  628.               else
  629.                 result = "pair"
  630.                 print(result)
  631.                 amount =  pullCost * 2
  632.               end
  633.             elseif isMultiplier(num1,1) or isMultiplier(num2,2) or isMultiplier(num3,3) then
  634.               result = "freespin"
  635.               print(result)
  636.               amount = pullCost
  637.             else
  638.               result = "none"
  639.               print(result)
  640.             end
  641.             if amount > 0 then
  642.               player = modifyPlayer(player.name,amount,"payoutSlots")
  643.             end
  644.             tellResults(result,amount)
  645.             running = false
  646.           else
  647.             print("Player doesnt have enough money")
  648.             showStats()
  649.           end
  650.         else
  651.           print("Could not contact Mainframe!")
  652.         end
  653.       end
  654.     end
  655.   end
  656. end
Advertisement
Add Comment
Please, Sign In to add comment