Apps Home
|
My Uploads
|
Create an App
grit123
Author:
grit1
Description
Source Code
Launch App
Current Users
Created by:
Grit1
App Images
var backgroundImage = {'red': '862eccdd-999a-421a-84b0-5a41b2f2c520','green':'c9433edf-cc60-4565-a02c-8f41e47973de','orange':'f7c513b8-7380-44ae-aeff-f64e183870c9','final':'7e0c6ecb-6657-409b-ab2c-01e8c6004ab6'}; var fontSize = 11; var fontSize_timer = 15; cb.onDrawPanel(function(user) { var panel = {}; panel.template = "image_template"; row1_label = "row1_label"; row1_value = "row1_value"; row2_label = "row2_label"; row2_value = "row2_value"; row3_label = "row3_label"; row3_value = "row3_value"; bg = backgroundImage['green']; if (isItGoing == 0){ bg = backgroundImage['red']; } else if (tipJar > green_start){ current_light = 2; bg = backgroundImage['green']; } else if(tipJar > orange_time){ current_light = 3; bg = backgroundImage['orange']; } else { current_light = 1; bg = backgroundImage['red']; } if (final_destination_reached) { row3_label = 'Destination ' + (current_destination-1) + ':'; row3_value = 'FINAL DESTINATION REACHED'; bg = backgroundImage['final']; } else { row3_label = 'Destination ' + current_destination + ':'; row3_value = currentTotalTipped + ' / ' + getCurrentDestinationAmount() + ' (' + tips_remaining() + ' left)'; } if (user == cb.room_slug) { if (isItGoing == 1) { showOrNot = "Show is On"; } else { showOrNot = "STOP SHOW!!"; } row1_label ='Keep It Going:'; row1_value = showOrNot; row2_label = 'Timer:'; row2_value = tipJar; } else { if(isItGoing == 1) { row1_label = 'Keep It Going:'; row1_value = 'Don\'t Let It turn Red'; row2_label = 'Timer:'; row2_value = tipJar; } else if (isItGoing == 0 && startJourneyMet == 1) { var toGo = startAt - tipJar; row1_label = 'Let\'s Get Going:'; row1_value = 'Start Tipping'; row2_label = 'Timer:'; row2_value = tipJar; } else { var toGo = startAt - tipJar; row1_label = 'Let\'s Get Going:'; row1_value = 'Start Tipping'; row2_label = 'Still Need:'; row2_value = toGo + ' tokens'; } } panel.layers = [ {'type': 'image', 'fileID': bg}, { 'type': 'text', 'text': row1_label, 'top': 5, 'left': 40, 'font-size': fontSize, 'color': 'purple', }, { 'type': 'text', 'text': row2_label, 'top': 29, 'left': 40, 'font-size': fontSize, 'color': 'red', }, { 'type': 'text', 'text': row3_label, 'top': 53, 'left': 40, 'font-size': fontSize, 'color': 'purple', }, { 'type': 'text', 'text': row1_value, 'top': 5, 'left': 125, 'font-size': fontSize, 'color': 'purple', }, { 'type': 'text', 'text': row2_value, 'top': 29, 'left': 125, 'font-size': fontSize_timer, 'color': 'red', }, { 'type': 'text', 'text': row3_value, 'top': 53, 'left': 125, 'font-size': fontSize, 'color': 'purple', }, ] return panel }); //Chaturbate API calls cb.settings_choices = [ {name:'room_subject', type: 'str', minLength: 1, maxLength: 255, label:'Room subject:'}, {name:'get_it_going', type:'int', minValue:1, default:50, label:'Tip required to start journey:'}, {name:'reduce_tip_jar', type:'int', minValue:1, maxValue:60, default:10, label:'Reduce the tip jar every X seconds:'}, {name:'reduce_tips_by', type:'int', minValue:1, maxValue:20, default:1, label:'Amount to reduce tip jar by:'}, {name: 'destination_1_tokens', label: 'Destination 1 Token Amount', type: 'int', minValue: 1, defaultValue: 200}, {name: 'destination_1_description', label: 'Destination 2 Description', type: 'str', minLength: 1, maxLength: 255}, {name: 'destination_2_tokens', label: 'Destination 2 Token Amount', type: 'int', minValue: 1, defaultValue: 200, required: false}, {name: 'destination_2_description', label: 'Destination 2 Description', type: 'str', minLength: 0, maxLength: 255, required: false}, {name: 'destination_3_tokens', label: 'Destination 3 Token Amount', type: 'int', minValue: 1, defaultValue: 200, required: false}, {name: 'destination_3_description', label: 'Destination 3 Description', type: 'str', minLength: 0, maxLength: 255, required: false}, {name: 'destination_4_tokens', label: 'Destination 4 Token Amount', type: 'int', minValue: 1, defaultValue: 200, required: false}, {name: 'destination_4_description', label: 'Destination 4 Description', type: 'str', minLength: 0, maxLength: 255, required: false}, {name: 'destination_5_tokens', label: 'Destination 5 Token Amount', type: 'int', minValue: 1, defaultValue: 200, required: false}, {name: 'destination_5_description', label: 'Destination 5 Description', type: 'str', minLength: 0, maxLength: 255, required: false}, {name: 'finality_message', label: 'Final Destination Reached Subject', type: 'str', minLength: 1, maxLength: 255, defaultValue: 'Final Destination reached! Thanks to all tippers!'}, ]; // vars var isItGoing = 0; var startJourneyMet = 0; var tipJar = 0; var totalTipped = 0; var currentTotalTipped = 0; var subject_is_final = false; var current_destination = 1; var current_light = 1; //1: Red 2:Green 3:Orange var final_destination_reached = false; var showOrNot = ""; var startApp = new Date(); var startAt = cb.settings.get_it_going; var orange_time = Math.ceil(startAt/3); var green_start = Math.ceil(startAt/3)*2; var reduceTJ = cb.settings.reduce_tip_jar * 1000; var reduceBy = cb.settings.reduce_tips_by; var resumeShow = reduceBy; var bigTipper = "--"; var bigTip = 0; var bigTipLocation = -1; var topTipper = new Array(); var ttLength = 0; var roomSubject = cb.settings.room_subject; var multiGoalSubject = roomSubject + ' [Destination ' + current_destination + ': ' + getCurrentDestinationDescription() + ' - ' + tips_remaining() + ' tk left] '; var keepItGoingSubject = '[Tip ' + startAt + ' to start the journey]'; cb.setTimeout(checkJar, reduceTJ); cb.chatNotice("Type '/stats' to see statistics."); cb.chatNotice("Broadcasters and Mods: Type '/help' to see additional functions."); function checkJar() { if(isItGoing == 1) { if(tipJar>0) { tipJar=tipJar-reduceBy; if(tipJar<0) { resetApp(); } } else { resetApp(); } } cb.setTimeout(checkJar, 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: " + totalTipped,x); } function updateRoomSubject() { cb.changeRoomSubject(multiGoalSubject + ' ' + keepItGoingSubject); } function resetApp() { tipJar = 0; isItGoing = 0; keepItGoingSubject = "[Bummer! It\'s Red light' - Tip to turn it Green]"; updateRoomSubject(); } function chageTimer(x) { if (x == 'Faster') { if (reduceTJ > 1000) { reduceTJ -= 1000; } } else if (x=='Slower') { if (reduceTJ < 60000) { reduceTJ += 1000; } } else if (x=='Fastest') { reduceTJ = 1000; } else if (x=='Slowest') { reduceTJ = 60000; } else if (x=='Pause') { reduceBy=0; } else if (x=='Resume') { reduceBy=resumeShow; } } 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 += "You can control how quickly the Tip Jar empties:\n"; help += "Type '/faster' to speed up emptying the Tip Jar\n"; help += "Type '/slower' to slow down emptying the Tip Jar\n"; help += "Type '/fastest' to set emptying Tip Jar Rate to 1 sec\n"; help += "Type '/slowest' to set emptying Tip Jar Rate to 60 secs\n"; help += "Type '/resume' to resume Tip Jar emptying\n"; help += "Type '/pause' to pause Tip Jar emptying\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: " + totalTipped + "\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); } function getCurrentDestinationDescription() { return cb.settings['destination_' + current_destination + '_description']; } function getCurrentDestinationAmount() { return cb.settings['destination_' + current_destination + '_tokens']; } function checkFinality() { if (getCurrentDestinationAmount() <= 0 || getCurrentDestinationDescription() === "" || current_destination === 6) { final_destination_reached = true; } } function tips_remaining() { var r = getCurrentDestinationAmount() - currentTotalTipped; return (r < 0) ? 0 : r; } function format_username(val) { return (val === null) ? "--" : val.substring(0, 12); } function update_goals() { if (final_destination_reached) { roomSubject = cb.settings.finality_message; multiGoalSubject = roomSubject; subject_is_final = true; } else { multiGoalSubject = roomSubject + ' [Destination ' + current_destination + ': ' + getCurrentDestinationDescription() + ' - ' + tips_remaining() + ' tk left] '; } updateRoomSubject(); } cb.onTip(function (tip) { tipJar += parseInt(tip['amount']); totalTipped += parseInt(tip['amount']); currentTotalTipped += parseInt(tip['amount']); if(isItGoing == 0 && startJourneyMet ==0) { if(tipJar >= startAt) { isItGoing = 1; startJourneyMet = 1; keepItGoingSubject = '[Keep It Going - Don\'t Let the light turn Red]'; } else { keepItGoingSubject = '[Tip ' + (startAt-totalTipped) + ' to start the journey]'; } } else if (isItGoing == 0 && startJourneyMet == 1){ isItGoing = 1; startJourneyMet = 1; keepItGoingSubject = '[Keep It Going - Don\'t Let the light turn Red]'; } checkTip(tip['from_user'],tip['amount']); while (currentTotalTipped >= getCurrentDestinationAmount()) { currentTotalTipped = currentTotalTipped - getCurrentDestinationAmount(); current_destination++; checkFinality(); } update_goals(); cb.drawPanel(); }); cb.onMessage(function (msg) { if (msg['m'] == '/faster' && (msg['user'] == cb.room_slug || msg['is_mod'])) { msg['X-Spam'] = true; chageTimer("Faster"); } else if (msg['m'] == '/fastest' && (msg['user'] == cb.room_slug || msg['is_mod'])) { msg['X-Spam'] = true; chageTimer("Fastest"); } else if (msg['m'] == '/slower' && (msg['user'] == cb.room_slug || msg['is_mod'])) { msg['X-Spam'] = true; chageTimer("Slower"); } else if (msg['m'] == '/slowest' && (msg['user'] == cb.room_slug || msg['is_mod'])) { msg['X-Spam'] = true; chageTimer("Slowest"); } else if (msg['m'] == '/pause' && (msg['user'] == cb.room_slug || msg['is_mod'])) { msg['X-Spam'] = true; chageTimer("Pause"); } else if (msg['m'] == '/resume' && (msg['user'] == cb.room_slug || msg['is_mod'])) { msg['X-Spam'] = true; chageTimer("Resume"); } else 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 (bigTipLocation >= 0) { if (msg['user'] == topTipper[bigTipLocation].username) { msg['background'] = '#ebc3f2'; } } return msg; }); cb.onEnter(function(user) { var notice = "*** Welcome " + user['user'] +" ***\n"; notice += "We are playing Traffic Lights today " + "\n"; notice += "Help me Reach Home by keeping the lights green " + "\n"; notice += "The lights will be Green when the Timer is above: " + green_start + "\n"; notice += "The lights will turn red when the Timer is below: " + orange_time + "\n"; notice += "The lights will be Orange in between " + "\n"; cb.chatNotice(notice); }); function init() { update_goals(); } init();
© Copyright Chaturbate 2011- 2025. All Rights Reserved.