Bots Home
|
Create an App
LCG
Author:
lovin_cali_girl
Description
Source Code
Launch Bot
Current Users
Created by:
Lovin_Cali_Girl
/* This menu BOT does a few different things. 1. Provides the viewers a tip menu. When a viewer tips for an item on the menu, the broadcaster is notified who tipped, and what it was for. 2. Provides a recurring goal. As an example, let's say that every 100th token, the broadcaster will deliver a certain item. This feature tracks the progress of the recurring goal and displays the progress in the chat. If you as a broadcaster do not want a recurring goal, leave the goal text blank. 3. Provides the broadcaster the means to change the recurring goal item and cost of the item on the fly without having to restart the bot. 4. Provides the broadcaster the means to change the entire menu on the fly without having to restart the bot. 5. Provides the broadcaster the means to offer a promotional item to encourage viewers to continue tipping. A few good examples for promotional items would be Snapchat access, videos, or photo packs. Upon the viewer's first tip, they are notified that there is a "bonus" item that they can get if they tip X number of tokens before the end of the session. As the number of tokens reaches 50% of the configured value of the item, they are notified that they are half way to reveiving the bonus item. Once the user reaches 100% of the value of the bonus item, they are notified that they earned the item. Upon the user's first tip, they receive a message that says: 'By tipping [X] more tokens ([X] in total) before the end of the show, you will get [X] as a bonus.' tested at https://yyanx.github.io/CB-TestBed/ Special Commands for the Broadcaster: "!goal=" followed by a whole number will change of price of the repeating goal Sample Usage: !goal=500 "!goalitem=" followed by a short description will change the text of the repeating goal Sample Usage: !goalitem=Snapchat for life "!newmenu==" followed by AT LEAST two comma delimited price--item pairs will replace the entire menu on the fly Sample Usage: !newmenu==10--Soda,20--Fries,30--Hamburger,40--Cheesburger,50--Combo Meal with a drink "!promousers" displays to the broadcaster every viewer's name and the total amount tipped of the viewers who have tipped the needed amount to receive the promotional item. Special Commands for the Viewers: "/menu" displays the menu to the user who asked for it. This code could probably use some refactoring, but is mostly solid and easy to make changes to. */ var HEART = '\u2665'; // BDIAMOND = '\u2666'; // BSTAR = ' \u2605 '; // WSTAR = ' \u2606 '; // var DID_NOT_PAY = 0; var PAID_4_PROMO = 1; var HALF_WAY = 3; var _timerIntervalMultiplier = 1; var _totalTips = 0; var _promoItemValue = 100; var tip_amt = 0; var separator_char = "\n "; var msg; // <== this is the entire text for the menu var MAXITEMS=20; var tipmenuprice = []; var tipmenuitem= []; var tiphistory = []; var MAXSEP = 9; var _useRepeatingGoal= false; var _useIncreasingGoals = false; var _increasingGoals = [[]]; var _maxCostofProgressiveGoal = 0; separators = [ {label:'Hearts',shortcut:':heart2'}, {label:'Glitter',shortcut:':pixelglitter'}, {label:'Flowers',shortcut:':tinyflower2'}, {label:'Bow',shortcut:':bluebow'}, {label:'Hearts2',shortcut:':pixelheart'}, {label:'Smiley',shortcut:':smile'}, {label:'Text Heart',shortcut:HEART}, {label:'Text Diamond',shortcut:BDIAMOND}, {label:'Text Star',shortcut:BSTAR}, ]; cb.settings_choices = [ {name: 'blockgrey', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes', label: 'Block messages from users without tokens. Once the bot is running you can unblock users without tokens by entering !unblockgrey during the session. To re-block, type !blockgrey'}, {name: 'sepchar', type: 'choice', choice1: 'Vertical Bar', choice2:'Hearts', choice3:'Glitter', choice4:'Flowers', choice5:'Bow', choice6:'Hearts2', choice7:'Smiley', choice8:'Text Heart', choice9:'Text Diamond', choice10:'Text Star', defaultValue: 'Vertical Bar', label: "Separator character"}, {name:'item1', type:'str', label:'Item 1 (eg 10--flash tits)',}, {name:'item2', type:'str', required: false, label:'Item 2',}, {name:'item3', type:'str', required: false, label:'Item 3',}, {name:'item4', type:'str', required: false, label:'Item 4',}, {name:'item5', type:'str', required: false, label:'Item 5',}, {name:'item6', type:'str', required: false, label:'Item 6',}, {name:'item7', type:'str', required: false, label:'Item 7',}, {name:'item8', type:'str', required: false, label:'Item 8',}, {name:'item9', type:'str', required: false, label:'Item 9',}, {name:'item10', type:'str', required: false, label:'Item 10',}, {name:'item11', type:'str', required: false, label:'Item 11',}, {name:'item12', type:'str', required: false, label:'Item 12',}, {name:'item13', type:'str', required: false, label:'Item 13',}, {name:'item14', type:'str', required: false, label:'Item 14',}, {name:'item15', type:'str', required: false, label:'Item 15',}, {name:'item16', type:'str', required: false, label:'Item 16',}, {name:'item17', type:'str', required: false, label:'Item 17',}, {name:'item18', type:'str', required: false, label:'Item 18',}, {name:'item19', type:'str', required: false, label:'Item 19',}, {name:'item20', type:'str', required: false, label:'Item 20',}, {name:'noticecolor', type:'str', label:'Notice color (html code default red #FF0000)', defaultValue: '#FF0000'}, {name: 'chat_ad', type:'int', minValue: 1, maxValue: 999, defaultValue: 1,label: 'Delay in minutes between notice being displayed (minimum 1)'}, {name: 'useRepeatingGoal', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'No', label: 'Use repeating goal'}, {name: 'repeatingGoalValue', type:'int', minValue: 1, maxValue: 10000, defaultValue: 100, label:'Repeating Goal Amount'}, {name: 'repeatingGoalText', type:'str', label:'Repeating Goal Description.'}, {name: 'promoItemValue', type:'int', minValue: 1, maxValue: 10000, defaultValue: 100, label:'Promo Item Amount'}, {name: 'promoItemText', type:'str', label:'Promo Item -- Leave blank if you do not want one.'}, {name: 'promoClaimInstructions', type:'str', label:'Tell the user how to claim the promo item once they earn it.'}, {name: 'useIncreasingGoals', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'No', label: 'Use increasing goals'}, {name: 'levelOneGoalDesc', required: false, type:'str', label:'Level 1 goal description'}, {name: 'levelOneGoalCost', required: false, type:'int', minValue: 1, maxValue: 10000, defaultValue: 100, label:'Level 1 cost'}, {name: 'levelTwoGoalDesc', required: false, type:'str', label:'Level 2 goal description'}, {name: 'levelTwoGoalCost', required: false, type:'int', minValue: 1, maxValue: 10000, defaultValue: 200, label:'Level 2 cost'}, {name: 'levelThreeGoalDesc', required: false, type:'str', label:'Level 3 goal description'}, {name: 'levelThreeGoalCost', required: false, type:'int', minValue: 1, maxValue: 10000, defaultValue: 300, label:'Level 3 cost'}, {name: 'levelFourGoalDesc', required: false, type:'str', label:'Level 4 goal description'}, {name: 'levelFourGoalCost', required: false, type:'int', minValue: 1, maxValue: 10000, defaultValue: 400, label:'Level 4 cost'}, {name: 'levelFiveGoalDesc', required: false, type:'str', label:'Level 5 goal description'}, {name: 'levelFiveGoalCost', required: false, type:'int', minValue: 1, maxValue: 10000, defaultValue: 500, label:'Level 5 cost'}, {name: 'levelSixGoalDesc', required: false, type:'str', label:'Level 6 goal description'}, {name: 'levelSixGoalCost', required: false, type:'int', minValue: 1, maxValue: 10000, defaultValue: 600, label:'Level 6 cost'}, {name: 'levelSevenGoalDesc', required: false, type:'str', label:'Level 7 goal description'}, {name: 'levelSevenGoalCost', required: false, type:'int', minValue: 1, maxValue: 10000, defaultValue: 700, label:'Level 7 cost'}, {name: 'levelEightGoalDesc', required: false, type:'str', label:'Level 8 goal description'}, {name: 'levelEightGoalCost', required: false, type:'int', minValue: 1, maxValue: 10000, defaultValue: 800, label:'Level 8 cost'}, {name: 'levelNineGoalDesc', required: false, type:'str', label:'Level 9 goal description'}, {name: 'levelNineGoalCost', required: false, type:'int', minValue: 1, maxValue: 10000, defaultValue: 900, label:'Level 9 cost'}, {name: 'levelTenGoalDesc', required: false, type:'str', label:'Level 10 goal description'}, {name: 'levelTenGoalCost', required: false, type:'int', minValue: 1, maxValue: 10000, defaultValue: 1000, label:'Level 10 cost'} ]; cb.onEnter(function (user) { cb.sendNotice( msg, user.user, '', cb.settings.noticecolor, 'bold'); cb.sendNotice( 'Enter "/menu" at any time to see the menu.', user.user,'',cb.settings.noticecolor,'bold'); }); cb.onMessage(function (msg) { var str = ''; var arr = []; // // only the broadcaster or a mod can change the price of the recurring goal // if(( msg.user === cb.room_slug )||(msg.is_mod === true)){ // // changes the price of the recurring goal // if ( msg.m.substring(0,6) == '!goal=' ){ msg['X-Spam'] = true; str = msg.m; arr = str.split('='); arr[1] = arr[1].replace(/\D/g,''); cb.sendNotice( 'The new goal amount is now ' + arr[1], msg.user, '', '', '', ''); if( arr[1] > 0 ){ _configuredGoalAmount = arr[1]; } } // // changes the item of the recurring goal // if ( msg.m.substring(0,10) === '!goalitem=' ){ msg['X-Spam'] = true; str = msg.m; arr = str.split('='); cb.sendNotice( 'The new goal item is now \"' + arr[1] + '\"', msg.user, '', '', '', ''); _configuredGoalText = arr[1]; _totalTips = 0; } // // Changes the entire menus on the fly // if ( msg.m.substring(0,10) === '!newmenu==' ){ msg['X-Spam'] = true; // // Separate everything after the first "==" // str = msg.m; arr = str.split('=='); var strData = arr[1]; if (strData.indexOf(',') > -1) { ReplaceMenu(strData); } else{ cb.sendNotice( 'ERROR - That was not a comma delimited list.', msg.user, '', '', '', ''); } } // // Display everyone who has tipped enough to get the promo item. // Only the broadcaster sees this. // if ( msg.m === '!promousers' ){ msg['X-Spam'] = true; for( var x = 0; x < tiphistory.length; x++ ){ // // find only the users who have tipped enough // if( tiphistory[x][1] >= _promoItemValue) { cb.sendNotice( tiphistory[x][0] + '--' + tiphistory[x][1], cb.room_slug, '#FFCC99', '', 'bold', ''); } } } // // Changes the entire menus on the fly // if ( msg.m.substring(0,10) === '!listgoals' ){ msg['X-Spam'] = true; printListOfGoals(); } } // // Not the broadcaster or a mod // else{ // // prints the menu on demand // if ( msg.m.substring(0,5) === '/menu' ){ msg['X-Spam'] = true; InstantMenu(); } else{ _spokenCounter = 0; } } return msg; }); // // event handler for when a tip is received // cb.onTip(function (tip) { tip_amt = parseInt(tip.amount); _totalTips += tip_amt; // // if there are increasing goal levels // if ( _useIncreasingGoals === true ) { drawProgressiveGoalProgress(); } // // Update the repeating goal progess // if ( _useRepeatingGoal === true ) { _goalAmountSoFar += tip_amt; if ( _goalAmountSoFar >= _configuredGoalAmount ) { _goalAchieved = true; } drawGoalProgress(); } // // Loop through all 20 items and look to see if the tip amount // matches a configured menu item. // for (var i = 1; i <= MAXITEMS; i++) { if (tip_amt == tipmenuprice[i]) { cb.sendNotice( tip.from_user + ' tipped for ' + tipmenuitem[i], '', '', cb.settings.noticecolor, 'bold'); cb.sendNotice("\n=== TIME TO DELIVER ===", cb.room_slug, "#FFFF00", "", "bold", ""); cb.sendNotice("\"" + tip.from_user + "\" paid for an item from your menu.", cb.room_slug, "#FFFF00", "", "bold", ""); cb.sendNotice("Item: \"" + tipmenuitem[i] + "\"\n", cb.room_slug, "#FFFF00", "", "bold", ""); } } // // See if there is a promotional item and handle its progress // HandlePromotion( tip.from_user, tip_amt ); }); var _progressiveGoalAmount = 0; // this is exclusively used for a repeating goal var _progressiveGoalText = ''; // this is the desc. of the repeating goal var _progressiveGoalAmountSoFar = 0; // this is the amound used for the repeating goal var _progressiveGoalAchieved = false; // this is a logic flag used for the repeating goal operations // // This function is only used for progressively larger goals // function drawProgressiveGoalProgress() { var str = "\n"; if( _totalTips >= _maxCostofProgressiveGoal ){ _useIncreasingGoals = false; _useRepeatingGoal = true; _configuredGoalText = _progressiveGoalText; _goalAchieved === true; cb.sendNotice('=== MAX LEVEL ACHIEVED ===', '', '#FF77FF', '', 'bold', ''); cb.sendNotice('\n=== GOAL ACHIEVED=== \n=== TIME TO DELIVER === ', cb.room_slug, '#FFFF00', '', 'bold', ''); cb.sendNotice('\"' + _progressiveGoalText + '\" \n', cb.room_slug, '#FFFF00', '', 'bold', ''); } else if( _totalTips >= _progressiveGoalAmount ){ _progressiveGoalAchieved = true; var prevGoal = _progressiveGoalText; cb.sendNotice('=== LEVELING UP ===', '', '#FF77FF', '', 'bold', ''); cb.sendNotice('\n=== GOAL ACHIEVED=== \n=== TIME TO DELIVER === ', cb.room_slug, '#FFFF00', '', 'bold', ''); cb.sendNotice('\"' + prevGoal + '\" \n', cb.room_slug, '#FFFF00', '', 'bold', ''); str = "The goal for " + prevGoal + " is achieved. \n"; for( var z = 0; z < _increasingGoals.length; z++ ) { if( _totalTips >= _progressiveGoalAmount ) { _progressiveGoalText = _increasingGoals[z][0]; _progressiveGoalAmount = _increasingGoals[z][1]; } } str += "The new goal is " + _progressiveGoalText + '\nPROGRESS: ' + _totalTips + '/' + _progressiveGoalAmount + ' achieved \n ' + graphicalPercent(_progressiveGoalAmount, _totalTips); } else{ // // Message for the users // str = 'PROGRESSIVE GOAL: \"' + _progressiveGoalText + '\" \nPROGRESS: ' + _totalTips + '/' + _progressiveGoalAmount + ' achieved \n ' + graphicalPercent(_progressiveGoalAmount, _totalTips); } cb.sendNotice(str, '', "#FFCCFF", "#000000", "", ""); } // // // Print all of the progressive goals // // function printListOfGoals() { var str = " === My Progressive Goals ==="; for( var z = 0; z < _increasingGoals.length; z++ ){ currentGoal = _increasingGoals[z][1]; str += "\n" + (z+1) + ". " + _increasingGoals[z][0] + " once I reach " + currentGoal + " tokens"; } cb.sendNotice(str, '', "#FFCCFF", "#000000", "", ""); } var _configuredGoalAmount = 0; // this is exclusively used for a repeating goal var _configuredGoalText = ''; // this is the desc. of the repeating goal var _goalAmountSoFar = 0; // this is the amound used for the repeating goal var _goalTimesAchieved = 0; // this is how many times the repeating goal has been achieved var _goalAchieved = false; // this is a logic flag used for the repeating goal operations // // This function should only be used if there is a repeating goal // function drawGoalProgress(){ // // if the goal HAS BEEN achieved // if ( _goalAchieved === true ) { // // Message for the users // var str = '\n' + _goalAmountSoFar + ' TOKENS COLLECTED!!! GOAL ACHIEVED!!!\n'; str += 'GOAL REWARD: \"' + _configuredGoalText + '\" \n'; cb.sendNotice( str,'','#CCCCFF','#000000','bold'); // // Message for the broadcaster // cb.sendNotice('\n=== GOAL ACHIEVED=== \n=== TIME TO DELIVER === ', cb.room_slug, '#FFFF00', '', 'bold', ''); cb.sendNotice('\"' + _configuredGoalText + '\" \n', cb.room_slug, '#FFFF00', '', 'bold', ''); _goalAchieved = false; _goalTimesAchieved = ~~( _totalTips / _configuredGoalAmount ); _goalAmountSoFar = _totalTips % _configuredGoalAmount; } // // the goal HAS NOT BEEN achieved yet // else{ // // Message for the users // var str = 'REPEATING GOAL: \"' + _configuredGoalText + '\" \nPROGRESS: ' + _goalAmountSoFar + '/' + _configuredGoalAmount + ' achieved \n ' + graphicalPercent(_configuredGoalAmount, _goalAmountSoFar); if( _goalTimesAchieved >= 1 ) { str += '\nGOALS ACHIEVED: ' + _goalTimesAchieved; } cb.sendNotice( str,'','#CCCCFF','#000000',''); } } // // If there is a promotional item, we will keep track // of all of the tips, and who gave them. When the user // has given enough tips, he will be able to collect on // the promotional item. // // The first time they tip, they will be notified that // there is a promotion, and what the terms are. // function HandlePromotion( username, tip_amt ) { if( cb.settings.promoItemText) { // // Track every tip for every user // var tempArr = [ username, tip_amt, DID_NOT_PAY ]; var togo = 0; // // at least one person has already tipped // if( tiphistory.length > 0 ){ // // the user has already tipped // if ( UserExists( tiphistory, username )){ for( var x = 0; x < tiphistory.length; x++ ){ // // the person already exists in the array // if( tiphistory[x][0] === username) { tiphistory[x][1] += tip_amt; togo = _promoItemValue - tiphistory[x][1]; // // test to see if the user is half way there yet // if(( tiphistory[x][1] >= (_promoItemValue/2)) && ( tiphistory[x][1] < _promoItemValue) && (tiphistory[x][2] != HALF_WAY )) { tiphistory[x][2] = HALF_WAY; cb.sendNotice( 'You are at least half way there to get ' + cb.settings.promoItemText + ' as a bonus. Tip ' + togo + ' more to receive ' + cb.settings.promoItemText, username, '#FFCC99', '', 'bold', ''); } // // test to see if the user has earned the promotional item yet // if(( tiphistory[x][1] >= _promoItemValue) && (tiphistory[x][2] != PAID_4_PROMO )) { tiphistory[x][2] = PAID_4_PROMO; cb.sendNotice( 'By tipping ' + _promoItemValue + ' or more tokens during this show, you now get ' + cb.settings.promoItemText + ' as a bonus. ' + cb.settings.promoClaimInstructions + '', username, '#FFCC99', '', 'bold', ''); } } }// end for loop } // // this is the user's first tip // else { if( tip_amt >= _promoItemValue ){ tempArr[2] = PAID_4_PROMO; cb.sendNotice( 'By tipping ' + _promoItemValue + ' or more tokens during this show, you now get ' + cb.settings.promoItemText + ' as a bonus. ' + cb.settings.promoClaimInstructions + '', username, '#FFCC99', '', 'bold', ''); } else { tempArr[2] = DID_NOT_PAY; togo = _promoItemValue - tip_amt; cb.sendNotice( 'By tipping ' + togo + ' more tokens (' + _promoItemValue + ' in total) before the end of the show, you will get ' + cb.settings.promoItemText + ' as a bonus.', username, '#FFCC99', '', 'bold', ''); } tiphistory[tiphistory.length] = tempArr; } } // // no one has tipped yet until now // else { if( tip_amt >= _promoItemValue ){ tempArr[2] = PAID_4_PROMO; cb.sendNotice( 'By tipping ' + _promoItemValue + ' or more tokens during this show, you now get ' + cb.settings.promoItemText + ' as a bonus. ' + cb.settings.promoClaimInstructions + '', username, '#FFCC99', '', 'bold', ''); } else { tempArr[2] = DID_NOT_PAY; togo = _promoItemValue - tip_amt; cb.sendNotice( 'By tipping ' + togo + ' more tokens (' + _promoItemValue + ' in total) before the end of the show, you will get ' + cb.settings.promoItemText + ' as a bonus.', username, '#FFCC99', '', 'bold', ''); } tiphistory[0] = tempArr; } } } // // Looks to see if a user has already tipped // function UserExists( tmpArray, username ) { var retVal = 0; for( var x = 0; x < tmpArray.length; x++ ){ // // the person already exists in the array // if( tmpArray[x][0] === username ) { retVal = 1; break; } } return retVal; } // // Instantly adds the menu to the chat // function InstantMenu() { cb.sendNotice( msg, '' ,'', cb.settings.noticecolor, 'bold'); } // // Timer for printing the menu to the chat // function chatAd() { if( cb.settings.item1) { if( _spokenCounter < (60 * _timerIntervalMultiplier) ){ cb.sendNotice( msg, '', '' ,cb.settings.noticecolor, 'bold'); if( _useIncreasingGoals === true ){ printListOfGoals(); } } else{ //cb.sendNotice( "Menu suppressed.", cb.room_slug,'','#777777','bold'); } } cb.setTimeout(chatAd, (_timerIntervalMultiplier * 60000)); } cb.setTimeout(chatAd, (_timerIntervalMultiplier * 60000)); // // Timer for adding the goal to the chat // function AddGoalToChat() { if (( _useRepeatingGoal === true )||( _useIncreasingGoals === true )) { if( _spokenCounter < 60 ){ if( _useRepeatingGoal === true ){ drawGoalProgress(); } if( _useIncreasingGoals === true ){ drawProgressiveGoalProgress(); } } else{ //do nothing } cb.setTimeout(AddGoalToChat, (60000)); } else{ cb.setTimeout(AddGoalToChat, (0)); } } cb.setTimeout(AddGoalToChat, (60000)); // // Timer monitoring incoming messages // var _spokenCounter = 0; function HasAnyoneAddedMessage() { if (( _useRepeatingGoal === true )||( _useIncreasingGoals === true )) { _spokenCounter++; cb.setTimeout(HasAnyoneAddedMessage, (1000)); } else{ cb.setTimeout(HasAnyoneAddedMessage, (0)); } } cb.setTimeout(HasAnyoneAddedMessage, (1000)); // // Returns a string that is a graph showing the percent completed the goal is. // The string uses black and white stars as a graphical representation. // function graphicalPercent(cfgNum, soFarNum){ var numberOfStars = 15; var returnString = ''; var normalized = cfgNum / numberOfStars; // normalize to numberOfStars since our graph has numberOfStars in it var blackStars = ~~( soFarNum / normalized ); // round it off to the interval var whiteStars = numberOfStars - blackStars; for( var x = 0; x < blackStars; x++ ) { returnString += BSTAR; } for( var y = 0; y < whiteStars; y++ ) { returnString += WSTAR; } return returnString; } // // Reads all of the configured settings and applies them to the session // function init() { _promoItemValue = parseInt( cb.settings.promoItemValue ); if( cb.settings.useIncreasingGoals === 'Yes') { _useIncreasingGoals = true; var tmp = cb.settings.levelOneGoalDesc; if( tmp ){ cb.sendNotice(tmp, '', '', cb.settings.noticecolor, 'bold'); _increasingGoals[0][0] = tmp; _increasingGoals[0][1] = parseInt(cb.settings.levelOneGoalCost); _progressiveGoalText = tmp; _progressiveGoalAmount = parseInt(cb.settings.levelOneGoalCost); _maxCostofProgressiveGoal = parseInt(cb.settings.levelOneGoalCost); } tmp = cb.settings.levelTwoGoalDesc; if( tmp ){ var arrB = [tmp, parseInt(cb.settings.levelTwoGoalCost)]; _increasingGoals.push(arrB); _maxCostofProgressiveGoal = parseInt(cb.settings.levelTwoGoalCost); } tmp = cb.settings.levelThreeGoalDesc; if( tmp ){ var arrC = [tmp, parseInt(cb.settings.levelThreeGoalCost)]; _increasingGoals.push(arrC); _maxCostofProgressiveGoal = parseInt(cb.settings.levelThreeGoalCost); } tmp = cb.settings.levelFourGoalDesc; if( tmp ){ var arrD = [tmp, parseInt(cb.settings.levelFourGoalCost)]; _increasingGoals.push(arrD); _maxCostofProgressiveGoal = parseInt(cb.settings.levelFourGoalCost); } tmp = cb.settings.levelFiveGoalDesc; if( tmp ){ var arrE = [tmp, parseInt(cb.settings.levelFiveGoalCost)]; _increasingGoals.push(arrE); _maxCostofProgressiveGoal = parseInt(cb.settings.levelFiveGoalCost); } tmp = cb.settings.levelSixGoalDesc; if( tmp ){ var arrF = [tmp, parseInt(cb.settings.levelSixGoalCost)]; _increasingGoals.push(arrF); _maxCostofProgressiveGoal = parseInt(cb.settings.levelSixGoalCost); } tmp = cb.settings.levelSevenGoalDesc; if( tmp ){ var arrG = [tmp, parseInt(cb.settings.levelSevenGoalCost)]; _increasingGoals.push(arrG); _maxCostofProgressiveGoal = parseInt(cb.settings.levelSevenGoalCost); } tmp = cb.settings.levelEightGoalDesc; if( tmp ){ var arrH = [tmp, parseInt(cb.settings.levelEightGoalCost)]; _increasingGoals.push(arrH); _maxCostofProgressiveGoal = parseInt(cb.settings.levelEightGoalCost); } tmp = cb.settings.levelNineGoalDesc; if( tmp ){ var arrI = [tmp, parseInt(cb.settings.levelNineGoalCost)]; _increasingGoals.push(arrI); _maxCostofProgressiveGoal = parseInt(cb.settings.levelNineGoalCost); } tmp = cb.settings.levelTenGoalDesc; if( tmp ){ var arrJ = [tmp, parseInt(cb.settings.levelTenGoalCost)]; _increasingGoals.push(arrJ); _maxCostofProgressiveGoal = parseInt(cb.settings.levelTenGoalCost); } printListOfGoals(); drawProgressiveGoalProgress(); }else{ _useIncreasingGoals = false; } //cb.sendNotice('ARRAY is ' + _increasingGoals.length + ' long', '', '', cb.settings.noticecolor, 'bold'); //for (var w = 0; w < _increasingGoals.length; w++) //{ // cb.sendNotice('GOAL is ' + _increasingGoals[w][0] + ' ' + _increasingGoals[w][1], '', '', cb.settings.noticecolor, 'bold'); //} // // If there is at least one menu item configured // if( cb.settings['item1']) { _timerIntervalMultiplier = parseInt( cb.settings.chat_ad ); cb.sendNotice('INTERVAL: ' + _timerIntervalMultiplier, '', '', cb.settings.noticecolor, 'bold'); } // // What is the configured goal amount? // What is the configured goal description? // if( cb.settings.useRepeatingGoal === 'Yes'){ _useRepeatingGoal = true; } else{ _useRepeatingGoal = false; } _configuredGoalAmount = parseInt(cb.settings.repeatingGoalValue); _configuredGoalText = cb.settings.repeatingGoalText; if ( _useRepeatingGoal === true ) { cb.sendNotice( 'LOADING the new goal.','','','#0000AA','bold'); drawGoalProgress(); } else{ cb.sendNotice( 'There is no repeating goal.','','','#0000AA','bold'); } // // Start constructing the text for the menu. // msg = 'Tip Menu: \n Being nice (0) ' + HEART + ' '; // // Look at all 20 slots and see if anything is in any of them. // If so, parse the text and add the item to the menu. // for (var i = 1; i <= MAXITEMS; i++) { var tmp; tmp = cb.settings['item' + i]; if (tmp) { var arr= tmp.split('--'); if (arr[1] === undefined) { cb.sendNotice('Error-You need two dashes to separate the tip amount and menu item for item no '+ i,'','',cb.settings['noticecolor'],'bold'); } else { var amt = parseInt(arr[0]); if (amt > 0) { tipmenuprice[i] = amt; tipmenuitem[i] = arr[1]; if (i >= 2 ) { //msg += "\n"; msg += " " + HEART + " "; } msg += "" + arr[1] + ' (' + amt + ') '; } } } } msg += "\n If you are unwilling to tip, please be equally unwilling to make demands."; // // Print the start up message to verify that everything loaded correctly // This message will display regardless of whether or not there are any menu items. // cb.sendNotice( "LOADING: " + msg, '', '',cb.settings.noticecolor,'bold'); } init(); // // Replaces the entire menu with a new one on the fly // See header for usage // function ReplaceMenu(CommaSepStr) { msg = 'Tip Menu: \n Being nice (0) ' + HEART + ' '; var ResultArray = null; // // deletes existing menu items // for( var z = 0; z < MAXITEMS; z++) { tipmenuprice[z+1] = ''; tipmenuitem[z+1] = ''; } // // splits up the string using commas as the delimeter // if( CommaSepStr!= null ) { var SplitChars = ','; if (CommaSepStr.indexOf(SplitChars) >= 0) { ResultArray = CommaSepStr.split(SplitChars); } } // // // for( var x = 0; x < ResultArray.length; x++) { var arr= ResultArray[x].split('--'); tipmenuprice[x+1] = parseInt(arr[0]); tipmenuitem[x+1] = arr[1]; msg += "" + tipmenuitem[x+1] + ' (' + tipmenuprice[x+1] + ') ' + HEART + ' '; } msg += "\n If you are unwilling to tip, please be equally unwilling to make demands."; InstantMenu(); }
© Copyright Chaturbate 2011- 2024. All Rights Reserved.