-- European Roulette Turtle Casino -- ComputerCraft / CC:Tweaked style program -- Designed for Advanced Monitor wall, 3 tall x 7 wide -- Uses a turtle as the diamond bank/payout machine -- Uses speaker if available -- -- Features: -- - Bet amount controls: +1 +5 +10 / -1 -5 -10 / RESET AMT -- - Cash out all player credits -- - Safe exit / safe cashout confirmation -- - Larger bottom-positioned bet controls -- - More visible zero slot color -------------------------------------------------- -- CONFIG -------------------------------------------------- local DIAMOND_ID = "minecraft:diamond" local RETURN_STAKE_ON_WIN = true -- true = a 1 diamond straight win pays 36 diamonds total -- false = a 1 diamond straight win pays 35 diamonds profit only local TEXT_SCALE = 0.5 local MIN_BET = 1 local MAX_BET_PER_SPACE = 999 local MAX_BET_AMOUNT = 999 local SPIN_STEPS = 44 local SPIN_DELAY_START = 0.035 local SPIN_DELAY_END = 0.16 local CASINO_MENU_PROGRAM = "casino" local CASINO_BANK_FILE = "casino_bank_base.txt" local TABLE_Y = 20 local BOTTOM_CONTROLS_RESERVED = 12 -------------------------------------------------- -- PERIPHERALS -------------------------------------------------- local mon = peripheral.find("monitor") if not mon then error("No monitor found. Attach/wrap an advanced monitor wall.") end local speaker = nil for _, name in ipairs(peripheral.getNames()) do local p = peripheral.wrap(name) if p then if type(p.playNote) == "function" or type(p.playSound) == "function" then speaker = p break end end end mon.setTextScale(TEXT_SCALE) mon.setBackgroundColor(colors.green) mon.setTextColor(colors.white) mon.clear() local W, H = mon.getSize() -------------------------------------------------- -- UTILS -------------------------------------------------- local function clamp(v, a, b) if v < a then return a end if v > b then return b end return v end local function writeAt(x, y, text, fg, bg) if bg then mon.setBackgroundColor(bg) end if fg then mon.setTextColor(fg) end mon.setCursorPos(x, y) mon.write(text) end local function fillBox(x, y, w, h, bg) if w <= 0 or h <= 0 then return end mon.setBackgroundColor(bg) for yy = y, y + h - 1 do if yy >= 1 and yy <= H then mon.setCursorPos(x, yy) mon.write(string.rep(" ", math.max(0, math.min(w, W - x + 1)))) end end end local function centerText(x, y, w, text, fg, bg) text = tostring(text) if #text > w then text = string.sub(text, 1, w) end local pad = math.floor((w - #text) / 2) writeAt(x + pad, y, text, fg, bg) end local function drawButton(x, y, w, h, label, bg, fg) fillBox(x, y, w, h, bg) local cy = y + math.floor(h / 2) centerText(x, cy, w, label, fg or colors.white, bg) end local function inBox(px, py, box) return px >= box.x and px < box.x + box.w and py >= box.y and py < box.y + box.h end -------------------------------------------------- -- DIAMOND BANKING -------------------------------------------------- local function countDiamonds() local total = 0 for slot = 1, 16 do local d = turtle.getItemDetail(slot) if d and d.name == DIAMOND_ID then total = total + d.count end end return total end local function selectDiamondSlot() for slot = 1, 16 do local d = turtle.getItemDetail(slot) if d and d.name == DIAMOND_ID and d.count > 0 then turtle.select(slot) return true end end return false end local function pullDiamondsFromAboveUntil(amountNeeded) local tries = 0 while countDiamonds() < amountNeeded and tries < 64 do tries = tries + 1 local pulled = turtle.suckUp(64) if not pulled then break end sleep(0.05) end return countDiamonds() >= amountNeeded end local function dropDiamondsDown(amount) local remaining = amount while remaining > 0 do if not selectDiamondSlot() then return false, amount - remaining end local d = turtle.getItemDetail() if not d or d.name ~= DIAMOND_ID then return false, amount - remaining end local toDrop = math.min(remaining, d.count) local ok = turtle.dropDown(toDrop) if not ok then return false, amount - remaining end remaining = remaining - toDrop sleep(0.03) end return true, amount end -------------------------------------------------- -- SOUND -------------------------------------------------- local function playNoteSafe(instrument, volume, pitch) if not speaker then return end instrument = instrument or "harp" volume = volume or 1 pitch = pitch or 12 if type(speaker.playNote) == "function" then local ok = pcall(function() speaker.playNote(instrument, volume, pitch) end) if ok then return end end if type(speaker.playSound) == "function" then pcall(function() speaker.playSound("note.harp", volume, 1) end) end end local function soundClick() playNoteSafe("hat", 0.8, 12) end local function soundSpin() playNoteSafe("hat", 0.6, math.random(8, 18)) end local function soundWin() playNoteSafe("bell", 1, 16) sleep(0.08) playNoteSafe("bell", 1, 20) sleep(0.08) playNoteSafe("bell", 1, 24) end local function soundLoss() playNoteSafe("bass", 1, 6) sleep(0.12) playNoteSafe("bass", 1, 4) end -------------------------------------------------- -- ROULETTE DATA -------------------------------------------------- local wheelOrder = { 0, 32, 15, 19, 4, 21, 2, 25, 17, 34, 6, 27, 13, 36, 11, 30, 8, 23, 10, 5, 24, 16, 33, 1, 20, 14, 31, 9, 22, 18, 29, 7, 28, 12, 35, 3, 26 } local redNums = { [1]=true,[3]=true,[5]=true,[7]=true,[9]=true, [12]=true,[14]=true,[16]=true,[18]=true, [19]=true,[21]=true,[23]=true,[25]=true,[27]=true, [30]=true,[32]=true,[34]=true,[36]=true } local blackNums = {} for n = 1, 36 do if not redNums[n] then blackNums[n] = true end end local function numColor(n) if n == 0 then return colors.lime end if redNums[n] then return colors.red end return colors.black end local function numTextColor(n) if n == 0 then return colors.black end return colors.white end -------------------------------------------------- -- GAME STATE -------------------------------------------------- math.randomseed(os.epoch and os.epoch("utc") or os.clock() * 100000) local bets = {} local hitBoxes = {} local message = "Deposit diamonds, set bet amount, tap spaces, then START SPIN." local lastResult = nil local spinning = false local wheelHighlightIndex = 1 local betAmount = 1 -- confirmMode: -- nil = normal -- "exit" = confirm exit to menu -- "cashout" = confirm clearing active bets and cashing out local confirmMode = nil local function loadBankBase() if fs.exists(CASINO_BANK_FILE) then local f = fs.open(CASINO_BANK_FILE, "r") if f then local raw = f.readAll() f.close() local n = tonumber(raw) if n and n >= 0 then return n end end end return countDiamonds() end local bankBase = loadBankBase() local function saveBankBase() local f = fs.open(CASINO_BANK_FILE, "w") if f then f.write(tostring(math.floor(bankBase))) f.close() end end saveBankBase() local function totalBets() local t = 0 for _, amt in pairs(bets) do t = t + amt end return t end local function availableCredits() local current = countDiamonds() local credits = current - bankBase - totalBets() if credits < 0 then credits = 0 end return credits end -------------------------------------------------- -- BET AMOUNT CONTROLS -------------------------------------------------- local function changeBetAmount(delta) if spinning or confirmMode then return end betAmount = betAmount + delta betAmount = clamp(betAmount, MIN_BET, MAX_BET_AMOUNT) message = "Bet amount set to " .. betAmount .. " diamond(s)." soundClick() end local function resetBetAmount() if spinning or confirmMode then return end betAmount = 1 message = "Bet amount reset to 1 diamond." soundClick() end local function addBet(id) if spinning or confirmMode then return end local amount = betAmount if availableCredits() < amount then message = "Need " .. amount .. " unbet diamond(s) to place that bet." soundLoss() return end bets[id] = bets[id] or 0 if bets[id] + amount > MAX_BET_PER_SPACE then message = "Max bet reached on this space." soundLoss() return end bets[id] = bets[id] + amount message = "Bet +" .. amount .. " on " .. id soundClick() end local function clearBets() if spinning then return end bets = {} message = "Bets cleared. Diamonds remain as credits." soundClick() end -------------------------------------------------- -- CASH OUT / EXIT LOGIC -------------------------------------------------- local function cashOutCredits() if spinning then message = "Cannot cash out while wheel is spinning." soundLoss() return end local amount = availableCredits() if amount <= 0 then message = "No unbet credits to cash out." soundLoss() return end local ok, dropped = dropDiamondsDown(amount) if ok then message = "Cashed out " .. dropped .. " diamond(s) below." soundWin() else message = "Cash out blocked! Dropped " .. dropped .. "/" .. amount .. "." soundLoss() end saveBankBase() end local function requestCashOut() if spinning then message = "Cannot cash out while wheel is spinning." soundLoss() return end if totalBets() > 0 then confirmMode = "cashout" message = "Confirm cash out. Active unspun bets will be cleared first." soundLoss() return end cashOutCredits() end local function exitToMenuNow() bets = {} confirmMode = nil saveBankBase() mon.setBackgroundColor(colors.black) mon.setTextColor(colors.white) mon.clear() if shell then if fs.exists(CASINO_MENU_PROGRAM) then shell.run(CASINO_MENU_PROGRAM) elseif fs.exists(CASINO_MENU_PROGRAM .. ".lua") then shell.run(CASINO_MENU_PROGRAM .. ".lua") else print("Casino menu not found.") print("Expected: " .. CASINO_MENU_PROGRAM) end end error("Exited to casino menu", 0) end local function requestExit() if spinning then message = "Cannot exit while wheel is spinning." soundLoss() return end if totalBets() > 0 then confirmMode = "exit" message = "Confirm exit. Current unspun bets will be cleared back to credits." soundLoss() else exitToMenuNow() end end -------------------------------------------------- -- BET RESOLUTION -------------------------------------------------- local function betWins(id, result) if string.sub(id, 1, 2) == "N:" then local n = tonumber(string.sub(id, 3)) if n == result then return true, 35 end return false, 0 end if id == "RED" then return redNums[result] == true, 1 end if id == "BLACK" then return blackNums[result] == true, 1 end if id == "ODD" then return result >= 1 and result <= 36 and result % 2 == 1, 1 end if id == "EVEN" then return result >= 1 and result <= 36 and result % 2 == 0, 1 end if id == "LOW" then return result >= 1 and result <= 18, 1 end if id == "HIGH" then return result >= 19 and result <= 36, 1 end if id == "D1" then return result >= 1 and result <= 12, 2 end if id == "D2" then return result >= 13 and result <= 24, 2 end if id == "D3" then return result >= 25 and result <= 36, 2 end if id == "C1" then return result >= 1 and result <= 36 and result % 3 == 1, 2 end if id == "C2" then return result >= 1 and result <= 36 and result % 3 == 2, 2 end if id == "C3" then return result >= 1 and result <= 36 and result % 3 == 0, 2 end return false, 0 end local function resolvePayout(result) local payout = 0 local winningBets = 0 for id, amt in pairs(bets) do local won, odds = betWins(id, result) if won then winningBets = winningBets + amt if RETURN_STAKE_ON_WIN then payout = payout + (amt * (odds + 1)) else payout = payout + (amt * odds) end end end return payout, winningBets end -------------------------------------------------- -- DRAWING -------------------------------------------------- local function resetHitBoxes() hitBoxes = {} end local function addHit(id, x, y, w, h) table.insert(hitBoxes, { id = id, x = x, y = y, w = w, h = h }) end local function drawFrame() fillBox(1, 1, W, H, colors.green) fillBox(1, 1, W, 1, colors.black) centerText(1, 1, W, "EUROPEAN ROULETTE | DIAMOND CASINO", colors.lime, colors.black) end local function drawWheel() local x = 2 local y = 3 local w = math.min(44, W - 4) local h = 12 fillBox(x, y, w, h, colors.gray) centerText(x, y, w, "ROULETTE WHEEL", colors.yellow, colors.gray) local displaySlots = 12 local start = wheelHighlightIndex for i = 1, displaySlots do local idx = ((start + i - 2) % #wheelOrder) + 1 local n = wheelOrder[idx] local cellW = math.floor(w / displaySlots) local cx = x + (i - 1) * cellW local bg = numColor(n) local fg = numTextColor(n) if i == math.ceil(displaySlots / 2) then bg = colors.yellow fg = colors.black end fillBox(cx, y + 3, cellW - 1, 3, bg) centerText(cx, y + 4, cellW - 1, tostring(n), fg, bg) end centerText(x, y + 8, w, "^^^^ BALL ^^^^", colors.white, colors.gray) if lastResult ~= nil then local bg = numColor(lastResult) fillBox(x + math.floor(w / 2) - 6, y + 10, 12, 1, bg) centerText(x + math.floor(w / 2) - 6, y + 10, 12, "LAST: " .. tostring(lastResult), numTextColor(lastResult), bg) else centerText(x, y + 10, w, "LAST: --", colors.white, colors.gray) end end local function drawInfoPanel() local x = 48 local y = 3 local w = W - x - 1 local h = 16 if w < 34 then return end fillBox(x, y, w, h, colors.black) writeAt(x + 2, y + 1, "Credits: " .. availableCredits(), colors.lime, colors.black) writeAt(x + 2, y + 2, "Total Bets: " .. totalBets(), colors.yellow, colors.black) writeAt(x + 2, y + 3, "Bet Amount: " .. betAmount, colors.orange, colors.black) writeAt(x + 2, y + 4, "Diamonds In Turtle: " .. countDiamonds(), colors.white, colors.black) writeAt(x + 2, y + 5, "House Bank Base: " .. bankBase, colors.lightGray, colors.black) local stakeText = "Win pays stake: " if RETURN_STAKE_ON_WIN then stakeText = stakeText .. "YES" else stakeText = stakeText .. "NO" end writeAt(x + 2, y + 6, stakeText, colors.lightGray, colors.black) fillBox(x + 1, y + 8, w - 2, 2, colors.gray) writeAt(x + 2, y + 8, string.sub(message, 1, w - 4), colors.white, colors.gray) local thirdW = math.floor((w - 5) / 3) drawButton(x + 1, y + 12, thirdW, 3, "START", colors.lime, colors.black) addHit("ACTION:START", x + 1, y + 12, thirdW, 3) drawButton(x + 2 + thirdW, y + 12, thirdW, 3, "CLEAR", colors.red, colors.white) addHit("ACTION:CLEAR", x + 2 + thirdW, y + 12, thirdW, 3) drawButton(x + 3 + thirdW * 2, y + 12, thirdW, 3, "MENU", colors.gray, colors.white) addHit("ACTION:EXIT", x + 3 + thirdW * 2, y + 12, thirdW, 3) end local function drawBottomBetControls() local panelW = math.min(W - 6, 124) local x = math.floor((W - panelW) / 2) local y = H - 11 local panelH = 10 fillBox(x, y, panelW, panelH, colors.black) centerText(x, y, panelW, "BET CONTROLS | CURRENT BET AMOUNT: " .. betAmount, colors.yellow, colors.black) local gap = 1 local smallW = math.floor((panelW - 4 - gap * 2) / 3) drawButton(x + 1, y + 1, smallW, 3, "+1", colors.lime, colors.black) addHit("BETAMT:+1", x + 1, y + 1, smallW, 3) drawButton(x + 1 + smallW + gap, y + 1, smallW, 3, "+5", colors.lime, colors.black) addHit("BETAMT:+5", x + 1 + smallW + gap, y + 1, smallW, 3) drawButton(x + 1 + (smallW + gap) * 2, y + 1, smallW, 3, "+10", colors.lime, colors.black) addHit("BETAMT:+10", x + 1 + (smallW + gap) * 2, y + 1, smallW, 3) drawButton(x + 1, y + 4, smallW, 3, "-1", colors.orange, colors.black) addHit("BETAMT:-1", x + 1, y + 4, smallW, 3) drawButton(x + 1 + smallW + gap, y + 4, smallW, 3, "-5", colors.orange, colors.black) addHit("BETAMT:-5", x + 1 + smallW + gap, y + 4, smallW, 3) drawButton(x + 1 + (smallW + gap) * 2, y + 4, smallW, 3, "-10", colors.orange, colors.black) addHit("BETAMT:-10", x + 1 + (smallW + gap) * 2, y + 4, smallW, 3) local halfW = math.floor((panelW - 3) / 2) drawButton(x + 1, y + 7, halfW, 3, "RESET AMT", colors.gray, colors.white) addHit("BETAMT:RESET", x + 1, y + 7, halfW, 3) drawButton(x + 2 + halfW, y + 7, halfW, 3, "CASH OUT", colors.yellow, colors.black) addHit("ACTION:CASHOUT", x + 2 + halfW, y + 7, halfW, 3) end local function drawBetAmount(id, x, y, w, bg) local amt = bets[id] or 0 if amt > 0 then local s = "x" .. tostring(amt) writeAt(x + w - #s, y, s, colors.yellow, bg) end end local function drawNumberCell(n, x, y, w, h) local bg = numColor(n) local fg = numTextColor(n) drawButton(x, y, w, h, tostring(n), bg, fg) addHit("N:" .. tostring(n), x, y, w, h) drawBetAmount("N:" .. tostring(n), x, y + h - 1, w, bg) end local function drawTable() local tableY = TABLE_Y local startX = 2 local cellW = math.max(4, math.floor((W - 14) / 14)) cellW = clamp(cellW, 4, 8) local cellH = 3 local zeroW = cellW local numX = startX + zeroW + 1 fillBox(1, tableY - 1, W, H - tableY - BOTTOM_CONTROLS_RESERVED, colors.green) centerText(1, tableY - 1, W, "TAP A SPACE TO PLACE CURRENT BET AMOUNT", colors.black, colors.green) local zeroBg = numColor(0) local zeroFg = numTextColor(0) drawButton(startX, tableY, zeroW, cellH * 3, "0", zeroBg, zeroFg) addHit("N:0", startX, tableY, zeroW, cellH * 3) drawBetAmount("N:0", startX, tableY + cellH * 3 - 1, zeroW, zeroBg) for col = 1, 12 do local nums = { col * 3, col * 3 - 1, col * 3 - 2 } for row = 1, 3 do local n = nums[row] local x = numX + (col - 1) * cellW local y = tableY + (row - 1) * cellH drawNumberCell(n, x, y, cellW - 1, cellH) end end local colBetX = numX + 12 * cellW drawButton(colBetX, tableY, cellW, cellH, "2:1", colors.gray, colors.white) addHit("C3", colBetX, tableY, cellW, cellH) drawBetAmount("C3", colBetX, tableY + cellH - 1, cellW, colors.gray) drawButton(colBetX, tableY + cellH, cellW, cellH, "2:1", colors.gray, colors.white) addHit("C2", colBetX, tableY + cellH, cellW, cellH) drawBetAmount("C2", colBetX, tableY + cellH * 2 - 1, cellW, colors.gray) drawButton(colBetX, tableY + cellH * 2, cellW, cellH, "2:1", colors.gray, colors.white) addHit("C1", colBetX, tableY + cellH * 2, cellW, cellH) drawBetAmount("C1", colBetX, tableY + cellH * 3 - 1, cellW, colors.gray) local dozenY = tableY + cellH * 3 + 1 local dozenW = cellW * 4 - 1 drawButton(numX, dozenY, dozenW, 2, "1st 12", colors.gray, colors.white) addHit("D1", numX, dozenY, dozenW, 2) drawBetAmount("D1", numX, dozenY + 1, dozenW, colors.gray) drawButton(numX + cellW * 4, dozenY, dozenW, 2, "2nd 12", colors.gray, colors.white) addHit("D2", numX + cellW * 4, dozenY, dozenW, 2) drawBetAmount("D2", numX + cellW * 4, dozenY + 1, dozenW, colors.gray) drawButton(numX + cellW * 8, dozenY, dozenW, 2, "3rd 12", colors.gray, colors.white) addHit("D3", numX + cellW * 8, dozenY, dozenW, 2) drawBetAmount("D3", numX + cellW * 8, dozenY + 1, dozenW, colors.gray) local outsideY = dozenY + 3 local outsideLabels = { {"LOW", "1-18", colors.gray, colors.white}, {"EVEN", "EVEN", colors.gray, colors.white}, {"RED", "RED", colors.red, colors.white}, {"BLACK", "BLACK", colors.black, colors.white}, {"ODD", "ODD", colors.gray, colors.white}, {"HIGH", "19-36", colors.gray, colors.white} } local outsideW = math.floor((cellW * 12 - 1) / 6) for i, b in ipairs(outsideLabels) do local id, label, bg, fg = b[1], b[2], b[3], b[4] local x = numX + (i - 1) * outsideW drawButton(x, outsideY, outsideW - 1, 3, label, bg, fg) addHit(id, x, outsideY, outsideW - 1, 3) drawBetAmount(id, x, outsideY + 2, outsideW - 1, bg) end end local function drawConfirmScreen() resetHitBoxes() fillBox(1, 1, W, H, colors.black) if confirmMode == "exit" then centerText(1, 3, W, "CONFIRM EXIT TO GAME MENU", colors.yellow, colors.black) centerText(1, 6, W, "You have " .. totalBets() .. " diamond(s) in unspun bets.", colors.white, colors.black) centerText(1, 8, W, "Leaving will clear those bets back into your credits.", colors.lightGray, colors.black) centerText(1, 10, W, "No diamonds will be paid out or removed.", colors.lightGray, colors.black) elseif confirmMode == "cashout" then centerText(1, 3, W, "CONFIRM CASH OUT", colors.yellow, colors.black) centerText(1, 6, W, "You have " .. totalBets() .. " diamond(s) in unspun bets.", colors.white, colors.black) centerText(1, 8, W, "Cash out will clear active bets back into credits first.", colors.lightGray, colors.black) centerText(1, 10, W, "Then all player credits will drop below the turtle.", colors.lightGray, colors.black) end local btnW = 32 local btnH = 5 local gap = 6 local totalW = btnW * 2 + gap local startX = math.floor((W - totalW) / 2) local y = 14 drawButton(startX, y, btnW, btnH, "CANCEL", colors.lime, colors.black) addHit("CONFIRM_CANCEL", startX, y, btnW, btnH) if confirmMode == "exit" then drawButton(startX + btnW + gap, y, btnW, btnH, "EXIT - CLEAR BETS", colors.red, colors.white) addHit("CONFIRM_YES", startX + btnW + gap, y, btnW, btnH) elseif confirmMode == "cashout" then drawButton(startX + btnW + gap, y, btnW, btnH, "CASH OUT ALL", colors.yellow, colors.black) addHit("CONFIRM_YES", startX + btnW + gap, y, btnW, btnH) end end local function drawAll() if confirmMode then drawConfirmScreen() return end resetHitBoxes() drawFrame() drawWheel() drawInfoPanel() drawTable() drawBottomBetControls() end -------------------------------------------------- -- SPIN LOGIC -------------------------------------------------- local function pickResult() return wheelOrder[math.random(1, #wheelOrder)] end local function findWheelIndex(num) for i, n in ipairs(wheelOrder) do if n == num then return i end end return 1 end local function spinRoulette() if spinning then return end if totalBets() <= 0 then message = "Place at least 1 diamond bet first." soundLoss() drawAll() return end spinning = true message = "Spinning..." drawAll() local result = pickResult() local targetIndex = findWheelIndex(result) for step = 1, SPIN_STEPS do wheelHighlightIndex = ((wheelHighlightIndex) % #wheelOrder) + 1 soundSpin() drawAll() local t = step / SPIN_STEPS local delay = SPIN_DELAY_START + (SPIN_DELAY_END - SPIN_DELAY_START) * t * t sleep(delay) end wheelHighlightIndex = targetIndex lastResult = result local payout, winningBets = resolvePayout(result) local unbetCredits = availableCredits() if payout > 0 then message = "Result " .. result .. "! WIN pays " .. payout .. " diamonds." drawAll() soundWin() local enough = pullDiamondsFromAboveUntil(payout) if enough then local ok, dropped = dropDiamondsDown(payout) if ok then message = "Paid " .. dropped .. " diamonds below. Result: " .. result else message = "Payout blocked! Dropped " .. dropped .. "/" .. payout end else local available = countDiamonds() local ok, dropped = dropDiamondsDown(available) message = "HOUSE EMPTY! Paid only " .. dropped .. "/" .. payout .. " diamonds." end else message = "Result " .. result .. ". No winning bets." soundLoss() end local after = countDiamonds() if payout > 0 then bankBase = after - unbetCredits if bankBase < 0 then bankBase = 0 end else bankBase = bankBase + totalBets() end bets = {} saveBankBase() spinning = false drawAll() end -------------------------------------------------- -- INPUT -------------------------------------------------- local function handleConfirmTouch(x, y) for _, box in ipairs(hitBoxes) do if inBox(x, y, box) then if box.id == "CONFIRM_CANCEL" then confirmMode = nil message = "Action cancelled." soundClick() drawAll() return true elseif box.id == "CONFIRM_YES" then if confirmMode == "exit" then bets = {} confirmMode = nil saveBankBase() exitToMenuNow() return true elseif confirmMode == "cashout" then bets = {} confirmMode = nil saveBankBase() cashOutCredits() drawAll() return true end end end end return false end local function handleTouch(x, y) if confirmMode then handleConfirmTouch(x, y) return end if spinning then return end for _, box in ipairs(hitBoxes) do if inBox(x, y, box) then if box.id == "ACTION:START" then spinRoulette() return elseif box.id == "ACTION:CLEAR" then clearBets() drawAll() return elseif box.id == "ACTION:EXIT" then requestExit() drawAll() return elseif box.id == "ACTION:CASHOUT" then requestCashOut() drawAll() return elseif box.id == "BETAMT:+1" then changeBetAmount(1) drawAll() return elseif box.id == "BETAMT:+5" then changeBetAmount(5) drawAll() return elseif box.id == "BETAMT:+10" then changeBetAmount(10) drawAll() return elseif box.id == "BETAMT:-1" then changeBetAmount(-1) drawAll() return elseif box.id == "BETAMT:-5" then changeBetAmount(-5) drawAll() return elseif box.id == "BETAMT:-10" then changeBetAmount(-10) drawAll() return elseif box.id == "BETAMT:RESET" then resetBetAmount() drawAll() return else addBet(box.id) drawAll() return end end end end -------------------------------------------------- -- MAIN -------------------------------------------------- drawAll() while true do local e, side, x, y = os.pullEvent() if e == "monitor_touch" then handleTouch(x, y) elseif e == "peripheral" or e == "peripheral_detach" then drawAll() end end