Bots Home
|
Create an App
Roll The Dice Free Edition
Author:
zingknaat
Description
Source Code
Launch Bot
Current Users
Created by:
Zingknaat
/** * App: Roll The Dice Free Edition * Version: 1.00 * Author: zingknaat * Date: 01.14.14 */ cb.settings_choices = [ {name: 'notice_wait_time', type: 'choice', label: 'Notification Time (in minutes)', choice1: 1, choice2: 2, choice3: 3, choice4: 4, choice5: 5, choice6: 10, choice7: 15, choice8: 20, choice9: 25, choice10: 30, choice11: 45, choice12: 60, defaultValue: 10}, {name: 'prize_2', type: 'str', label: 'If the outcome is 2, what will you do?'}, {name: 'prize_3', type: 'str', label: 'If the outcome is 3, what will you do?'}, {name: 'prize_4', type: 'str', label: 'If the outcome is 4, what will you do?'}, {name: 'prize_5', type: 'str', label: 'If the outcome is 5, what will you do?'}, {name: 'prize_6', type: 'str', label: 'If the outcome is 6, what will you do?'}, {name: 'prize_7', type: 'str', label: 'If the outcome is 7, what will you do?'}, {name: 'prize_8', type: 'str', label: 'If the outcome is 8, what will you do?'}, {name: 'prize_9', type: 'str', label: 'If the outcome is 9, what will you do?'}, {name: 'prize_10', type: 'str', label: 'If the outcome is 10, what will you do?'}, {name: 'prize_11', type: 'str', label: 'If the outcome is 11, what will you do?'}, {name: 'prize_12', type: 'str', label: 'If the outcome is 12, what will you do?'}, {name: 'prize_13', type: 'str', label: 'If the outcome is 13 (very rare), what will you do?'} ]; var langTokens = (cb.settings.tokens > 1) ? 'tokens' : 'token'; var dice = Array(1, 2, 3, 4, 5, 6); var lastPrizeWon = '--'; var rollCounter = 0; var winners = Array(); cb.onEnter(function (user) { var notices = ""; notices += "Welcome, " + user['user'] + "! We are playing Roll The Dice (free edition). \n"; notices += "Each roll reveals a prize. There are 12 possible prizes. \n"; notices += "Type /roll to roll the dice. \n"; notices += "Type /prizes to see the possible prizes. \n"; notices += "Type /winners to see a list of the last 20 winners."; cb.sendNotice(notices, user['user'], '', '#6B6BB2', 'bold'); }); cb.onMessage(function(msg) { if(msg['m'].match(/\/winners/i)) { msg['X-Spam'] = true; showPrizesWon(msg['user']); } if(msg['m'].match(/\/prizes/i)) { msg['X-Spam'] = true; showPrizes(msg['user']); } if(msg['m'].match(/\/roll/i)) { msg['X-Spam'] = true; roll(msg['user']); } return msg; }); function roll(username) { rollCounter++; var notices = ""; var dice1 = dice[Math.floor(Math.random() * dice.length)]; var dice2 = dice[Math.floor(Math.random() * dice.length)]; if (rollCounter%5 == 0) { if((dice1 == 1) && (dice2 != 1)) { dice1 = 7; } if((dice2 == 1) && (dice1 != 1)) { dice2 = 7; } } var total = dice1 + dice2; var prize = cb.settings['prize_' + total]; notices += ":diceresult" + dice1 + " :diceresult" + dice2 + "\n"; notices += "The outcome is " + total + "! \n"; notices += username + "'s prize: " + prize; cb.sendNotice(notices, '', '#CCFFCC', '#000000', 'bold'); lastPrizeWon = prize; winners.push(username + ' won: ' + prize); cb.drawPanel(); } function showPrizes(username) { var notices = ""; notices += "\n***** POSSIBLE PRIZES ***** \n"; var rareText = ""; for(var i=2;i<=13;i++){ if(i==13) rareText = " (VERY RARE)"; notices += "Dice outcome is " + i + rareText + ": " + cb.settings['prize_' + i] + "\n"; } cb.sendNotice(notices, username, '#F0FAFF'); } function showPrizesWon(username) { winners.reverse(); var notices = "\n**** LAST 20 WINNERS ****\n"; if(winners.length == 0) { cb.sendNotice('No one has won anything yet. Roll the dice to win a prize!', username, '', '', 'bold'); } else { winners.slice(0,20); var prizeNum = 1; for(var i=0; i<winners.length;i++) { notices += prizeNum + ") " + winners[i] + " \n"; prizeNum++; } cb.sendNotice(notices, username, '#CCFF99', '', 'bold'); } } function advertise() { var notices = "Roll The Dice (free edition) by zingknaat \n"; notices += "Each roll reveals a prize. There are 12 possible prizes. \n"; notices += "Type /roll to roll the dice. \n"; notices += "Type /prizes to see the possible prizes. \n"; notices += "Type /winners to see a list of the last 20 winners.\n"; cb.sendNotice(notices, '', '', '#6B6BB2'); cb.setTimeout(advertise, cb.settings.notice_wait_time * 60000); } function init() { advertise(); cb.changeRoomSubject('Roll the dice to reveal a prize for free!'); } init();
© Copyright Chaturbate 2011- 2026. All Rights Reserved.