Bots Home
|
Create an App
SC
Author:
itsme3
Description
Source Code
Launch Bot
Current Users
Created by:
Itsme3
/*a_quiet_guy Sep 2016*/ cb.settings_choices = [ { name: 'tokens', type: 'int', minValue: 1, maxValue: 100, label: 'How many tips per roll?', defaultValue: 25 }, { name: 'rare_dice', type: 'int', minValue: 0, maxValue: 255, label: 'How often can appear the third dice? 0 - Always / 255 - Never (Keep this a secret!)', defaultValue: 85 }, { name: 'notice_wait_time', type: 'choice', label: 'In minutes, how often should the app advertise itself? (0 means never)', choice1: 5, choice2: 10, choice3: 15, choice4: 20, choice5: 25, choice6: 30, choice7: 45, choice8: 0, defaultValue: 10 }, {name: 'prize_2', type: 'str', default: '', label: 'Prize for rolling 2', required: false}, {name: 'prize_3', type: 'str', default: '', label: 'Prize for rolling 3', required: false}, {name: 'prize_4', type: 'str', default: '', label: 'Prize for rolling 4', required: false}, {name: 'prize_5', type: 'str', default: '', label: 'Prize for rolling 5', required: false}, {name: 'prize_6', type: 'str', default: '', label: 'Prize for rolling 6', required: false}, {name: 'prize_7', type: 'str', default: '', label: 'Prize for rolling 7', required: false}, {name: 'prize_8', type: 'str', default: '', label: 'Prize for rolling 8', required: false}, {name: 'prize_9', type: 'str', default: '', label: 'Prize for rolling 9', required: false}, {name: 'prize_10', type: 'str', default: '', label: 'Prize for rolling 10', required: false}, {name: 'prize_11', type: 'str', default: '', label: 'Prize for rolling 11', required: false}, {name: 'prize_12', type: 'str', default: '', label: 'Prize for rolling 12', required: false}, { name: 'prize_12+', type: 'str', default: '', label: 'Prize for rolling 12+ (RARE)' } ]; var langTokens = (cb.settings.tokens > 1) ? 'tokens' : 'token'; var numberOfSides =6; var rollCounter = 0; var tipCounter = 0; var prizes = []; var RareDice = parseInt(cb.settings.rare_dice); var maxOutcome = 12; var dieImagePrefix = ':reddie'; cb.onTip(function (tip) { tipCounter += parseInt(tip['amount']); if (parseInt(tip['amount']) == cb.settings.tokens) { roll(tip['from_user']); } }); cb.onEnter(function (user) { showAppAd(user['user']); }); cb.onMessage(function (msg) { if (msg['m'].match(/\/prizes/i)) { msg['X-Spam'] = true; if ((msg['is_mod'] == true) || (msg['user'] == cb.room_slug)) { showPrizes(); } else { showPrizes(msg['user']); } } return msg; }); function roll(username) { rollCounter++; var die3 = 0; var die1 = Math.floor((Math.random() * numberOfSides) + 1); var die2 = Math.floor((Math.random() * numberOfSides) + 1); var msg = username + " rolled: \n"; if (rollCounter > RareDice || RareDice == 0) { if((Math.random() > 0.5 || RareDice == 0) && RareDice != 255) { var faces = Math.floor((Math.random() * numberOfSides) + 1); die3 = Math.floor((Math.random() * faces) + 1); rollCounter = 0; msg += dieImagePrefix + die1 + " " + dieImagePrefix + die2 + " " + dieImagePrefix + die3 + "\n"; }else{ msg += dieImagePrefix + die1 + " " + dieImagePrefix + die2 + "\n"; } }else{ msg += dieImagePrefix + die1 + " " + dieImagePrefix + die2 + "\n"; } var total = die1 + die2 + die3; var textColor = '#067D00'; var bgColor = '#D9FAD7'; if(total > 12){ var prize = cb.settings['prize_12+']; bgColor = '#FFDBF3'; textColor = '#A805A6'; if(prize != ''){ msg += "Prize is: " + prize; }else{ msg += "There is no prize for this number, try again!!"; bgColor = '##FFFFFF'; textColor = '#FF3F3F'; } }else{ var prize = cb.settings['prize_' + total]; if(prize != ''){ msg += "Prize is: " + prize; }else{ msg += "There is no prize for this number, try again!!"; bgColor = '##FFFFFF'; textColor = '#FF3F3F'; } } cb.sendNotice(msg, '', bgColor, textColor, 'bold'); } function setPrizes() { var rareText = ''; for (var i = 1; i <= maxOutcome; i++) { if (i == maxOutcome){ rareText = " (VERY RARE)"; prizes.push(cb.settings['prize_12+'] + rareText); }else{ prizes.push(cb.settings['prize_' + i] + rareText); } } } function showPrizes(username) { if (prizes.length) { var msg = "+++++ DICE GAME POSSIBLE PRIZES +++++"; for (var i = 1; i <= maxOutcome; i++) { var prize = cb.settings['prize_' + (i + 1)]; if (i == maxOutcome){ msg += "\nRoll 12+" + " - " + cb.settings['prize_12+'] + " (VERY RARE)"; }else{ if(prize != ''){ msg += "\nRoll " + (i + 1) + " - " + cb.settings['prize_' + (i + 1)]; } } } msg += "\n+++++ ++++ +++ +++ +++ ++++ +++++"; } else { var msg = "SORRY! There are no prizes left in the list, but thank you for the tip. :thumbsup"; } cb.sendNotice(msg, username, '#D9FAD7', '#067D00', 'normal'); } function advertise() { showAppAd(); if (parseInt(cb.settings.notice_wait_time) != 0) cb.setTimeout(advertise, parseInt(cb.settings.notice_wait_time) * 60000); } function showAppAd(username) { var msg = ""; if (username != undefined) { msg += "Hey " + username + ", We are playing Roll The Dice. \n"; } msg += "Each roll reveals a prize. There are " + prizes.length + " possible prizes. \n"; msg += "Tip " + cb.settings.tokens + " to roll the dice. \n"; msg += "Type \"/prizes\" to see the list of prizes. \n"; cb.sendNotice(msg, username, '#D9FAD7', '#067D00', 'normal'); } function init() { setPrizes(); advertise(); } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.