Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mSide = "right"
- results = {}
- slotImage = {"seven", "heart", "club", "spade", "diamond", "bomb", "star"}
- slotLooserImage = {"looserSeven", "looserHeart", "looserClub", "looserSpade", "looserDiamond", "looserBomb", "looserStar"}
- --mon = peripheral.wrap(mSide)
- --mon.setTextScale(3)
- term.setBackgroundColor(colors.white)
- credits = 500 - ".0"
- pot = 50 - ".0"
- hold = false
- hold1 = false
- hold2 = false
- hold3 = false
- winner = {}
- winnerX = {}
- winnerY = {}
- prize = 0
- win = false
- c = 1
- d = 1
- e = 1
- slotWheel1 = {}
- slotWheel2 = {}
- slotWheel3 = {}
- function activate()
- os.pullEvent("disk")
- end
- function getCredits()
- if fs.exists("/disk/credits") == false then
- term.clear()
- mWrite("There is no credits on the disk.", 9, 9)
- mWrite("To get credits, go to the check-in counter", 4, 10)
- sleep(10)
- os.reboot()
- end
- f = fs.open("/disk/credits", "r")
- credits = f.readLine()
- f.close()
- f = fs.open("startCredits", "w")
- f.write(credits)
- f.close()
- credits = tonumber(credits)
- end
- function startingCredits()
- f = fs.open("startCredits", "r")
- startCredits = f.readLine()
- f.close()
- startCredits = tonumber(startCredits)
- end
- function generateNumber()
- for i = 1,9 do
- randomNum = tonumber(math.random(1,7))
- table.insert(results, randomNum)
- end
- end
- function randomNumber()
- number = tonumber(math.random(1,9))
- return number
- end
- function slotsTable1()
- for i = 1, 260 do
- randomNum = tonumber(math.random(1,7))
- table.insert(slotWheel1, randomNum)
- end
- end
- function slotsTable2()
- for i = 1, 260 do
- randomNum = tonumber(math.random(1,7))
- table.insert(slotWheel2, randomNum)
- end
- end
- function slotsTable3()
- for i = 1, 260 do
- randomNum = tonumber(math.random(1,7))
- table.insert(slotWheel3, randomNum)
- end
- end
- function makeSlotWheel()
- slotsTable1()
- slotsTable2()
- slotsTable3()
- end
- function generateSlots()
- holdingScreen()
- stopWatch = os.startTimer(0.12)
- numberSpin = tonumber(math.random(130, 260))
- for i = 1, numberSpin do
- if hold1 == true and hold2 == true and hold3 == true then
- break
- end
- term.clear()
- creditsScreen()
- potScreen()
- drawSlots()
- holdingScreen()
- event, timerID, x, y = os.pullEvent()
- if event == "timer" then
- stopWatch = 0
- stopWatch = os.startTimer(0.12)
- elseif event == "mouse_click" and x > 1 and x < 8 and y > 17 and y < 20 and hold1 == false then
- hold1 = true
- elseif event == "mouse_click" and x > 9 and x < 16 and y > 17 and y < 20 and hold2 == false then
- hold2 = true
- elseif event == "mouse_click" and x > 17 and x < 24 and y > 17 and y < 20 and hold3 == false then
- hold3 = true
- end
- end
- end
- function drawSlots()
- a = 1
- b = 1
- if hold1 == false then
- slot1 = slotWheel1[c+2]
- drawSlot(slot1, a, b)
- b = b + 6
- slot2 = slotWheel1[c+1]
- drawSlot(slot2, a, b)
- b = b + 6
- slot3 = slotWheel1[c]
- drawSlot(slot3, a, b)
- b = b + 6
- c = c + 1
- elseif hold1 == true then
- drawSlot(slot1, a, b)
- b = b + 6
- drawSlot(slot2, a, b)
- b = b + 6
- drawSlot(slot3, a, b)
- b = b + 6
- end
- a = a +8
- b = 1
- if hold2 == false then
- slot4 = slotWheel2[d+2]
- drawSlot(slot4, a, b)
- b = b + 6
- slot5 = slotWheel2[d+1]
- drawSlot(slot5, a, b)
- b = b + 6
- slot6 = slotWheel2[d]
- drawSlot(slot6, a, b)
- b = b + 6
- d = d+1
- elseif hold2 == true then
- drawSlot(slot4, a, b)
- b = b + 6
- drawSlot(slot5, a, b)
- b = b + 6
- drawSlot(slot6, a, b)
- b = b + 6
- end
- a= a + 8
- b = 1
- if hold3 == false then
- slot7 = slotWheel3[e+2]
- drawSlot(slot7, a, b)
- b = b + 6
- slot8 = slotWheel3[e+1]
- drawSlot(slot8, a, b)
- b = b + 6
- slot9 = slotWheel3[e]
- drawSlot(slot9, a, b)
- b = b + 6
- e = e +1
- elseif hold3 == true then
- drawSlot(slot7, a, b)
- b = b + 6
- drawSlot(slot8, a, b)
- b = b + 6
- drawSlot(slot9, a, b)
- b = b + 6
- end
- end
- function bombOrSeven()
- for i = 1, #winner do
- if winner[i] == 1 then
- prize = prize *2
- elseif winner[i] == 6 then
- prize = pot -(pot*2)
- win = false
- end
- end
- end
- function getWinner()
- if slot1 == slot2 and slot1 == slot3 then -- hvis den forreste række ned
- table.insert(winner, slot1)
- table.insert(winner, slot2)
- table.insert(winner, slot3)
- table.insert(winnerX, 1)
- table.insert(winnerX, 1)
- table.insert(winnerX, 1)
- table.insert(winnerY, 1)
- table.insert(winnerY, 7)
- table.insert(winnerY, 13)
- prize = prize + pot*4
- win = true
- bombOrSeven()
- end
- if slot4 == slot5 and slot4 == slot6 then -- midterste ned
- table.insert(winner, slot4)
- table.insert(winner, slot5)
- table.insert(winner, slot6)
- table.insert(winnerX, 9)
- table.insert(winnerX, 9)
- table.insert(winnerX, 9)
- table.insert(winnerY, 1)
- table.insert(winnerY, 7)
- table.insert(winnerY, 13)
- prize = prize + pot*4
- win = true
- bombOrSeven()
- end
- if slot7 == slot8 and slot7 == slot9 then -- yderste og ned
- table.insert(winner, slot7)
- table.insert(winner, slot8)
- table.insert(winner, slot9)
- table.insert(winnerX, 17)
- table.insert(winnerX, 17)
- table.insert(winnerX, 17)
- table.insert(winnerY, 1)
- table.insert(winnerY, 7)
- table.insert(winnerY, 13)
- prize = prize + pot*4
- win = true
- bombOrSeven()
- end
- if slot1 == slot5 and slot1 == slot9 then -- fra øverste venstre hjørne og ned
- table.insert(winner, slot1)
- table.insert(winner, slot5)
- table.insert(winner, slot9)
- table.insert(winnerX, 1)
- table.insert(winnerX, 9)
- table.insert(winnerX, 17)
- table.insert(winnerY, 1)
- table.insert(winnerY, 7)
- table.insert(winnerY, 13)
- prize = prize + pot*2
- win = true
- bombOrSeven()
- end
- if slot3 == slot5 and slot3 == slot7 then -- fra nederste venstre hjørne og op
- table.insert(winner, slot3)
- table.insert(winner, slot5)
- table.insert(winner, slot7)
- table.insert(winnerX, 1)
- table.insert(winnerX, 9)
- table.insert(winnerX, 17)
- table.insert(winnerY, 1)
- table.insert(winnerY, 7)
- table.insert(winnerY, 13)
- prize = prize + pot*2
- win = true
- bombOrSeven()
- end
- if slot1 == slot4 and slot1 == slot7 then -- øverste hen
- table.insert(winner, slot1)
- table.insert(winner, slot4)
- table.insert(winner, slot7)
- table.insert(winnerX, 1)
- table.insert(winnerX, 9)
- table.insert(winnerX, 17)
- table.insert(winnerY, 1)
- table.insert(winnerY, 1)
- table.insert(winnerY, 1)
- prize = prize + math.ceil(pot*2)
- win = true
- bombOrSeven()
- end
- if slot2 == slot5 and slot2 == slot8 then -- midterste hen
- table.insert(winner, slot2)
- table.insert(winner, slot5)
- table.insert(winner, slot8)
- table.insert(winnerX, 1)
- table.insert(winnerX, 9)
- table.insert(winnerX, 17)
- table.insert(winnerY, 7)
- table.insert(winnerY, 7)
- table.insert(winnerY, 7)
- prize = prize + math.ceil(pot*2)
- win = true
- bombOrSeven()
- end
- if slot3 == slot6 and slot3 == slot9 then -- nederste hen
- table.insert(winner, slot3)
- table.insert(winner, slot6)
- table.insert(winner, slot9)
- table.insert(winnerX, 1)
- table.insert(winnerX, 9)
- table.insert(winnerX, 17)
- table.insert(winnerY, 13)
- table.insert(winnerY, 13)
- table.insert(winnerY, 13)
- prize = prize + math.ceil(pot*2)
- win = true
- bombOrSeven()
- end
- end
- function displayWinner()
- credits = credits + prize
- if win == false then
- credits = credits - pot
- end
- term.clear()
- creditsScreen()
- potScreen()
- for i = 1, #winner do
- drawSlot(winner[i], winnerX[i], winnerY[i])
- end
- end
- function waitClick()
- event = os.pullEvent("mouse_click")
- if event == "mouse_click" then
- notInUse2 = 0
- end
- end
- ----------- SCREENS -------------
- function startScreen2()
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.black)
- drawImage("background", 1,1)
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.black)
- drawImage("logoSeven2", 12, 2)
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.black)
- drawImage("logoSeven2", -12, 2)
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.black)
- drawImage("logoSeven2", 0, 1)
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.black)
- end
- function startScreen4()
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.black)
- drawImage("background", 1,1)
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.black)
- drawImage("logoSeven4", 12, 2)
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.black)
- drawImage("logoSeven4", -12, 2)
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.black)
- drawImage("logoSeven4", 0, 1)
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.black)
- end
- function bettingScreen()
- drawImage("betScreen", 32, 13)
- mWrite("+1", colors.lightGray, colors.black, 32,13)
- mWrite("+10", colors.lightGray, colors.black, 32,15)
- mWrite("-1", colors.lightGray, colors.black, 46,13)
- mWrite("-10", colors.lightGray, colors.black, 46,15)
- mWrite("Place", colors.gray, colors.white, 38, 15)
- end
- function potScreen()
- drawImage("creditScreen", 32, 8)
- mWrite("Pot", colors.gray, colors.white, 39, 8)
- mWrite(pot, colors.white, colors.black, 39, 9)
- end
- function creditsScreen()
- drawImage("creditScreen", 32, 3)
- mWrite("Credits", colors.gray, colors.white, 37, 3)
- mWrite(credits, colors.white, colors.black, 39, 4)
- end
- function holdingScreen()
- drawImage("holdScreen", 2, 18)
- mWrite("Hold", colors.white, colors.black, 3, 19)
- mWrite("Hold", colors.white, colors.black, 11, 19)
- mWrite("Hold", colors.white, colors.black, 19, 19)
- end
- function startScreen()
- term.clear()
- a = 1
- b = 1
- for slotNumber = 1,3 do
- drawSlot(2, a, b)
- a = a +8
- end
- a = 1
- b = b + 6
- for slotNumber = 1,3 do
- drawSlot(1, a, b)
- a = a +8
- end
- a= 1
- b = b + 6
- for slotNumber = 1,3 do
- drawSlot(3, a, b)
- a = a +8
- end
- end
- function mWrite(message, background, text, x, y)
- term.setCursorPos(x,y)
- term.setBackgroundColor(background)
- term.setTextColor(text)
- term.write(message)
- end
- function drawSlot(image, x, y)
- myImage = paintutils.loadImage(slotImage[image])
- paintutils.drawImage(myImage, x, y)
- term.setBackgroundColor(colors.white)
- end
- function drawLooserSlot(image, x, y)
- myImage = paintutils.loadImage(slotLooserImage[image])
- paintutils.drawImage(myImage, x, y)
- term.setBackgroundColor(colors.white)
- end
- function drawImage(image, x, y)
- myImage = paintutils.loadImage(image)
- paintutils.drawImage(myImage, x, y)
- term.setBackgroundColor(colors.black)
- end
- function newGame()
- hold = false
- hold1 = false
- hold2 = false
- hold3 = false
- q = 1
- winner = 0
- winnerX = 0
- winnerY = 0
- winner = {}
- winnerX = {}
- winnerY = {}
- prize = 0
- win = false
- c = 1
- d = 1
- e = 1
- slotWheel1 = 0
- slotWheel2 = 0
- slotWheel3 = 0
- slotWheel1 = {}
- slotWheel2 = {}
- slotWheel3 = {}
- end
- -- ##### LOOP #####
- term.clear()
- term.clear()
- startScreen4()
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.setCursorPos(14,19)
- term.write("Insert credit-disk to play")
- waitClick()
- term.clear()
- term.setBackgroundColor(colors.white)
- while true do
- newGame()
- makeSlotWheel()
- startScreen()
- bettingScreen()
- creditsScreen()
- potScreen()
- waitClick()
- creditsScreen()
- potScreen()
- holdingScreen()
- generateNumber()
- generateSlots()
- sleep(3)
- getWinner()
- displayWinner()
- waitClick()
- newGame()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement