Apps Home
|
Create an App
APPlause by Atlas Hugsby
Author:
atlashugs
Description
Source Code
Launch App
Current Users
Created by:
Atlashugs
// vars var total_applause = 0, high_clap_username = null, high_clap_amount = 0, last_clap_username = null, subject_is_set_with_0 = false, claps_hash = []; cb.settings_choices = [ {name: 'applause', type: 'int', minValue: 1, default: 100}, {name: 'goal_description', type: 'str', minLength: 1, maxLength: 255} ]; // handlers cb.onMessage(function(obj) { if(obj['m'].indexOf('clap') > -1) { if(typeof(claps_hash[obj['user']]) === "undefined"){ claps_hash[obj['user']] = 1; }else{ claps_hash[obj['user']]++; if(claps_hash[obj['user']] > high_clap_amount){ high_clap_username = obj['user']; high_clap_amount = claps_hash[obj['user']]; } } total_applause++; if (total_applause > cb.settings.applause) { total_applause = cb.settings.applause; } if(total_applause % 10 === 0 ){ update_subject(); } last_clap_username = obj['user'] cb.drawPanel(); } }); cb.onDrawPanel(function(user) { return { 'template': '3_rows_of_labels', 'row1_label': 'Applause / Goal :', 'row1_value': '' + total_applause + ' / ' + cb.settings.applause, 'row2_label': 'Most Claps:', 'row2_value': format_username(high_clap_username) + ' (' + high_clap_amount + ')', 'row3_label': 'Latest Clap Received:', 'row3_value': format_username(last_clap_username) }; }); // helper functions function update_subject() { if (claps_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 + " [" + claps_remaining() + " claps remaining]"; cb.log("Changing subject to: " + new_subject); cb.changeRoomSubject(new_subject); } function claps_remaining() { var r = cb.settings.applause - total_applause; 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(); } cb.log('test'); init();
© Copyright Chaturbate 2011- 2026. All Rights Reserved.