Guest User

Untitled

a guest
Nov 19th, 2018
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.43 KB | None | 0 0
  1. rednet.open("bottom")
  2. local bet = 1
  3. local user = ""
  4. local inactivity = nil
  5. local times = 0
  6. local timeout = 180
  7. local idServer = 1
  8. local blanks = 0
  9. local final = ""
  10. local slot1 = ""
  11. local slot2 = ""
  12. local slot3 = ""
  13. local playing = false
  14. local name = nil
  15. local pass = nil
  16. local results = {
  17.     "Diamond", "Diamond",
  18.     "Emerald","Emerald","Emerald",
  19.     "Gold","Gold","Gold","Gold",
  20.     "Iron","Iron","Iron","Iron","Iron",
  21.     "Stone","Stone","Stone","Stone","Stone","Stone",
  22.     "Wood","Wood","Wood","Wood","Wood","Wood","Wood"
  23. }
  24. local payouts = {}
  25.     payouts["Diamond,Diamond,Diamond"] = 300
  26.     payouts["Emerald,Emerald,Emerald"] = 100
  27.     payouts["Gold,Gold,Gold"] = 50
  28.     payouts["Iron,Iron,Iron"] = 25
  29.     payouts["Stone,Stone,Stone"] = 15
  30.     payouts["Wood,Wood,Wood"] = 5
  31.  
  32. local function CheckID(nameID, passID)
  33.     rednet.send(idServer, nameID ..",".. passID)
  34.     local senderid, message, distance = rednet.receive()
  35.     if senderid == idServer and message == "allow" then
  36.         user = nameID
  37.         return true
  38.     else
  39.         return false
  40.     end
  41. end
  42.  
  43. local function FitText(space, word)
  44.     final = ""
  45.     blanks = math.floor((space - string.len(word))/2)
  46.     if (blanks*2 + string.len(word)) ~= space then
  47.         for i=1, blanks+1 do
  48.             final = final .. " "
  49.         end
  50.         final = final .. word
  51.         for i=1, blanks do
  52.             final = final .. " "
  53.         end
  54.         return final
  55.     else
  56.         for i=1, blanks do
  57.             final = final .. " "
  58.         end
  59.         final = final .. word
  60.         for i=1, blanks do
  61.             final = final .. " "
  62.         end
  63.         return final
  64.     end
  65. end
  66. local function BadID()
  67.     term.clear()
  68.     term.setCursorPos(1,1)
  69.     print([[
  70.    
  71. You either Don't have a valid Casino
  72. Identification card, or you don't have one at
  73. all. Please buy one from one of the casino
  74. clerks. If you're card is somehow corrupt
  75. you can request a replacement.
  76.  
  77.            
  78.            
  79.            Press [ENTER] To Return
  80.    ]])
  81.    
  82.    while true do
  83.        event, param1, param2, param3 = os.pullEvent()
  84.        if event == "key" and param1 == 28 then
  85.            StartScreen()
  86.            break
  87.        end
  88.    end
  89. end
  90.  
  91. local function Slots()
  92.     print([[
  93.   Welcome to the Casino of Sparky's Minecraft
  94.  
  95. Credits:
  96.      ----------------------------------------
  97.      -            -            -            -
  98.      -            -            -            -
  99.      -            -            -            -
  100.      -            -            -            -
  101.      -            -            -            -
  102.      ----------------------------------------
  103.                                  Payout:
  104.                Press [S] To Spin
  105.                Press [Q] To Quit
  106. Press Numbers
  107. To Change Bet              
  108. [1] 2 3                          
  109.     ]])
  110.    
  111.     term.setCursorPos(9,3)
  112.     term.write(num)
  113. end
  114.  
  115. function StartScreen()
  116.     term.clear()
  117.     term.setCursorPos(1,1)
  118.     print([[      
  119.          ||||||  ||      ||||||  ||||||  ||||||
  120.          ||      ||      ||  ||    ||    ||    
  121.          ||||||  ||      ||  ||    ||    ||||||
  122.              ||  ||      ||  ||    ||        ||
  123.          ||||||  ||||||  ||||||    ||    ||||||
  124.  
  125.      
  126.  
  127.                         Press [ENTER] To Continue
  128.     ]])
  129.    
  130.     while true do
  131.         event, param1, param2, param3 = os.pullEvent()
  132.         if event == "key" and param1 == 28 then
  133.             if fs.exists("disk/casinoid") then
  134.                 local id = fs.open("disk/casinoid", "r")
  135.                 local idinfo = id.readAll()
  136.                 name,pass = string.match(idinfo, "([^,]+),(%d+)")
  137.                 if CheckID(name, pass) == true then
  138.                     term.clear()
  139.                     term.setCursorPos(1,1)
  140.                     playing = true
  141.                     inactivity = os.startTimer(timeout)
  142.                     Slots()
  143.                     break
  144.                 else
  145.                     BadID()
  146.                     break
  147.                 end
  148.             else
  149.                 BadID()
  150.                 break
  151.             end
  152.         end
  153.     end
  154. end
  155. StartScreen()
  156.  
  157. while playing == true do
  158.     event, param1, param2, param3 = os.pullEvent()
  159.     if event == "char" and string.lower(param1) == "s" then
  160.         term.setCursorPos(1,7)
  161.         term.clearLine()
  162.         slot1 = results[math.random(1,#results)]
  163.         slot2 = results[math.random(1,#results)]
  164.         slot3 = results[math.random(1,#results)]
  165.         print("     -"..FitText(12, slot1).."-"..FitText(12, slot2).."-"..FitText(12, slot3).."-")
  166.         inactivity = os.startTimer(timeout)
  167.         num = num-bet
  168.         term.setCursorPos(9,3)
  169.         term.write(num.."    ")
  170.         rednet.send(idServer, "creditupdate,"..user..",".."num")
  171.        
  172.         if payouts[slot1..","..slot2..","..slot3] ~= nil then
  173.             term.setCursorPos(9,3)
  174.             num = tonumber(num)+payouts[slot1..","..slot2..","..slot3]*bet
  175.             term.write(num.."    ")
  176.         end
  177.     end
  178.     if event == "char" and string.lower(param1) == "q" then
  179.         playing = false
  180.         StartScreen()
  181.     end
  182.     if event == "char" and (param1=="1" or param1=="2" or param1=="3") then
  183.         local bets = {"[1] 2 3", "1 [2] 3", "1 2 [3]"}
  184.         bet = tonumber(param1)
  185.         term.setCursorPos(1,16)
  186.         term.clearLine()
  187.         print(bets[bet])
  188.         inactivity = os.startTimer(timeout)
  189.     end
  190.     if event == "disk_eject" then
  191.         playing = false
  192.         BadID()
  193.     end
  194.     if event == "timer" and param1 == inactivity then
  195.         disk.eject("right")
  196.     end
  197. end
Add Comment
Please, Sign In to add comment