Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function save(table, name)
- local file = fs.open(name, "w")
- file.write(textutils.serialize(table))
- file.close()
- end
- function load(name)
- local file = fs.open(name, "r")
- local data = file.readAll()
- file.close()
- return textutils.unserialize(data)
- end
- function winnings(amount, result, rand)
- print(rand)
- if (result == 1) then
- money[c_User] = money[c_User] + amount + amount
- print("well done")
- print("you won "..amount)
- print("you now have "..money[c_User])
- elseif (result == 0) then
- print("unlucky")
- print("you lost "..amount)
- print("you now have "..money[c_User])
- end
- save(money, money)
- end
- print("Welcome to Casino v0.1.1")
- local user = {llama = "i awesome"}
- local money = {llama = 100}
- check = 1
- while (check == 1) do
- print("Username: ")
- userin = read()
- print("Password: ")
- passin = read("*")
- if (user[userin] == passin) then
- c_User = userin
- check = 0
- end
- end
- print("What to do?")
- print("gamble -gamble-")
- print("display balance -display-")
- print("logout -logout-")
- input = read()
- if (input == "gamble") then
- print("how much do you want to bet?")
- amount = read()
- if (amount > money[c_User]) then
- print("You don't have enough money")
- else
- money[c_User] = money[c_User] - amount
- print("What Game?")
- print(" ")
- print("Basic Virtual Roulette -roulette-")
- print("To Be Added")
- print("cancel -cancel-")
- save(money, money)
- game = read()
- if (game == "roulette") then
- print("Yay, lets play roulette")
- print("You can guess higher or lower than 18, or guess a single number")
- print("Please enter higher, lower or number")
- roulette = read()
- rand = math.random(36)
- if (roulette == "higher") then
- if (rand > 18) then
- winnings(amount, 1, rand)
- else
- winnings(amount, 0, rand)
- end
- elseif (roulette == "lower") then
- if (rand < 18) then
- winnings(amount, 1, rand)
- else
- winnings(amount, 0, rand)
- end
- elseif (roulette == "number") then
- print("What number do you want to guess")
- roulette_Guess = read()
- if (roulette_guess == rand) then
- thing = amount * 35
- winnings(thing, 1, rand)
- else
- winnings(amount, 0, rand)
- end
- end
- end
- elseif (game == "cancel") then
- money[c_User] = money[c_User] + amount
- save(money, money)
- end
- elseif (input == "display") then
- print("Your Balance Is: ")
- print(money[c_User])
- elseif (input == "logout") then
- save(money, money)
- save(user, user)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement