Apps Home
|
My Uploads
|
Create an App
MyKinkyBunny's Roll The Dice
Author:
dickavatar
Description
Source Code
Launch App
Current Users
Created by:
Dickavatar
App Images
/** * MyKinkyBunny's Roll The Dice v1.0.1 * By: Dick Avatar * Date: 20202-04-19 * * V 1.0.1 * - Can select an image for the chat panel. * * V 1.0.0 * - Only roll the die if the tip amount is an exact multiple of the * cost to roll the dice * - Removed maxiumum tip value for a roll. * - Made changing the room subject optional. * * Original App: Roll The Dice w/ hashtags in subject * Version: 2.0.5 * Original Author: zingknaat * Modified by: cdhinch * Date: 2018-04-29 * */ const VERSION = '1.0.1' const broadcaster = cb.room_slug const background = { eyes:'985975bc-6224-4987-bb23-f15d0ac30373', boobs: '086bf833-fd94-496c-ad5a-f451cecab6ac', lips: 'c261737e-a08b-48f9-8822-8eb2a42cb61d' } var selectedBackgroundImage var fontColor = 'orange' var fontWeight = 'bold' cb.settings_choices = [ { name: 'tokens', type: 'int', minValue: 1, maxValue: 100, 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: 'change_subject', type: 'choice', label: "Should I set the room subject for you?", choice1: 'Yes', choice2: 'No', defaultValue: 'Yes' }, { name: 'subject_suffix', type: 'str', default: '#rollthedice', label: 'Hashtags to be appended to the Subject line (Separate tags with a space.)' }, { name: 'background', type:'choice', label:"Image to use for the panel background.", choice1: 'None', choice2: 'Boobs', choice3: 'Lips', choice4: 'Eyes', default: 'Lips' }, { name: 'die_type', type: 'choice', label: 'Use traditional (6-sided) or Chinese (10-sided) die? (NOTE: If you choose the ' + 'Chinese die, please set all of the 21 prizes. Otherwise, just set the first 13.)', choice1: 'Traditional', choice2: 'Chinese', default: 'Traditional' }, { name: 'minimum_rolls', type: 'choice', label: 'What is the minimum number of rolls before the rare dice can appear? (Keep this a secret!)', choice1: 10, choice2: 15, choice3: 20, choice4: 25, choice5: 30, choice6: 35, choice7: 40, choice8: 45, choice9: 50, defaultValue: 10 }, { name: 'notice_wait_time', type: 'choice', label: 'In minutes, how often should the app advertise itself?', choice1: 5, choice2: 10, choice3: 15, choice4: 20, choice5: 25, choice6: 30, choice7: 45, choice8: 60, defaultValue: 10 }, {name: 'prize_1', type: 'str', label: 'Prize for rolling 1', default:'flash tits'}, {name: 'prize_2', type: 'str', label: 'Prize for rolling 2', default:'A kiss'}, {name: 'prize_3', type: 'str', label: 'Prize for rolling 3', default:'flash ass'}, {name: 'prize_4', type: 'str', label: 'Prize for rolling 4', default:'3 spnks'}, {name: 'prize_5', type: 'str', label: 'Prize for rolling 5', default:'flash feet'}, {name: 'prize_6', type: 'str', label: 'Prize for rolling 6', default:'flash pussy'}, {name: 'prize_7', type: 'str', label: 'Prize for rolling 7', default:'dance'}, {name: 'prize_8', type: 'str', label: 'Prize for rolling 8', default:'flash tongue'}, {name: 'prize_9', type: 'str', label: 'Prize for rolling 9', default:'ahego face'}, {name: 'prize_10', type: 'str', label: 'Prize for rolling 10', default:'tease legs'}, {name: 'prize_11', type: 'str', label: 'Prize for rolling 11', default:'doggy style'}, {name: 'prize_12', type: 'str', label: 'Prize for rolling 12', default:'A kiss'}, { name: 'prize_13', type: 'str', default: 'flash tits', label: 'Prize for rolling 13 (RARE if using traditional dice)' }, { name: 'prize_14', type: 'str', default: 'flash pussy', label: 'Prize for rolling 14 (only shown if using Chinese dice)' }, { name: 'prize_15', type: 'str', default: 'flash tongue', label: 'Prize for rolling 15 (only shown if using Chinese dice)' }, { name: 'prize_16', type: 'str', default: 'flash ass', label: 'Prize for rolling 16 (only shown if using Chinese dice)' }, { name: 'prize_17', type: 'str', default: 'flash feet', label: 'Prize for rolling 17 (only shown if using Chinese dice)' }, { name: 'prize_18', type: 'str', default: 'flash tongue', label: 'Prize for rolling 18 (only shown if using Chinese dice)' }, { name: 'prize_19', type: 'str', default: 'tease legs', label: 'Prize for rolling 19 (only shown if using Chinese dice)' }, { name: 'prize_20', type: 'str', default: '5 spanks', label: 'Prize for rolling 20 (only shown if using Chinese dice)' }, { name: 'prize_21', type: 'str', default: 'A smile', label: 'Prize for rolling 21 (RARE; only shown if using Chinese dice)' } ]; var langTokens = (cb.settings.tokens > 1) ? 'tokens' : 'token'; var numberOfSides = (cb.settings.die_type == 'Traditional') ? 6 : 10; var lastRoller = '--'; var lastPrizeWon = '--'; var rollCounter = 0; var tipCounter = 0; var winners = []; 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 subject_suffix = cb.settings['subject_suffix']; cb.onTip(function (tip) { var tipAmount = parseInt(tip['amount']); tipCounter += tipAmount; if (tipAmount >= cb.settings.tokens && (tipAmount % cb.settings.tokens === 0)) { var numberOfRolls = Math.floor(tipAmount / cb.settings.tokens); for (var i = 0; i < numberOfRolls; i++) { roll(tip['from_user']); lastRoller = tip['from_user']; } } else { cb.drawPanel(); } }); cb.onDrawPanel(onDrawPanel) function onDrawPanel(user) { cb.log("Drawing panel.") function defaultPanel() { return { 'template': '3_rows_12_22_31', 'row1_label': 'Last prize won:', 'row1_value': lastPrizeWon, 'row2_label': 'Last player:', 'row2_value': lastRoller, 'row3_value': tipCounter + ' ' + langTokens + ' received / rolled ' + rollCounter + ' time(s)' }; } if (selectedBackgroundImage === 'none') { cb.log("No selectedBackgroundImage.") return defaultPanel() } if (user.user === '') { cb.log('Anonymous user') return defaultPanel() } // var image = background[cb.settings.background.toLowerCase()] // if (image === undefined) { // cb.log("Error: no such image has been defined: " + cb.settings.background) // return defaultPanel() // } if (selectedBackgroundImage === undefined) { cb.log("selectedBackgroundImage was undefined.") selectedBackgroundImage = background.lips } return { "template": "image_template", "layers": [ {'type': 'image', 'fileID': selectedBackgroundImage}, { 'type': 'text', 'text': 'Last prize won', 'top': 6, 'left': 52, 'color': 'black', 'font-weight': fontWeight }, { 'type': 'text', 'text': 'Last prize won', 'top': 5, 'left': 51, 'color': fontColor, 'font-weight': fontWeight }, { 'type': 'text', 'text': 'Last player', 'top': 30, 'left': 74, 'color': 'black', 'font-weight': fontWeight }, { 'type': 'text', 'text': 'Last player', 'top': 29, 'left': 73, 'color': fontColor, 'font-weight': fontWeight }, { 'type': 'text', 'text': tipCounter + ' ' + langTokens + ' received / rolled ' + rollCounter + ' time(s)', 'top': 53, 'left': 29, 'color': 'black', 'font-weight': fontWeight }, { 'type': 'text', 'text': tipCounter + ' ' + langTokens + ' received / rolled ' + rollCounter + ' time(s)', 'top': 52, 'left': 28, 'color': fontColor, 'font-weight': fontWeight }, { 'type': 'text', 'text': lastPrizeWon, 'top': 6, 'left': 148, 'color': 'black', 'font-weight': fontWeight }, { 'type': 'text', 'text': lastPrizeWon, 'top': 5, 'left': 147, 'color': fontColor, 'font-weight': fontWeight }, { 'type': 'text', 'text': lastRoller, 'top': 30, 'left': 148, 'color': 'black', 'font-weight': fontWeight }, { 'type': 'text', 'text': lastRoller, 'top': 29, 'left': 147, 'color': fontColor, 'font-weight': fontWeight }, ], }; } cb.onEnter(function (user) { showAppAd(user['user']); }); cb.onMessage(onMessage); function onMessage(message) { let msg = message['m'].toLowerCase() if (msg === '/winners') { message['X-Spam'] = true; showPrizesWon(msg['user']); return message } else if (msg.startsWith('/prizes')) { message['X-Spam'] = true; if (msg === '/prizes all' && ((msg['is_mod'] == true) || (msg['user'] == broadcaster))) { showPrizes(); } else { showPrizes(msg['user']); } return message } if (message['user'] !== broadcaster) { return msg } var args = msg.split(' ') var command = args[0] var option = args[1] if (command === '/image') { message['X-Spam'] = true if (option === undefined) { notify(broadcaster, "USAGE: /image [eyes|boobs|lips]\nEXAMPE:\n/panel eyes") } else if (option === 'none') { selectedBackgroundImage = option notify(broadcaster, "Will not use a background image in the chat panel.") } else { var image = background[option] if (image === undefined) { notify(broadcaster,"Invalid image name.\nUSAGE: /panel [eyes|boobs|lips|none]\nEXAMPE:\n/panel eyes") } else { selectedBackgroundImage = image } } } else if (command === '/color') { message['X-Spam'] = true if (option === undefined) { notify(broadcaster, "USAGE: /color <color>\nEXAMPE: /font orange") } else { notify(broadcaster, "Setting font color to " + option) fontColor = option } } cb.drawPanel() return message } function notify(user, msg) { if (msg === undefined) { cb.log("Sending notice to broadcaster " + broadcaster) cb.sendNotice(msg, broadcaster, '#DBFBFF', '#008596', 'bold') } else { cb.log("Sending notice to user " + user) cb.sendNotice(msg, user, '#DBFBFF', '#008596', 'bold') } } function roll(username) { rollCounter++; var die1 = Math.floor(Math.random() * numberOfSides+1); var die2 = Math.floor(Math.random() * numberOfSides+1); // convoluted logic to appease the dev gods on cb var randomNum = Math.ceil(Math.random() * (100 - minimumRollsToGetRareDice) + minimumRollsToGetRareDice); if (rollCounter == randomNum) { if ((die1 == 1) && (die2 != 1)) die1 = (cb.settings.die_type == 'Traditional') ? 7 : 11; if ((die2 == 1) && (die1 != 1)) die2 = (cb.settings.die_type == 'Traditional') ? 7 : 11; } 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 prizeIndex = prizes.indexOf(prize); 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 + "! \n".toUpperCase(); msg += "Roll #" + rollCounter + " | Prize: " + prize; var textColor = '#000000'; var bgColor = '#D9FAD7'; if (winner) textColor = '#067D00'; if (total == maxOutcome) { bgColor = '#FFDBF3'; textColor = '#A805A6'; } cb.sendNotice(msg, '', bgColor, textColor, 'bold'); lastPrizeWon = prize; winners.push("Roll #" + rollCounter + " (" + total + "): " + username + " - " + prize); cb.drawPanel(); } function setPrizes() { var rareText = ''; for (var i = 1; i <= maxOutcome; i++) { if (i == maxOutcome) rareText = " (VERY 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 = " (VERY 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"; } cb.sendNotice(msg, username, '#DBFBFF', '#008596', 'bold'); } function showPrizesWon(username) { var msg = "##### LAST 40 WINNERS #####"; msg += "\nList sorted in chronological order"; if (winners.length == 0) { cb.sendNotice('No one has won anything yet. Roll the dice to win a prize!', username, '', '', 'bold'); } else { var recentWinners = winners.slice(-40); for (var i = 0; i < recentWinners.length; i++) msg += "\n" + recentWinners[i]; cb.sendNotice(msg, username, '#FFF0DE', '#8A4900', 'bold'); } } function advertise() { showAppAd(); cb.setTimeout(advertise, parseInt(cb.settings.notice_wait_time) * 60000); } function showAppAd(username) { var msg = ""; if (username != undefined) { msg += "Welcome, " + username + "! We are playing Roll The Dice.\n"; } else { msg += "Roll The Dice by zingknaat\nModified for MyKinkyBunny by Dick Avatar.\n"; } msg += "Each roll reveals a prize. There are " + prizes.length + " possible prizes.\n"; if (cb.settings.remove_winning_prize == 'Yes') { msg += "Each prize won will be removed from the list.\n"; } else { msg += "Each prize won will stay on the list.\n"; } msg += "Tip " + cb.settings.tokens + " " + langTokens + " to roll the dice. \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.\n"; msg += "Type \"/winners\" to see a list of the last 20 winners."; cb.sendNotice(msg, username, '', '#15A6B0', 'bold'); } function log(username, message) { } function init() { setPrizes(); advertise(); if (cb.settings.change_subject) { cb.changeRoomSubject('Tip ' + cb.settings.tokens + ' tokens to roll the dice! ' + cb.settings.subject_suffix); } if (cb.settings.background === 'None') { cb.log("cb.settings.background is set to None") selectedBackgroundImage = 'none' } else { cb.log("Using background image " + cb.settings.background) selectedBackgroundImage = background[cb.settings.background] } } init();
© Copyright Chaturbate 2011- 2025. All Rights Reserved.