Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local term = require("term")
- local event = require("event")
- local Data = component.data
- local m = component.modem
- term.clear()
- local ServerA = "158e29fe-4f83-42b5-8837-1bddad8fadc4"
- local PortO = 123
- m.open(PortO)
- local function myFunction(eventName, address, playerName, cardData,
- cardUniqueId, isCardLocked, side)
- m.send(ServerA, PortO, "ATM")
- os.sleep(2)
- m.send(ServerA, PortO, cardData)
- os.sleep(1)
- local _, _, from, port, _, ServerBalance = event.pull("modem_message")
- term.clear()
- local Balance = ServerBalance
- io.write("Choose how much money you are willing to bet\n")
- io.write("Type E to exit!")
- io.write("---------------------------------\n")
- io.write("your balance is ", Balance, "$\n")
- io.write("You will be assigned a random number between\n 1-15 and the casino will be assigned a number between 1-10\n Highest number win!")
- print("\n")
- local BetChoice = io.read()
- local PlayerNum = math.random(1, 15)
- local CasinoNum = math.random(1, 10)
- if PlayerNum > CasinoNum then
- term.clear()
- io.write("YOU WIN!\n You had ", PlayerNum, " Casino had ", CasinoNum)
- local BetWin = BetChoice * 3
- local NewBalance = BetWin + Balance
- io.write("YOU WON ", BetWin, "$")
- m.send(ServerA, PortO, "NewBalance")
- os.sleep(2)
- m.send(ServerA, PortO, cardData)
- os.sleep(2)
- m.send(ServerA, PortO, NewBalance)
- event.ignore("magData", myFunction)
- os.execute("NumberGame")
- elseif PlayerNum < CasinoNum then
- term.clear()
- io.write("YOU LOOSE!\n You had ", PlayerNum, " Casino had ", CasinoNum)
- local NewBalance = Balance - BetChoice
- m.send(ServerA, PortO, "NewBalance")
- os.sleep(2)
- m.send(ServerA, PortO, cardData)
- os.sleep(2)
- m.send(ServerA, PortO, NewBalance)
- event.ignore("magData", myFunction)
- os.execute("NumberGame")
- elseif BetChoice > Balance then
- term.clear()
- io.write("You cant bet more money than what you own!")
- os.sleep(5)
- event.ignore("magData", myFunction)
- os.execute("NumberGame")
- elseif Choice == "E" then
- term.clear()
- event.ignore("magData", myFunction)
- os.execute("CasinoStart")
- else
- term.clear()
- io.write("Incorrect Command!")
- os.sleep(4)
- os.execute("NumberGame")
- end
- end
- term.clear()
- io.write("Scan Your Card")
- event.listen("magData", myFunction)
Add Comment
Please, Sign In to add comment