Apps Home
|
Create an App
Lucky Number Game Improved
Author:
test01
Description
Source Code
Launch App
Current Users
Created by:
Test01
//LUCKY NUMBER BOT MADE BY thynameislisterofsmeg :) //Please do not use this source code for learning Chaturbate's app/bot syntax if you aren't familiar with ternary operators - this code makes heavy use of it. //If you wish to make a app/bot request, feel free to email me at "ricksanchez03312@gmail.com" :) var broadcaster = cb.room_slug; var guessed = false; var guessBoard = []; //USER-DEFINED VALUES cb.settings_choices = [ {name:'luckyNumberMin', type:'int', defaultValue: 1, minValue: 1, maxValue: 249, label: 'Minimum'}, {name:'luckyNumberMax', type:'int', defaultValue: 100, maxValue: 250, minValue: 2, label: 'Maximum'}, {name:'luckyNumber', type:'int', defaultValue: 100, minValue: 1, maxValue: 250, label: 'Lucky Number'}, {name:'luckyNumberPrize', type:'str', label: 'Lucky Number Prize'}, {name:'noticeBgColour', type:'str', defaultValue: '#FFFFFF', label: 'Notifier Background Colour (HEX)'}, {name:'noticeFgColour', type:'str', defaultValue: '#000000', label: 'Notifier Text Colour (HEX)'}, {name:'boardNotifierFreq', type:'int', defaultValue: 120, label: 'Frequency at which to show the guess board (seconds)'}]; function dispBoard(users){ cb.sendNotice("Lucky Number Board:",users,cb.settings.noticeBgColour,cb.settings.noticeFgColour,"bolder"); cb.sendNotice(guessBoard.join(" \u2605"),users,cb.settings.noticeBgColour,cb.settings.noticeFgColour,"bold"); cb.sendNotice("Prize: " + cb.settings.luckyNumberPrize,users,cb.settings.noticeBgColour,cb.settings.noticeFgColour,"bold") cb.sendNotice("Type !luckyboard to see the lucky number board!",users,cb.settings.noticeBgColour,cb.settings.noticeFgColour,"bolder"); } function dispGen(){ for(var i = cb.settings.luckyNumberMin; i < cb.settings.luckyNumberMax+1; i++) { guessBoard.push(" " + i.toString());} dispBoard(""); } dispGen(); function notifier() { if(!guessed) { dispBoard(); cb.setTimeout(notifier, cb.settings.boardNotifierFreq*1000);} else { null; } } cb.setTimeout(notifier, cb.settings.boardNotifierFreq*1000); //ERROR MESSAGES var error = false; cb.settings.luckyNumberMin > cb.settings.luckyNumberMax ? (cb.sendNotice("ERROR: Your minimum value is greater than you maximum value! \n Your minimum value must be less than your maximum value!", broadcaster,"#000000","#eb4034","bolder"), error=true) : null; cb.settings.luckyNumber > cb.settings.luckyNumberMax ? (cb.sendNotice("ERROR: Your lucky number is greater than you maximum value! \n Your lucky number must be less than or equal your maximum value!", broadcaster,"#000000","#eb4034","bolder"), error=true) : null; cb.settings.luckyNumber < cb.settings.luckyNumberMin ? (cb.sendNotice("ERROR: Your lucky number is less than your minimum value! \n Your lucky number must be greater than or equal to your minimum value!", broadcaster,"#000000","#eb4034","bolder"), error=true) : null; cb.settings.luckyNumberMax == cb.settings.luckyNumberMin ? (cb.sendNotice("ERROR: Your maximum value is the same as your minimum value! \n There must be a difference of atleast 1 between your minimum and maximum values!", broadcaster,"#000000","#eb4034","bolder"), error=true) : null; error == true ? cb.sendNotice("The bot will not work with the current parameters! \n Please restart the bot with the correct parameters!",broadcaster,"","#eb4034","bold") : null; cb.onMessage(function (msg) { if (msg['m'] == '!luckyboard') { msg['X-Spam'] = true; dispBoard(msg['user']); } return msg; }); if(!error){ function luckyExec(query,tip){ if(query){ //User correctly tipped lucky number cb.sendNotice(tip['from_user'] + " has tipped " + tip['amount'] + " tokens!","", cb.settings.noticeBgColour,cb.settings.noticeFgColour,"bold"); cb.sendNotice(tip['from_user'] + " correctly tipped the lucky number, " + cb.settings.luckyNumber + "!","","","",'bolder'); cb.sendNotice(tip['from_user'] + " has won the prize: " + cb.settings.luckyNumberPrize + "!","", cb.settings.noticeBgColour,cb.settings.noticeFgColour,"bold"); cb.sendNotice("FOR BROADCASTER: A user has guessed the lucky number. If you wish to start a new game, please deactivate, then restart the bot in your apps and bots panel.",broadcaster,"#000000","#FFFFFF","bold"); guessed = true; } else { cb.sendNotice("Sorry, " + tip['from_user'] + ", that wasn't the lucky number!","",cb.settings.noticeBgColour,cb.settings.noticeFgColour,'bolder'); guessBoard[tip['amount']-1] = "--"; } } var total_tipped = 0; cb.onTip(function (tip) { if(!guessed){ luckyExec((tip['amount'] == cb.settings.luckyNumber) ? true : false, tip); } else { null; } //cb.sendNotice(tip['from_user'] + " has tipped " + tip['amount'] + " tokens!","", cb.settings.noticecb.settings.noticeBgColour,cb.settings.noticeBgColour,"bold"); //dispBoard(); }); }
© Copyright Chaturbate 2011- 2024. All Rights Reserved.