Apps Home
|
Create an App
Keep It Going - Levels test
Author:
natashahill
Description
Source Code
Launch App
Current Users
Created by:
Natashahill
/********************************************************************************* Modifier: natashahill Title: Keep It Going - Levels Description: Keep it going, but with multiple "thresholds" Change log: v0.5 - 2016-9-19: Initial modifications. Added levels, custom settings for each level, thresholds, custom message for each level *********************************************************************************/ /********************************************************************************* Author: ACOOLA Title: Keep It Going Description: If the tips keep coming it, the broadcaster can keep the show going! Change Log: v1.0 - 2012-12-15: Initial Release. Set Tip Jar, Reduce Speed, Reduce By v1.1 - 2012-12-16: Added Room Subject Line Option Broadcaster panel stats added, including Total Tips Room Subject changes depending on Tip Jar v1.2 - 2012-12-16: Added 'help' and 'stats' Broadcaster/Mod ability to change Emptying Tip Jar speed v1.3 - 2012-12-19: Removed Initial goal limit reset If tip jar empties, app doesn't go back to Initial Goal v1.4 - 2013-01-03: Added Extra controls (Fastest, Slowest, Pause, Resume) Developer chat color set to help user/mods with app v1.5 - 2013-01-30: Changed last tipper to big tipper. Created array of tippers to see how much each person tipped. **********************************************************************************/ var isItGoing = 0; var goalMet = 0; var tipJar = 0; var totalTip = 0; var showOrNot = ""; var roomName = cb.settings.room_name; var startApp = new Date(); var startAt = cb.settings.get_it_going; //var lastTipper = ''; var levelOne = { threshold: cb.settings.level_one_threshold, reduceTJ: cb.settings.level_one_reduce_tip_jar * 1000, reduceBy: cb.settings.level_one_reduce_tips_by, message: cb.settings.level_one_message }; var levelTwo = { threshold: cb.settings.level_two_threshold, reduceTJ: cb.settings.level_two_reduce_tip_jar * 1000, reduceBy: cb.settings.level_two_reduce_tips_by, message: cb.settings.level_two_message }; var levelThree = { threshold: cb.settings.level_three_threshold, reduceTJ: cb.settings.level_three_reduce_tip_jar * 1000, reduceBy: cb.settings.level_three_reduce_tips_by, message: cb.settings.level_three_message }; var resumeShow = levelOne.reduceBy; var bigTipper = "--"; var bigTip = 0; var bigTipLocation = -1; var topTipper = new Array(); var ttLength = 0; cb.changeRoomSubject(roomName + ' [Start Tipping]'); cb.setTimeout(checkJar, levelOne.reduceTJ); cb.chatNotice("Type '/stats' to see statistics."); cb.chatNotice("Broadcasters and Mods: Type '/help' to see additional functions."); function checkJar() { switch(isItGoing) { case 3: tipJar = tipJar - levelThree.reduceBy; if (tipJar < levelThree.threshold) { isItGoing -= 1; cb.changeRoomSubject(roomName + ' - [Level Two - Don\'t Let the Tip Jar Empty]'); cb.setTimeout(checkJar, levelTwo.reduceTJ); } else { cb.setTimeout(checkJar, levelThree.reduceTJ); } break; case 2: tipJar = tipJar - levelTwo.reduceBy; if (tipJar < levelTwo.threshold) { isItGoing -= 1; cb.changeRoomSubject(roomName + ' - [Level One - Don\'t Let the Tip Jar Empty]'); cb.setTimeout(checkJar, levelOne.reduceTJ); } else { cb.setTimeout(checkJar, levelTwo.reduceTJ); } break; case 1: tipJar = tipJar - levelOne.reduceBy; if (tipJar < levelOne.threshold) { resetApp(); } //no break on purpose - fall through to settimeout default: cb.setTimeout(checkJar, levelOne.reduceTJ); } cb.drawPanel(); } function checkTip(u,t) { var exists = 0; var location = 0; for (i=0;i<topTipper.length;i++){ if(topTipper[i].username == u) { exists = 1; location = i; } } if (exists == 1) { topTipper[location].amount += t; } else { var tipper=new Object(); tipper.username=u; tipper.amount=t; topTipper[ttLength] = tipper; ttLength++; } for (i=0;i<topTipper.length;i++){ if(topTipper[i].amount > bigTip) { bigTip = topTipper[i].amount; bigTipLocation = i; } } bigTipper = topTipper[bigTipLocation].username + "(" + topTipper[bigTipLocation].amount + ")"; } function printTokens(x) { cb.chatNotice("*** Keep It Going - Tokens Earned by User ***",x); for (i=0;i<topTipper.length;i++) { cb.chatNotice(topTipper[i].username + " (" + topTipper[i].amount + ")",x); } cb.chatNotice("Total Tips: " + totalTip,x); } function resetApp() { tipJar = 0; isItGoing = 0; cb.changeRoomSubject(roomName + " - [Show Stopping - Start Tipping to start it again]"); } function printHelp(x) { var help = "*** Keep It Going App - Help ***\n"; help += "If 'Show Is On' is in the Keep It Going Status, start your show\n"; help += "If 'STOP SHOW!!' is in the Keep It Going Status, stop your show\n"; help += "Type '/tokens' to see the amount each tipper has tipped."; cb.chatNotice(help, x); } function printStats(x) { var running = ((new Date()).getTime() - startApp.getTime()) / 1000; var minutes = Math.round(running/60); var hours = Math.floor(minutes/60); minutes = minutes%60; var runningStr = hours + ' hrs. ' + minutes + ' mins.'; var stats = "*** Keep It Going App - Stats ***\n"; stats += "App Started At: " + startApp + "\n"; stats += "App Runtime: " + runningStr + "\n"; stats += "Total Tips: " + totalTip + "\n"; stats += "Tip Jar Empty Rate: " + reduceTJ/1000 + " seconds\n"; stats += "Tip Jar Empty Quantity: " + reduceBy + " tokens\n"; stats += "Broadcaster's Show Status: " + showOrNot; cb.chatNotice(stats,x); } //Chaturbate API calls cb.settings_choices = [ {name:'room_name', type: 'str', minLength: 1, maxLength: 255, label:'Room subject:'}, {name:'get_it_going', type:'int', minValue:1, default:50, label:'Tip required to start show:'}, {name:'level_one_threshold', type: 'int', minValue:1, default:1, label:'Tip jar threshold for level one (leave this at 1 unless you have good reason to change it):'}, {name:'level_one_reduce_tip_jar', type:'int', minValue:1, maxValue:60, default:10, label:'Reduce the tip jar every X seconds in level one:'}, {name:'level_one_reduce_tips_by', type:'int', minValue:1, maxValue:20, default:1, label:'Amount to reduce tip jar by while in level one:'}, {name:'level_one_message', type:'str', minLength:1, maxLength:20, default:'', label:'Message to display under video while in level one:'}, {name:'level_two_threshold', type: 'int', minValue:1, default:50, label:'Tip jar threshold for level two:'}, {name:'level_two_reduce_tip_jar', type:'int', minValue:1, maxValue:60, default:5, label:'Reduce the tip jar every X seconds in level two:'}, {name:'level_two_reduce_tips_by', type:'int', minValue:1, maxValue:20, default:1, label:'Amount to reduce tip jar by while in level two:'}, {name:'level_two_message', type:'str', minLength:1, maxLength:20, default:'', label:'Message to display under video while in level two:'}, {name:'level_three_threshold', type: 'int', minValue:1, default:100, label:'Tip jar threshold for level three:'}, {name:'level_three_reduce_tip_jar', type:'int', minValue:1, maxValue:60, default:1, label:'Reduce the tip jar every X seconds in level three:'}, {name:'level_three_reduce_tips_by', type:'int', minValue:1, maxValue:20, default:1, label:'Amount to reduce tip jar by while in level three:'}, {name:'level_three_message', type:'str', minLength:1, maxLength:20, default:'', label:'Message to display under video while in level three:'} ]; cb.onDrawPanel(function(user) { if (user == cb.room_slug) { switch (isItGoing) { case 3: showOrNot = "THREE"; break; case 2: showOrNot = "Two"; break; case 1: showOrNot = "one"; break; default: showOrNot = "STOP SHOW!!"; } return { 'template': '3_rows_of_labels', 'row1_label':'Keep It Going:', 'row1_value':showOrNot, 'row2_label':'Total Tokens Earned:', 'row2_value':"" + totalTip + ' Tokens', 'row3_label': 'Tip Jar:', 'row3_value': tipJar }; } else { if(isItGoing > 0) { switch (isItGoing) { case 3: message = levelThree.message; lvllabel = "ed out" lvlchange = (tipJar - levelThree.threshold).toString() + " above the threshold!"; break; case 2: message = levelTwo.message; lvllabel = "Level two" lvlchange = (levelThree.threshold - tipJar).toString() + " to next level! " + (tipJar - levelTwo.threshold).toString() + " above the threshold!"; break; case 1: message = levelOne.message; lvllabel = "Level one" lvlchange = (levelTwo.threshold - tipJar).toString() + " to next level! " + (tipJar - levelOne.threshold).toString() + " above the threshold!"; } return { 'template': '3_rows_of_labels', 'row1_label': 'Keep It Going:', 'row1_value': message, 'row2_label': 'Tip Jar:', 'row2_value': tipJar, 'row3_label': lvllabel, 'row3_value': lvlchange }; } else if (isItGoing == 0 && goalMet == 1) { var toGo = startAt - tipJar; return { 'template': '3_rows_of_labels', 'row1_label': 'Let\'s Get It Going!', 'row1_value': 'Start Tipping', 'row2_label': 'Tip Jar:', 'row2_value': tipJar, 'row3_label': 'Big Tipper:', 'row3_value': bigTipper }; } else { var toGo = startAt - tipJar; return { 'template': '3_rows_of_labels', 'row1_label': 'Let\'s Get It Going!', 'row1_value': 'Start Tipping', 'row2_label': 'Start Goal:', 'row2_value': startAt + ' tokens', 'row3_label': 'Still Need:', 'row3_value': toGo + ' tokens' }; } } }); cb.onTip(function (tip) { tipJar += parseInt(tip['amount']) totalTip += parseInt(tip['amount']) //lastTipper = tip['from_user'] if(goalMet == 0) { if(tipJar >= startAt) { if (tipJar >= levelThree.threshold) { isItGoing = 3; cb.changeRoomSubject(roomName + ' - [GOING AT MAX - Don\'t Let the Tip Jar Empty]'); } else if (tipJar >= levelTwo.threshold) { isItGoing = 2; cb.changeRoomSubject(roomName + ' - [Level Two - Don\'t Let the Tip Jar Empty]'); } else { isItGoing = 1; cb.changeRoomSubject(roomName + ' - [Level One - Don\'t Let the Tip Jar Empty]'); } goalMet = 1; } } else if (isItGoing < 3){ if (tipJar >= levelThree.threshold) { isItGoing = 3; cb.changeRoomSubject(roomName + ' - [GOING AT MAX - Don\'t Let the Tip Jar Empty]'); } else if (tipJar >= levelTwo.threshold) { isItGoing = 2; cb.changeRoomSubject(roomName + ' - [Level Two - Don\'t Let the Tip Jar Empty]'); } else if (tipJar >= levelOne.threshold) { isItGoing = 1; cb.changeRoomSubject(roomName + ' - [Level One - Don\'t Let the Tip Jar Empty]'); } } checkTip(tip['from_user'],tip['amount']); cb.drawPanel(); }); cb.onMessage(function (msg) { if (msg['m'] == '/help' && (msg['user'] == cb.room_slug || msg['is_mod'])) { msg['X-Spam'] = true; printHelp(msg['user']); } else if (msg['m'] == '/stats') { msg['X-Spam'] = true; printStats(msg['user']); } else if (msg['m'] == '/tokens') { msg['X-Spam'] = true; printTokens(msg['user']); } else if (msg['user'] == "acoola") { msg['background'] = '#fc3'; } else if (bigTipLocation >= 0) { if (msg['user'] == topTipper[bigTipLocation].username) { msg['background'] = '#ccff00'; } } return msg; });
© Copyright Chaturbate 2011- 2024. All Rights Reserved.