Apps Home
|
My Uploads
|
Create an App
-
Author:
anygalaxy
Description
Source Code
Launch App
Current Users
Created by:
Anygalaxy
App Images
//Variablen var lastRoller = '--'; var lastPrizeWon = '--'; var rollCounter = 0; var tipCounter = 0; var prizes = []; //Settings cb.settings_choices = [ { name: 'tokens', type: 'int', minValue: 1, maxValue: 100, label: 'Charge per roll (single tip)?', defaultValue: 25 }, { 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_2', type: 'str', label: 'Prize for rolling 2'}, {name: 'prize_3', type: 'str', label: 'Prize for rolling 3'}, {name: 'prize_4', type: 'str', label: 'Prize for rolling 4'}, {name: 'prize_5', type: 'str', label: 'Prize for rolling 5'}, {name: 'prize_6', type: 'str', label: 'Prize for rolling 6'}, {name: 'prize_7', type: 'str', label: 'Prize for rolling 7'}, {name: 'prize_8', type: 'str', label: 'Prize for rolling 8'}, {name: 'prize_9', type: 'str', label: 'Prize for rolling 9'}, {name: 'prize_10', type: 'str', label: 'Prize for rolling 10'}, {name: 'prize_11', type: 'str', label: 'Prize for rolling 11'}, {name: 'prize_12', type: 'str', label: 'Prize for rolling 12'}, ]; //CB Events cb.onTip(function (tip) { tipCounter += parseInt(tip['amount']); if (parseInt(tip['amount']) >= cb.settings.tokens) { for (var i = 1; i <= tip['amount'] / cb.settings.tokens; i++) { roll(tip['from_user']); } lastRoller = tip['from_user']; } cb.drawPanel(); }); 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; }); cb.onEnter(function (user) { showAppAd(user['user']); }); cb.onDrawPanel(function(user) { return { "template": "image_template", "layers": [ {'type': 'image', 'fileID': "9096a436-f06f-485e-94f4-56455878a064"}, { 'type': 'text', 'text': 'Last prize won:', 'left': 48, 'top': 5, //'font-family': 'cursive', 'font-size': 12, 'color': 'white', }, { 'type': 'text', 'text': lastPrizeWon, 'left': 150, 'top': 5, //'font-family': 'cursive', 'font-size': 12, 'color': 'white', }, { 'type': 'text', 'text': 'Last roller:', 'left': 70, 'top': 29, //'font-family': 'cursive', 'font-size': 12, 'color': 'white', }, { 'type': 'text', 'text': lastRoller, 'left': 150, 'top': 29, //'font-family': 'cursive', 'font-size': 12, 'color': 'white', }, { 'type': 'text', 'text': tipCounter + ' token(s)' + ' received / rolled ' + rollCounter + ' time(s)', 'top': 52, 'width': 270, //'font-family': 'cursive', 'text-align': 'center', 'font-size': 12, 'color': 'yellow', }, ], }; }); //Funktionen 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 += "We are playing Roll The Dice.\n"; } msg += "Tip " + cb.settings.tokens + " token(s) " + "to roll the dice.\n"; msg += "Type \"/prizes\" to see the list of prizes."; cb.sendNotice(msg+'\n', username, '', '#9b59b6', 'bold'); } function showPrizes(username) { var msg = "[*** POSSIBLE PRIZES ***]"; for (var i = 2; i <= 12; i++) { msg += "\nRoll " + i + " - " + cb.settings['prize_' + i]; } cb.sendNotice(msg+'\n', username, '#DBFBFF', '#3498db', 'bold'); } function roll(username) { rollCounter++; var die1 = Math.floor(Math.random() * 6+1); var die2 = Math.floor(Math.random() * 6+1); var total = die1 + die2; var prize = cb.settings['prize_' + total]; var msg = "[*** ROLL THE DICE ***]\n"; msg += ':reddie' + die1 + " " + ':reddie' + die2 + "\n"; msg += username + " rolled a " + total + "! \n".toUpperCase(); msg += "Roll #" + rollCounter + " | Prize: " + prize; cb.sendNotice(msg+'\n', '', '#e2ffdb', '#27ae60', 'bold'); lastPrizeWon = prize; cb.drawPanel(); } //Main function init() { for (var i = 2; i <= 12; i++) { prizes.push(cb.settings['prize_' + i]); } cb.drawPanel(); advertise(); } init();
© Copyright Chaturbate 2011- 2025. All Rights Reserved.