Bots Home
|
Create an App
Tip Goal edit
Author:
veganslutt
Description
Source Code
Launch Bot
Current Users
Created by:
Veganslutt
/* Name: Multi-Goal Author: mx2k6 Version History ============================================ v1.0 08/02/2013: First release Credits and Props ============================================ Based on the bog standard tip goal app, with multiple goals. I can't believe noone had thought of it yet! */ // vars var total_tipped = 0; var current_total_tipped = 0; var high_tip_username = null; var high_tip_amount = 0; var last_tip_username = null; var last_tip_amount = 0; var subject_is_final = false; var current_goal = 1; var final_goal_met = false; cb.settings_choices = [ {name: 'goal_1_tokens', label: 'Goal 1 Token Amount', type: 'int', minValue: 1, defaultValue: 100}, {name: 'goal_1_description', label: 'Goal 1 Description', type: 'str', defaultValue:'Doggy Style'}, {name: 'goal_2_tokens', label: 'Goal 2 Token Amount', type: 'int', minValue: 1, defaultValue: 200, required: false}, {name: 'goal_2_description', label: 'Goal 2 Description', type: 'str', defaultValue:'Hot strip dance'}, {name: 'goal_3_tokens', label: 'Goal 3 Token Amount', type: 'int', minValue: 1, defaultValue: 300, required: false}, {name: 'goal_3_description', label: 'Goal 3 Description', type: 'str', defaultValue:'Completly naked'}, {name: 'finality_message', label: 'Final Goal Met Subject', type: 'str', minLength: 1, maxLength: 255, defaultValue: 'Goal reached! Thanks to all tippers!'}, {name: 'highlight_goal_king', label: 'Highlight highest tipper', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes'} ]; function getCurrentGoalDescription() { return cb.settings['goal_' + current_goal + '_description']; } function getCurrentGoalAmount() { return cb.settings['goal_' + current_goal + '_tokens']; } function checkFinality() { if (getCurrentGoalAmount() <= 0 || getCurrentGoalDescription() === "" || current_goal === 6) { final_goal_met = true; } } function tips_remaining() { var r = getCurrentGoalAmount() - current_total_tipped; return (r < 0) ? 0 : r; } function format_username(val) { return (val === null) ? "--" : val.substring(0, 12); } function update_goals() { var new_subject = ""; if (subject_is_final) { return; } if (final_goal_met) { new_subject = cb.settings.finality_message; subject_is_final = true; } else { new_subject = getCurrentGoalDescription() + " [" + tips_remaining() + " tokens remaining]"; } cb.log("Changing subject to: " + new_subject); cb.changeRoomSubject(new_subject); } cb.onTip(function (tip) { total_tipped += tip.amount; current_total_tipped += tip.amount; while (current_total_tipped >= getCurrentGoalAmount()) { current_total_tipped = current_total_tipped - getCurrentGoalAmount(); current_goal++; checkFinality(); } update_goals(); last_tip_amount = tip.amount; last_tip_username = tip.from_user; if (tip.amount > high_tip_amount) { high_tip_amount = tip.amount; high_tip_username = tip.from_user; } cb.drawPanel(); }); cb.onDrawPanel(function (user) { var panel = {}; if (final_goal_met) { panel = { 'template': '3_rows_of_labels', 'row1_label': 'Total Tips:', 'row1_value': total_tipped, 'row2_label': 'Highest Tip:', 'row2_value': format_username(high_tip_username) + ' (' + high_tip_amount + ')', 'row3_label': 'Latest Tip Received:', 'row3_value': format_username(last_tip_username) + ' (' + last_tip_amount + ')' }; } else { panel = { 'template': '3_rows_of_labels', 'row1_label': 'Tip Received / Goal (Total):', 'row1_value': current_total_tipped + ' / ' + getCurrentGoalAmount() + ' (' + total_tipped + ')', 'row2_label': 'Highest Tip:', 'row2_value': format_username(high_tip_username) + ' (' + high_tip_amount + ')', 'row3_label': 'Latest Tip Received:', 'row3_value': format_username(last_tip_username) + ' (' + last_tip_amount + ')' }; } return panel; }); cb.onMessage(function (msg) { if (cb.settings.highlight_goal_king === "Yes" && msg.user === high_tip_username) { msg.background = '#9F9'; } return msg; }); function init() { update_goals(); } init();
© Copyright Chaturbate 2011- 2026. All Rights Reserved.