Apps Home
|
Create an App
Looping Tip [goal] App
Author:
justin4case
Description
Source Code
Launch App
Current Users
Created by:
Justin4case
var next_tip_amount = null; var last_username = null; var max_tip_sequence = null; var repeat_sequence = cb.settings.stage1_repeat_sequence; var total_goal_count = null; var goal_reached = false; var mini_goal_count = null; 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 changed_name = 0; var subject_is_set_with_0 = false; // Limit goal description as we add some text cb.settings_choices = [ { name: 'stage1_mini_goal_descr', type: 'str', minLength: 1, maxLength: 190, label:"Goal 1 Description" }, { name: 'stage1_seqence_number', type: 'int', minValue: 1, maxValue: 1000, default: 20, label:"Goal 1 Sequence Amount" }, { name: 'stage1_repeat_sequence', type: 'int', minValue: 1, maxValue: 1000, default: 2, label:"Times to repeat sequence 1" }, { name: 'stage2_mini_goal_descr', type: 'str', minLength: 1, maxLength: 190, label:"Goal 2 Description" }, { name: 'stage2_seqence_number', type: 'int', minValue: 1, maxValue: 1000, default: 15, label:"Goal 2 Sequence Amount" }, { name: 'stage2_repeat_sequence', type: 'int', minValue: 1, maxValue: 1000, default: 5, label:"Times to repeat sequence 2" }, { name: 'stage3_mini_goal_descr', type: 'str', minLength: 1, maxLength: 190, label:"Goal 3 Description" }, { name: 'stage3_seqence_number', type: 'int', minValue: 1, maxValue: 1000, default: 10, label:"Goal 3 Sequence Amount" }, { name: 'stage3_repeat_sequence', type: 'int', minValue: 1, maxValue: 1000, default: 13, label:"Times to repeat sequence 3" } ]; cb.onTip( function (tip) { total_tipped += tip['amount'] if (total_goal_count < 3) { var tipAmt = tip['amount']; while ((tipAmt > 0) && (!GoalReached())) { tipAmt -= next_tip_amount; if (tipAmt >= 0) { last_username = tip['from_user']; next_tip_amount++; change_room_subject(); } } //change_room_subject(); cb.drawPanel(); } if (total_goal_count >= 3) { if (total_tipped > cb.settings.tokens) { total_tipped = cb.settings.tokens; } update_subject(); 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) { if (goal_reached) { return { 'template': '3_rows_of_labels', 'row1_label': 'Total Tips Received:', 'row1_value': total_tipped, 'row2_label': 'Prince Charming:', 'row2_value': format_username(high_tip_username) + ' (' + high_tip_amount + ')', 'row3_label': 'Last Tip From:', 'row3_value': format_username(last_tip_username) + ' (' + last_tip_amount + ')' }; } if (total_goal_count == 0) { 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_username), 'row3_label': 'Tip In Order:', 'row3_value': 'from 1 to ' + cb.settings.stage1_seqence_number }; } if (total_goal_count == 1) { 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_username), 'row3_label': 'Tip In Order:', 'row3_value': 'from 1 to ' + cb.settings.stage2_seqence_number }; } if (total_goal_count == 2) { 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_username), 'row3_label': 'Tip In Order:', 'row3_value': 'from 1 to ' + cb.settings.stage3_seqence_number }; } } ); function format_username(val) { if (val == null) { return "--"; } else { // return val.substring(0, 12); return val; } } function change_room_subject() { var subject = ""; if (MiniGoalReached()) { if (repeat_sequence > 0) { if (total_goal_count == 0) { cb.chatNotice("Sequence completed for " + cb.settings.stage1_mini_goal_descr, '', '#fcb2bf', '#000000', 'bold'); subject = cb.settings.stage1_mini_goal_descr + " [Tip In Order From 1 to " + cb.settings.stage1_seqence_number + "] [Sequences Left to Complete: " + repeat_sequence + "]"; cb.changeRoomSubject(subject); } if (total_goal_count == 1) { cb.chatNotice("Sequence completed for " + cb.settings.stage2_mini_goal_descr, '', '#fcb2bf', '#000000', 'bold'); subject = cb.settings.stage2_mini_goal_descr + " [Tip In Order From 1 to " + cb.settings.stage2_seqence_number + "] [Sequences Left to Complete: " + repeat_sequence + "]"; cb.changeRoomSubject(subject); } if (total_goal_count == 2) { cb.chatNotice("Sequence completed for " + cb.settings.stage3_mini_goal_descr, '', '#fcb2bf', '#000000', 'bold'); subject = cb.settings.stage3_mini_goal_descr + " [Tip In Order From 1 to " + cb.settings.stage3_seqence_number + "] [Sequences Left to Complete: " + repeat_sequence + "]"; cb.changeRoomSubject(subject); } } } if (GoalReached()) { goal_reached = true; subject = cb.settings.goal_descr + " [Goal reached! Thank you all Tippers.]"; // broadcast to room and performer goal! if (total_goal_count == 0) { cb.chatNotice("Goal was reached for " + cb.settings.stage1_mini_goal_descr, '', '#fcb2bf', '#000000', 'bold'); } if (total_goal_count == 1) { cb.chatNotice("Goal was reached for " + cb.settings.stage2_mini_goal_descr, '', '#fcb2bf', '#000000', 'bold'); } if (total_goal_count == 2) { cb.chatNotice("Goal was reached for " + cb.settings.stage3_mini_goal_descr, '', '#fcb2bf', '#000000', 'bold'); total_goal_count++; StartShow(); } total_goal_count++; if (total_goal_count == 1) { StartGoal2(); subject = cb.settings.stage2_mini_goal_descr + " [Tip In Order From 1 to " + cb.settings.stage2_seqence_number + "] [Sequences Left to Complete: " + repeat_sequence + "]"; cb.changeRoomSubject(subject); } if (total_goal_count == 2) { StartGoal3(); subject = cb.settings.stage3_mini_goal_descr + " [Tip In Order From 1 to " + cb.settings.stage3_seqence_number + "] [Sequences Left to Complete: " + repeat_sequence + "]"; cb.changeRoomSubject(subject); } } } // Set the Next Tip Amount // Increase the mini_goal_count if next_tip_amount > 10 function MiniGoalReached() { if (total_goal_count == 0) { if (next_tip_amount > cb.settings.stage1_seqence_number) { next_tip_amount = 1; mini_goal_count++; repeat_sequence = cb.settings.stage1_repeat_sequence - mini_goal_count; return true; } } if (total_goal_count == 1) { if (next_tip_amount > cb.settings.stage2_seqence_number) { next_tip_amount = 1; mini_goal_count++; repeat_sequence = cb.settings.stage2_repeat_sequence - mini_goal_count; return true; } } if (total_goal_count == 2) { if (next_tip_amount > cb.settings.stage3_seqence_number) { next_tip_amount = 1; mini_goal_count++; repeat_sequence = cb.settings.stage3_repeat_sequence - mini_goal_count; return true; } } return false; } function GoalReached() { if (mini_goal_count >= max_tip_sequence) { return true; } return false; } cb.onMessage(function (msg) { if (msg['user'] == high_tip_username) { msg['background'] = '#ffe0fe'; } if (msg['is_mod']) { if (msg['m'] == '/next' || msg['m'] == '[Astronaut Cat] /next' || msg['m'] == '[Alien Cat] /next' || msg['m'] == '[King Cat] /next' || msg['m'] == '[Unicorn Cat] /next') { if (total_goal_count <= 2) { cb.chatNotice(":next" + next_tip_amount); } else { cb.chatNotice("Tip if you enjoy " +cb.room_slug+ "'s Show!", '', '#fcb2bf', '#000000', 'bold'); } } } return msg; }); function update_subject() { total_goal_count = 3; goal_reached = true; if (tips_remaining() == 0) { if (subject_is_set_with_0) { return; } subject_is_set_with_0 = true; } else { subject_is_set_with_0 = false; } } 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 notifyGoal() { if (total_goal_count <= 2) { cb.chatNotice(":next" + next_tip_amount); cb.setTimeout(notifyGoal, 450000) } else { cb.chatNotice("Tip if you enjoy " +cb.room_slug+ "'s Show!", '', '#fcb2bf', '#000000', 'bold'); cb.setTimeout(notifyGoal, 450000) } } // Initialize Application function init() { cb.setTimeout(notifyGoal, 300000) next_tip_amount = 1; // Calculate the Tip Sequence and set Ascending Order max_tip_sequence = cb.settings.stage1_repeat_sequence; repeat_seqence = cb.settings.stage1_repeat_sequence; total_goal_count = 0; goal_reached = false; mini_goal_count = 0; last_username = "No Tipper"; // if the sequence needs to be restarted // subtract from the max_tip_sequence if (cb.settings.restart_sequence > 0) { max_tip_sequence -= cb.settings.restart_sequence; } // Update the Subject with tip and goal subject = cb.settings.stage1_mini_goal_descr + " [Tip In Order From 1 to " + cb.settings.stage1_seqence_number + "] [Sequences Left to Complete: " + repeat_sequence + "]"; cb.changeRoomSubject(subject); } function StartGoal2() { next_tip_amount = 1; // Calculate the Tip Sequence and set Ascending Order max_tip_sequence = cb.settings.stage2_repeat_sequence; repeat_seqence = cb.settings.stage2_repeat_sequence; total_goal_count = 1; goal_reached = false; mini_goal_count = 0; repeat_sequence = cb.settings.stage2_repeat_sequence - mini_goal_count; // if the sequence needs to be restarted // subtract from the max_tip_sequence if (cb.settings.restart_sequence > 0) { max_tip_sequence -= cb.settings.restart_sequence; } // Update the Subject with tip and goal change_room_subject(); } function StartGoal3() { next_tip_amount = 1; // Calculate the Tip Sequence and set Ascending Order max_tip_sequence = cb.settings.stage3_repeat_sequence; repeat_seqence = cb.settings.stage3_repeat_sequence; total_goal_count = 2; goal_reached = false; mini_goal_count = 0; repeat_sequence = cb.settings.stage3_repeat_sequence - mini_goal_count; // if the sequence needs to be restarted // subtract from the max_tip_sequence if (cb.settings.restart_sequence > 0) { max_tip_sequence -= cb.settings.restart_sequence; } // Update the Subject with tip and goal change_room_subject(); } function StartShow() { next_tip_amount = 1; max_tip_sequence = cb.settings.stage3_repeat_sequence; repeat_seqence = cb.settings.stage3_repeat_sequence; total_goal_count = 3; goal_reached = true; mini_goal_count = 0; repeat_sequence = cb.settings.stage3_repeat_sequence - mini_goal_count; // if the sequence needs to be restarted // subtract from the max_tip_sequence if (cb.settings.restart_sequence > 0) { max_tip_sequence -= cb.settings.restart_sequence; } // Update the Subject with tip and goal var new_subject = "Welcome to " + cb.room_slug + "'s Room"; cb.changeRoomSubject(new_subject); change_room_subject(); update_subject(); } init();
© Copyright Freesexcam 2011- 2024. All Rights Reserved.