Apps Home
|
Create an App
Moon_goal_war
Author:
aerari
Description
Source Code
Launch App
Current Users
Created by:
Aerari
// vars var last_tip_username = null; var next_tip_amount = 1; var goal_reached = false; var goal_count = 0; var goal_count1 = 1; var total_tokens = 0; var goal_tokens = 0; var goal_win = 0; var progress = 0; // var version = 10 // Limit goal description as we add some text cb.settings_choices = [ { name: 'goal_value', label: 'goal1', type: 'int', minValue: 1, maxValue: 2000, default: 50 }, { name: 'goal_description1', label: 'goal2', type: 'str', required: false, minLength: 0, maxLength: 190 }, { name: 'goal_description2', label: 'goal3', type: 'str', required: false, minLength: 0, maxLength: 190 }, { name: 'goal_description3', label: 'goal4', type: 'str', required: false, minLength: 0, maxLength: 190 }, { name: 'goal_description4', label: 'goal5', type: 'str', required: false, minLength: 0, maxLength: 190 }, ]; var goal_type = [0,0,0,0]; var goal_label = [cb.settings.goal_description1,cb.settings.goal_description2,cb.settings.goal_description3,cb.settings.goal_description4] cb.onTip( function (tip) { var j=0 var amount = parseInt(tip['amount']); var tip_message = (tip['message']); for (i=0;i<=3;i++) { j=i+1; if (j==tip_message) { total_tokens = total_tokens + amount; goal_type[i] = goal_type[i] + amount; } } if (total_tokens >= cb.settings.goal_value) { goal_reached = true; } for (i=1;i<=4;i++) { if (goal_tokens < goal_type[i]) { goal_tokens = goal_type[i]; goal_win = goal_label[i]; } } update_subject(); cb.drawPanel(); } ); cb.onDrawPanel( function (user) { if (goal_reached){ return { 'template': '3_rows_11_21_31', 'row1_value': 'Goal reached!', 'row2_value': 'Goal: '+ goal_win, 'row3_value': 'Thanks for all tippers!' }; } else {return { 'template': '3_rows_11_22_32', 'row1_label': 'Chose next goal:'+total_tokens+'('+cb.settings.goal_value+')', 'row2_label': '1 - '+ goal_label[0]+'('+goal_type[0]+')', 'row2_value': '2 - '+ goal_label[1]+'('+goal_type[1]+')', 'row3_label': '3 - '+ goal_label[2]+'('+goal_type[2]+')', 'row3_value': '4 - '+ goal_label[3]+'('+goal_type[3]+')' }; }} ); // helper functions function update_subject() { var new_subject = ""; if (goal_reached) { new_subject = "Goal: " + goal_win + " [Goal reached! Thanks to all tippers.]"; goal_reached = true; } else { new_subject = "Type number of goal you want to reach in tip note: 1 - " + goal_label[0] + " 2 - " + goal_label[1] + " 3 - " + goal_label[2] + " 4 - " + goal_label[3] + ", 1 token = 1 vote, " + total_tokens + " from " + cb.settings.goal_value } cb.changeRoomSubject(new_subject); } function init() { update_subject(); } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.