Bots Home
|
Create an App
Roll the Dice SL
Author:
romeo_john
Description
Source Code
Launch Bot
Current Users
Created by:
Romeo_John
/* #################################################################################################### App: Roll the Dice Author: romeo_john Version: 1.1.0 Credits: zingknaat, milo_bloom, tablesalt90, kingchris_, bye_bye_beautiful #################################################################################################### Summary: Tip to roll the dice and receive a prize. You set the prizes and cost per roll. #################################################################################################### Description: Custom version of "Roll the dice 2.0" by bye_bye_beautiful. <strong>How it Works:</strong> User tips the amount you chose in the settings and the app will roll the dice. Each roll will result in a prize. You may choose to repeat the prizes or remove them once they have been received. If you choose the traditional dice, there will be 13 possible prizes. The Chinese dice option will give you 21 possible prizes for your viewers. <strong>Commands:</strong> !prizes - List all available prizes !prizes all - Show list of prizes to all (mod/broadcaster only) #################################################################################################### */ cb.settings_choices = [ { name: 'theme', type: 'choice', label: 'Theme: ', choice1: 'Pink / Diamonds', choice2: 'Blue / Diamonds', defaultValue: 'Pink / Diamonds' }, { name: 'fontweight', type: 'choice', label: 'Font weight: ', choice1: 'normal', choice2: 'bold', choice3: 'bolder', defaultValue: 'normal' }, { name: 'tokens', type: 'int', minValue: 1, label: 'How much do you want to charge per roll?', defaultValue: 25 }, { name: 'remove_winning_prize', type: 'choice', label: 'Remove prize from list after each roll?', choice1: 'Yes', choice2: 'No', defaultValue: 'No' }, { name: 'die_type', type: 'choice', label: 'Use Traditional (6-sided) or Chinese (10-sided) dice? (NOTE: If you choose the ' + 'Chinese die, please set all of the 21 prizes. Otherwise, just set the first 13.)', choice1: 'Traditional', choice2: 'Chinese', defaultValue: 'Traditional' }, { name: 'multirolls', type: 'int', minValue: 1, label: 'What is the maximum number of rolls you want a user to be able to make in a single tip? (set to 1 to disable) Example: If you set this to 3 and you charge 33 tokens per roll, a user could tip 66 for 2 rolls or 99 for 3 rolls.', defaultValue: 1 }, { name: 'too_high_multiples', type: 'choice', label: 'What shall happen if a user tips an amount that is a multiple of the roll price but would result in more rolls at once than allowed?', choice1: 'Roll the dice as often as allowed', choice2: 'Do not roll the dice at all', defaultValue: 'Do not roll the dice at all' }, { name: 'minimum_rolls', type: 'int', minValue: 0, maxValue: 50, label: 'What is the minimum number of rolls before the rare die can appear? (Will be displayed if not 0)', defaultValue: 5 }, { name: 'notice_wait_time', type: 'choice', label: 'In minutes, how often should the app advertise itself?', choice1: 5, choice2: 6, choice3: 7, choice4: 8, choice5: 9, choice6: 10, choice7: 15, choice8: 20, choice9: 25, choice10: 30, choice11: 45, choice12: 60, defaultValue: 7 }, { name: 'change_room_subject', type: 'choice', label: 'Change room subject when using this bot?', choice1: 'Yes', choice2: 'No', defaultValue: 'No' }, {name: 'prize_1', type: 'str', label: 'Prize for rolling 1', defaultValue: 'dance'}, {name: 'prize_2', type: 'str', label: 'Prize for rolling 2', defaultValue: 'dance (you choose song)'}, {name: 'prize_3', type: 'str', label: 'Prize for rolling 3', defaultValue: 'flash boobs'}, {name: 'prize_4', type: 'str', label: 'Prize for rolling 4', defaultValue: 'flash pussy'}, {name: 'prize_5', type: 'str', label: 'Prize for rolling 5', defaultValue: 'flash butt'}, {name: 'prize_6', type: 'str', label: 'Prize for rolling 6', defaultValue: 'flash (you choose what)'}, {name: 'prize_7', type: 'str', label: 'Prize for rolling 7', defaultValue: 'suck nipples'}, {name: 'prize_8', type: 'str', label: 'Prize for rolling 8', defaultValue: 'pussy close up'}, {name: 'prize_9', type: 'str', label: 'Prize for rolling 9', defaultValue: 'camel toe'}, {name: 'prize_10', type: 'str', label: 'Prize for rolling 10', defaultValue: 'spank butt'}, {name: 'prize_11', type: 'str', label: 'Prize for rolling 11', defaultValue: 'spank butt both hands'}, {name: 'prize_12', type: 'str', label: 'Prize for rolling 12', defaultValue: 'spank pussy'}, {name: 'prize_13', type: 'str', label: 'Prize for rolling 13 (RARE if using traditional dice)', defaultValue: 'finger pussy 10 mins'}, {name: 'prize_14', type: 'str', label: 'Prize for rolling 14 (only shown if using Chinese dice)', defaultValue: '.'}, {name: 'prize_15', type: 'str', label: 'Prize for rolling 15 (only shown if using Chinese dice)', defaultValue: '.'}, {name: 'prize_16', type: 'str', label: 'Prize for rolling 16 (only shown if using Chinese dice)', defaultValue: '.'}, {name: 'prize_17', type: 'str', label: 'Prize for rolling 17 (only shown if using Chinese dice)', defaultValue: '.'}, {name: 'prize_18', type: 'str', label: 'Prize for rolling 18 (only shown if using Chinese dice)', defaultValue: '.'}, {name: 'prize_19', type: 'str', label: 'Prize for rolling 19 (only shown if using Chinese dice)', defaultValue: '.'}, {name: 'prize_20', type: 'str', label: 'Prize for rolling 20 (only shown if using Chinese dice)', defaultValue: '.'}, {name: 'prize_21', type: 'str', label: 'Prize for rolling 21 (RARE if using Chinese dice)', defaultValue: '.'} ]; var price = cb.settings.tokens; var langTokens = (price > 1) ? 'tokens' : 'token'; var numberOfSides = (cb.settings.die_type == 'Traditional') ? 6 : 10; var multiRolls = cb.settings.multirolls; var lastRoller = '--'; var lastPrizeWon = '--'; var rollCounter = 0; var prizes = []; var minimumRollsToGetRareDice = parseInt(cb.settings.minimum_rolls); var maxOutcome = (cb.settings.die_type == 'Traditional') ? 13 : 21; var dieImagePrefix = (cb.settings.die_type == 'Traditional') ? ':reddie' : ':cdie'; var rareChance = 10; // percent chance of rolling a RARE (minimum rolls must also be met) var total_tokens = 0; var bg, font_size, font_weight, font_colour, light_colour, dark_colour; if (cb.settings.theme == "Blue / Diamonds") { bg = "739b41f6-4436-417e-8790-ae8b4ff3e9c6"; font_size = 11; font_weight = cb.settings.fontweight; font_colour = "#6fd1ff"; light_colour = "#b8e6fb"; dark_colour = "#156285"; } else { bg = "b728ab20-6ae7-41ac-b593-acd2bbfed762"; font_size = 11; font_weight = cb.settings.fontweight; font_colour = "maroon"; light_colour = '#F8D6E8'; dark_colour = '#E9438A'; } cb.onTip(function (tip) { var tipAmount = parseInt(tip['amount']); // check to see if tip was for a dice roll if (tipAmount >= price && (tipAmount % price == 0)) { var numberOfRolls = Math.floor(tipAmount / price); if (numberOfRolls > multiRolls) { if (cb.settings.too_high_multiples == 'Roll the dice as often as allowed'){ numberOfRolls = multiRolls; } else { numberOfRolls = 0; } } for (var i = 0; i < numberOfRolls; i++) { total_tokens += price; roll(tip['from_user']); lastRoller = tip['from_user']; } } }); cb.onDrawPanel(function (user) { var roll_counter_time_text = rollCounter == 1 ? "time" : "times"; // rollCounter = 5; // lastPrizeWon = "Doggystyle in panties"; // lastRoller = "kjhjksdh_sdhks1234444"; return { "template": "image_template", "layers": [ {'type': 'image', 'fileID': bg}, { 'type': 'text', 'text': 'Last prize won:', 'top': 5, 'left': 49, 'font-size': font_size, 'font-weight': font_weight, 'color': font_colour, }, { 'type': 'text', 'text': 'Last player:', 'top': 27, 'left': 66, 'font-size': font_size, 'font-weight': font_weight, 'color': font_colour, }, { 'type': 'text', 'text': 'Rolled ' + rollCounter + ' ' + roll_counter_time_text + " | Tokens received: " + total_tokens, 'top': 51, 'left': 54, 'font-size': font_size, 'font-weight': font_weight, 'color': font_colour, }, { 'type': 'text', 'text': lastPrizeWon, 'top': 5, 'left': 134, 'font-size': font_size, 'font-weight': font_weight, 'color': font_colour, }, { 'type': 'text', 'text': lastRoller, 'top': 27, 'left': 134, 'font-size': font_size, 'font-weight': font_weight, 'color': font_colour, } ], }; }); cb.onEnter(function (user) { showAppAd(user['user']); }); cb.onMessage(function (msg) { if (msg['m'].match(/!prizes/i)) { msg['X-Spam'] = true; if (msg['m'].match(/all/i) && ((msg['is_mod'] == true) || (msg['user'] == cb.room_slug))) { showPrizes(); } else { showPrizes(msg['user']); } } return msg; }); function roll(username) { rollCounter++; var die1 = Math.floor(Math.random() * numberOfSides) + 1; var die2 = Math.floor(Math.random() * numberOfSides) + 1; // see if there's a chance we can roll a rare die if (rollCounter > minimumRollsToGetRareDice) { if (Math.random() <= (rareChance / 100)) { die1 = 7; } } var total = die1 + die2; var winner = false; if (total >= 1) { winner = true; var prize = cb.settings['prize_' + total]; } else { winner = false; var prize = 'A Thank You!'; } var rareText = ''; if (total == maxOutcome) rareText = " (RARE)"; var prizeIndex = prizes.indexOf(prize + rareText); if (prizeIndex >= 0) { if (cb.settings.remove_winning_prize == 'Yes') prizes.splice(prizeIndex, 1); } else { prize = 'A Thank You!'; } var msg = dieImagePrefix + die1 + " " + dieImagePrefix + die2 + "\n"; msg += username + " rolled a " + total + "!".toUpperCase(); cb.sendNotice(msg, '', light_colour, dark_colour, font_weight); msg = "Roll #" + rollCounter + " | Prize: " + prize; var textColor = light_colour; var bgColor = dark_colour; if (total == maxOutcome) { bgColor = light_colour; textColor = dark_colour; } cb.sendNotice(msg, '', bgColor, textColor, font_weight); lastPrizeWon = prize; cb.drawPanel(); } function setPrizes() { var rareText = ''; for (var i = 1; i <= maxOutcome; i++) { if (i == maxOutcome) rareText = " (RARE)"; prizes.push(cb.settings['prize_' + i] + rareText); } } function showPrizes(username) { if (prizes.length) { var rareText = ''; var msg = "##### POSSIBLE PRIZES #####"; for (var i = 1; i <= maxOutcome; i++) { if (i == maxOutcome) rareText = " (RARE)"; if (prizes.indexOf(cb.settings['prize_' + i] + rareText) >= 0) msg += "\nRoll " + i + " - " + cb.settings['prize_' + i] + rareText; } } else { var msg = "SORRY! There are no prizes left in the list, but thank you for the tip. :thumbsup"; } if (rollCounter < minimumRollsToGetRareDice) { if ((minimumRollsToGetRareDice - rollCounter) == 1) { msg += "\nOnly 1 roll until the rare die can appear." } else { msg += "\n" + (minimumRollsToGetRareDice - rollCounter) + " rolls until the rare die can appear." } } cb.sendNotice(msg, username, light_colour, dark_colour, font_weight); } function advertise() { showAppAd(); cb.setTimeout(advertise, parseInt(cb.settings.notice_wait_time) * 60000); } function showAppAd(username) { var msg = ""; var dicechar = ':unicode_dice'; msg += dicechar + " We are playing Roll the Dice!!! " + dicechar + " \n"; msg += "Each roll reveals one of " + prizes.length + " possible prizes.\n"; if (cb.settings.remove_winning_prize == 'Yes') { msg += "Each prize won will be removed from the list.\n"; } msg += "Tip " + price + " " + langTokens + " to roll the dice. \n"; if (multiRolls > 1) msg += "You can roll a maximum of " + multiRolls + " times in a single tip (" + (multiRolls*price) + " tokens). \n"; msg += "Type \"!prizes\" to see the list of prizes. \n"; msg += "Type \"!prizes all\" to send the list to all viewers if you're a mod or the broadcaster."; cb.sendNotice(msg, username, '', dark_colour, font_weight); } function init() { setPrizes(); advertise(); if (cb.settings.change_room_subject == 'Yes') { cb.changeRoomSubject('Tip ' + price + ' ' + langTokens + ' to roll the dice and win a prize!'); } } init();
© Copyright Chaturbate 2011- 2026. All Rights Reserved.