Bots Home
|
Create an App
Goal x 10
Author:
mishiloveshawk
Description
Source Code
Launch Bot
Current Users
Created by:
Mishiloveshawk
// vars var last_tip_username = null; var next_tip_amount = 1; var goal_reached = false; var goal_count = 0; var goal_count1 = 1; var total_tokens = 0; var goal_tokens = 0; var progress = 0; var moons = "\u25EF\u25EF\u25EF\u25EF\u25EF\u25EF\u25EF\u25EF\u25EF\u25EF"; // var version = 10 // Limit goal description as we add some text cb.settings_choices = [ { name: 'goal_value', label: 'goal1', type: 'int', minValue: 1, maxValue: 1000, default: 50 }, { name: 'goal_description', label: 'goal1', type: 'str', minLength: 1, maxLength: 190 }, { name: 'goal_value1', label: 'goal2', type: 'int', required: false, minValue: 0, maxValue: 1000, default: 0 }, { name: 'goal_description1', label: 'goal2', type: 'str', required: false, minLength: 0, maxLength: 190 }, { name: 'goal_value2', label: 'goal3', type: 'int', required: false, minValue: 0, maxValue: 1000, default: 0 }, { name: 'goal_description2', label: 'goal3', type: 'str', required: false, minLength: 0, maxLength: 190 }, { name: 'goal_value3', label: 'goal4', type: 'int', required: false, minValue: 0, maxValue: 1000, default: 0 }, { name: 'goal_description3', label: 'goal4', type: 'str', required: false, minLength: 0, maxLength: 190 }, { name: 'goal_value4', label: 'goal5', type: 'int', required: false, minValue: 0, maxValue: 1000, default: 0 }, { name: 'goal_description4', label: 'goal5', type: 'str', required: false, minLength: 0, maxLength: 190 }, { name: 'goal_value5', label: 'goal6', type: 'int', required: false, minValue: 0, maxValue: 1000, default: 0 }, { name: 'goal_description5', label: 'goal6', type: 'str', required: false, minLength: 0, maxLength: 190 }, { name: 'goal_value6', label: 'goal7', type: 'int', required: false, minValue: 0, maxValue: 1000, default: 0 }, { name: 'goal_description6', label: 'goal7', type: 'str', required: false, minLength: 0, maxLength: 190 }, { name: 'goal_value7', label: 'goal8', type: 'int', required: false, minValue: 0, maxValue: 1000, default: 0 }, { name: 'goal_description7', label: 'goal8', type: 'str', required: false, minLength: 0, maxLength: 190 }, { name: 'goal_value8', label: 'goal9', type: 'int', required: false, minValue: 0, maxValue: 1000, default: 0 }, { name: 'goal_description8', label: 'goal9', type: 'str', required: false, minLength: 0, maxLength: 190 }, { name: 'goal_value9', label: 'goal10', type: 'int', required: false, minValue: 0, maxValue: 1000, default: 0 }, { name: 'goal_description9', label: 'goal10', type: 'str', required: false, minLength: 0, maxLength: 190 }, { name: 'goal_value10', label: 'goal11', type: 'int', required: false, minValue: 0, maxValue: 1000, default: 0 }, { name: 'order', type: 'choice', choice1: 'ascending', choice2: 'descending', default: 'ascending' } ]; cb.onTip( function (tip) { var diff = tip['amount']; total_tokens = total_tokens + diff; goal_tokens = goal_tokens + diff; if (goal_tokens >= cb.settings.goal_value) { if (cb.settings['goal_value' + goal_count ] == 0) { goal_reached = true;} goal_count++; cb.settings.goal_value = cb.settings['goal_value' + goal_count]; cb.settings.goal_description = cb.settings['goal_description' + goal_count]; goal_tokens = 0; } // We set the last tipper only if the tip was counted // (not optimal to do it as many times as the tip counted though) last_tip_username = tip['from_user']; progress = goal_tokens/cb.settings.goal_value*100; progress = parseInt (progress); if (progress == 0 ) {moons = "\u25EF\u25EF\u25EF\u25EF\u25EF\u25EF\u25EF\u25EF\u25EF\u25EF"}; if (progress > 0 && progress <10) {moons = "\u2764\u25EF\u25EF\u25EF\u25EF\u25EF\u25EF\u25EF\u25EF\u25EF"}; if (progress >= 10 && progress <20) {moons = "\u2764\u2764\u25EF\u25EF\u25EF\u25EF\u25EF\u25EF\u25EF\u25EF"}; if (progress >= 20 && progress <30) {moons = "\u2764\u2764\u2764\u25EF\u25EF\u25EF\u25EF\u25EF\u25EF\u25EF"}; if (progress >= 30 && progress <40) {moons = "\u2764\u2764\u2764\u2764\u25EF\u25EF\u25EF\u25EF\u25EF\u25EF"}; if (progress >= 40 && progress <50) {moons = "\u2764\u2764\u2764\u2764\u2764\u25EF\u25EF\u25EF\u25EF\u25EF"}; if (progress >= 50 && progress <60) {moons = "\u2764\u2764\u2764\u2764\u2764\u2764\u25EF\u25EF\u25EF\u25EF"}; if (progress >= 60 && progress <70) {moons = "\u2764\u2764\u2764\u2764\u2764\u2764\u2764\u25EF\u25EF\u25EF"}; if (progress >= 70 && progress <80) {moons = "\u2764\u2764\u2764\u2764\u2764\u2764\u2764\u2764\u25EF\u25EF"}; if (progress >= 80 && progress <90) {moons = "\u2764\u2764\u2764\u2764\u2764\u2764\u2764\u2764\u2764\u25EF"}; if (progress >= 90 && progress <=100) {moons = "\u2764\u2764\u2764\u2764\u2764\u2764\u2764\u2764\u2764\u2764"}; update_subject(); cb.drawPanel(); } ); cb.onDrawPanel( function (user) { if (checkGoalReached()) { return { 'template': '3_rows_11_21_31', 'row1_value': 'Goal reached!', 'row2_value': '', 'row3_value': 'Thanks to all tippers' }; } else { if (isAscendingOrder()) { return { 'template': '3_rows_11_21_31', 'row1_value': 'Collected: ' + goal_tokens + ' (from ' + cb.settings.goal_value + ' tokens)', 'row3_value': 'Goal reached: ' + goal_count + ' times (' + total_tokens + ' tokens)', 'row2_value': moons + '(' + progress + '%)', }; } else { return { 'template': '3_rows_of_labels', 'row1_label': 'Next Tip Needed:', 'row1_value': next_tip_amount, 'row2_label': 'Goal reached:', 'row2_value': goal_count + ' times (' + total_tokens + ' tokens)', 'row3_label': 'Descending:', 'row3_value': 'From ' + cb.settings.goal_value + ' to 1' }; } } } ); // helper functions function update_subject() { if (goal_reached) { return; } var new_subject = ""; if (checkGoalReached()) { new_subject = cb.settings.goal_description + " [Goal reached! Thanks to all tippers.]"; goal_reached = true; } else { if (isAscendingOrder()) { new_subject = cb.settings.goal_description; } else { new_subject = cb.settings.goal_description + " [Tip in descending order from " + cb.settings.goal_value + " to 0. Next tip needed: " + next_tip_amount + "]"; } } cb.changeRoomSubject(new_subject); } function format_username(val) { if (val === null) { return "--"; } else { return val.substring(0, 12); } } function isAscendingOrder() { return (cb.settings.order == 'ascending'); } function setNextTipNeeded() { if (isAscendingOrder()) { next_tip_amount++; } else { next_tip_amount--; } } function checkGoalReached() { if (isAscendingOrder()) { return (next_tip_amount > cb.settings.goal_value); } else { return (next_tip_amount <= 0); } } function init() { if (isAscendingOrder()) { next_tip_amount = 1; } else { next_tip_amount = cb.settings.goal_value; } update_subject(); } init();
© Copyright Chaturbate 2011- 2026. All Rights Reserved.