Apps Home
|
Create an App
stcc
Author:
loulouw
Description
Source Code
Launch App
Current Users
Created by:
Loulouw
// vars var last_tip_username = null; var next_tip_amount = 1; var goal_reached = false; // var version = 10 var pw = 'off' var notTowardArray = [401, 601, 801, 1001, 2001] var pmPrivateShowArray = [] // Limit goal description as we add some text cb.settings_choices = [ { name: 'goal_description', type: 'str', minLength: 1, maxLength: 190 }, { name: 'start_value', type: 'int', minValue: 1, default: 1 }, { name: 'goal_value', type: 'int', minValue: 1, default: 50 }, { name: 'order', type: 'choice', choice1: 'ascending', choice2: 'descending', default: 'ascending' }, ]; cb.onTip( function (tip) { var diff = tip['amount']; var old_tip_amount = next_tip_amount; /*if ( tip['amount'] == 22 && privateShow && !pmPrivateShowArray.includes(tip['from_user']) ) { pmPrivateShowArray.push(name) } else if (pmPrivateShowArray.includes(tip['from_user']) { }*/ while (diff > 0 && !checkGoalReached() && !notTowardArray.includes(diff)) { diff -= next_tip_amount; if (diff >= 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']; setNextTipNeeded(); } } if (old_tip_amount != next_tip_amount) { //if(!notTowardArray.includes(tip['amount'])) { cb.chatNotice('prize') } if (checkGoalReached()) { cb.chatNotice('-------- Goal reached --------\n \u26AB '+cb.settings.goal_description+' \n--------------------------------------','','','#ea0202','bold') // lou /*if (cb.settings.goal_description.indexOf('(hc)') != -1 || cb.settings.goal_description.indexOf('hidden') != -1) { if (cb.settings.goal_description.indexOf('BJ') != -1) { cb.chatNotice('Type /cam 2 et /cam start',cb.room_slug) } else if (cb.settings.goal_description.indexOf('kitty') != -1) { cb.chatNotice('Type /cam 3 et /cam start',cb.room_slug) } else (cb.settings.goal_description.indexOf('cum') != -1) { cb.chatNotice('Type /cam 2 et /cam start',cb.room_slug) } }*/ } 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_of_labels', 'row1_label': 'Next Tip Needed:', 'row1_value': next_tip_amount, 'row2_label': 'Last Tip From:', 'row2_value': format_username(last_tip_username), 'row3_label': 'Ascending:', 'row3_value': 'From 1 to ' + cb.settings.goal_value }; } else { return { 'template': '3_rows_of_labels', 'row1_label': 'Next Tip Needed:', 'row1_value': next_tip_amount, 'row2_label': 'Last Tip From:', 'row2_value': format_username(last_tip_username), 'row3_label': 'Descending:', 'row3_value': 'From ' + cb.settings.goal_value + ' to 0' }; } } } ); // 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 = 'Goal :'+cb.settings.goal_description+' @ '+cb.settings.goal_value+ " [Tip in ascending order from 1 to "+cb.settings.goal_value+". Next tip needed: " + next_tip_amount + "]"; } else { new_subject = 'Goal :'+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 series_tot(first,last) { return (Math.abs(last-first) + 1) * (last + first) * 0.5; } 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(); cb.chatNotice('Total tokens = ' + Math.abs(series_tot(cb.settings.start_value,cb.settings.goal_value)),cb['room_slug']); } init();
© Copyright Chaturbate 2011- 2025. All Rights Reserved.