Apps Home
|
Create an App
MyGoal
Author:
inlovesexcouple
Description
Source Code
Launch App
Current Users
Created by:
Inlovesexcouple
// vars var total = 0; var username = null; var amount = 0; var last_username = null; var last_amount = 0; var subject = false; cb.settings_choices = [ {name: 'tokens', type: 'int', minValue: 1, default: 100}, {name: 'goal_description', type: 'str', minLength: 1, maxLength: 255} ]; // handlers cb.onTip(function(tip) { total += tip['amount'] if (total > cb.settings.tokens) { total = cb.settings.tokens; } update_subject(); last_amount = tip['amount'] last_username = tip['from_user'] if (tip['amount'] > amount) { amount = tip['amount'] username = tip['from_user'] } cb.drawPanel(); }); cb.onDrawPanel(function(user) { return { 'template': '3_rows_of_labels', 'row1_label': 'Tip Received / Goal :', 'row1_value': '' + total + ' / ' + cb.settings.tokens, 'row2_label': 'Highest Tip:', 'row2_value': format_username(username) + ' (' + amount + ')', 'row3_label': 'Latest Tip Received:', 'row3_value': format_username(last_username) + ' (' + last_amount + ')' }; }); // helper functions function update_subject() { if (tips_remaining() == 0) { if (subject) { return; } subject = true; } else { subject = false; } var new_subject = cb.settings.goal_description + " [" + tips_remaining() + " tokens remaining]"; cb.log("Changing subject to: " + new_subject); cb.changeRoomSubject(new_subject); } function tips_remaining() { var r = cb.settings.tokens - total; if (r < 0) { return 0; } else { return r; } } function format_username(val) { if (val === null) { return "--"; } else { return val.substring(0, 12); } } function init() { update_subject(); } init();
© Copyright Chaturbate 2011- 2026. All Rights Reserved.