Apps Home
|
My Uploads
|
Create an App
ReprogrammedCom14
Author:
com14v2
Description
Source Code
Launch App
Current Users
Created by:
Com14v2
App Images
// vars var backgroundImage = '1dc547b4-6fb1-4cdb-955a-caa82744761f'; var fontSize = 12; var 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_set_with_0 = false; var goals_hit = 0; cb.settings_choices = [ {name: 'goal_amount', label: 'How many tokens should the goal be for?', type: 'int', minValue: 1, default: 1000}, {name: 'goal_description', label: 'What should the goal be displayed as?', type: 'str', minLength: 1, maxLength: 255}, {name: 'goal_repeat', label: 'Repeat the goal upon completion?', type: 'choice', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes'}, ]; // On Tip cb.onTip(function(tip) { // Check the goal check_goal(tip); // Update last tip amount last_tip(tip); // Check if new high tip check_high_tip(tip); // Update panel cb.drawPanel(); }); function check_goal(tip) { total_tipped += tip['amount'] if (total_tipped > cb.settings.goal_amount) { total_tipped = cb.settings.goal_amount; } if(total_tipped >= cb.settings.goal_amount) { goals_hit++; if(tips_remaining() > 0) { total_tipped = tips_remaining(); } else { total_tipped = 0; } update_subject(true); } else { update_subject(false); } } function last_tip(tip) { last_tip_amount = tip['amount']; last_tip_username = tip['from_user']; } function check_high_tip(tip) { if (tip['amount'] > high_tip_amount) { high_tip_amount = tip['amount']; high_tip_username = tip['from_user']; } } // helper functions function update_subject(goal_hit) { if (tips_remaining() == 0) { if (subject_is_set_with_0) { return; } subject_is_set_with_0 = true; } else { subject_is_set_with_0 = false; } var new_subject = cb.settings.goal_description + " [" + tips_remaining() + " tokens remaining]"; if(goal_hit) { new_subject = "GOAL HIT! " + new_subject; } cb.changeRoomSubject(new_subject); } function tips_remaining() { var r = cb.settings.goal_amount - total_tipped; if (r < 0) { return 0; } else { return r; } } // Update the panel cb.onDrawPanel(function(user) { return { "template": "image_template", "layers": [ {'type': 'image', 'fileID': backgroundImage}, { 'type': 'text', 'text': 'TIPS RECEIVED:', 'top': 5, 'left': 45, 'font-size': fontSize, 'color': 'white', 'font-weight': 'bold' }, { 'type': 'text', 'text': 'HIGHEST TIP:', 'top': 27, 'left': 58, 'font-size': fontSize, 'color': 'white', 'font-weight': 'bold' }, { 'type': 'text', 'text': 'LATEST TIP RECEIVED:', 'top': 48, 'left': 9, 'font-size': fontSize, 'color': 'white', 'font-weight': 'bold' }, { 'type': 'text', 'text': '' + total_tipped + ' / ' + cb.settings.goal_amount, 'top': 5, 'left': 135, 'font-size': fontSize, 'color': 'white', }, { 'type': 'text', 'text': format_username(high_tip_username) + ' (' + high_tip_amount + ')', 'top': 27, 'left': 135, 'font-size': fontSize, 'color': 'white', }, { 'type': 'text', 'text': format_username(last_tip_username) + ' (' + last_tip_amount + ')', 'top': 48, 'left': 135, 'font-size': fontSize, 'color': 'white', }, ], }; }); /* * * * * DO NOT BOTHER BELOW * * * */ function format_username(val) { if (val === null) { return "--"; } else { return val.substring(0, 12); } } function init() { update_subject(); } init();
© Copyright Chaturbate 2011- 2025. All Rights Reserved.