Apps Home
|
Create an App
Recursion goal
Author:
astaea
Description
Source Code
Launch App
Current Users
Created by:
Astaea
// Made by astaea and evilalco // vars 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 second_goal_current = 0; cb.settings_choices = [ {name: 'tokens', type: 'int', minValue: 1, default: 100}, {name: 'goal_description', type: 'str', minLength: 1, maxLength: 255}, {name: 'sequential_tokens', type: 'int', minValue: 1, default: 20}, {name: 'sequential_goal_description', type: 'str', minLength: 1, maxLength: 40} ]; // handlers cb.onTip(function(tip) { if(tip['amount'] == cb.settings.sequential_tokens) { second_goal_current += tip['amount']; second_goal_current = second_goal_current % cb.settings.sequential_tokens; cb.log("Second Goal reached: " + cb.settings.sequential_goal_description); cb.chatNotice("Second Goal reached: " + cb.settings.sequential_goal_description); } else { total_tipped += tip['amount']; if (total_tipped > cb.settings.tokens) { total_tipped = cb.settings.tokens; } } update_subject(); cb.chatNotice("Thanks for the tip!", tip['from_user']); 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) { return { 'template': '3_rows_of_labels', 'row1_label': 'Tip Received / Goal :', 'row1_value': '' + total_tipped + ' / ' + cb.settings.tokens, 'row2_label': '' + cb.settings.sequential_goal_description + ':', 'row2_value': '' + cb.settings.sequential_tokens, 'row3_label': 'Latest Tip Received:', 'row3_value': format_username(last_tip_username) + ' (' + last_tip_amount + ')' }; }); // helper functions function update_subject() { 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 = "Tip anything other than " + cb.settings.sequential_tokens + " to go into the primary goal. " + cb.settings.goal_description + " goal [" + tips_remaining() + " tokens remaining] ~~~" + " Tip EXACTLY " + cb.settings.sequential_tokens + " tokens for " + " " + cb.settings.sequential_goal_description; cb.log("Changing subject to: " + new_subject); cb.changeRoomSubject(new_subject); } function tips_remaining() { var r = cb.settings.tokens - total_tipped; 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.