Apps Home
|
My Uploads
|
Create an App
argoal
Author:
biglebuster
Description
Source Code
Launch App
Current Users
Created by:
Biglebuster
App Images
// vars var bki = 'a226b712-ce9a-4633-8871-7658351bc905' var times_goal_reached = 0; var last_time_goal_reached = null; var current_goal_tipped = 0; cb.settings_choices = [ {name: 'tokens', type: 'int', minValue: 1, default: 100}, {name: 'goal_description', type: 'str', minLength: 1, maxLength: 255} ]; // handlers cb.onTip(function(tip) { current_goal_tipped += tip['amount'] if (current_goal_tipped >= cb.settings.tokens) { goalReached(); } update_subject(); cb.drawPanel(); }); cb.onDrawPanel(function(user) { var tcolor = 'white'; var fontSize = 11; var row3=''; if (times_goal_reached == 0) { row1= 'tks / Goal (Total): '+ '' + current_goal_tipped + ' / ' + cb.settings.tokens + ' (' + ((times_goal_reached * cb.settings.tokens) + current_goal_tipped) + ')'; row2= 'Hit Goal For: '+ '' + times_goal_reached + ' times'; } else { row1= 'tks / Goal (Total): '+ '' + current_goal_tipped + ' / ' + cb.settings.tokens + ' (' + ((times_goal_reached * cb.settings.tokens) + current_goal_tipped) + ')'; row2= 'Hit Goal For: '+'' + times_goal_reached + ' times'; } return { "template": "image_template", "layers": [ {'type': 'image', 'fileID': bki}, { 'type': 'text', 'text': row1, 'top': 5, 'left': (105-0*row1.length*5/2), 'font-size': fontSize, 'color': tcolor, }, { 'type': 'text', 'text': row2, 'top': 29, 'left': 105+0*(135-row2.length*5/2), 'font-size': fontSize, 'color': tcolor, }, { 'type': 'text', 'text': row3, 'top': 50, 'left': (105-0*row3.length*5/2), 'font-size': fontSize, 'color': tcolor, }, ], } }); // Functions function refresh() { cb.log("Refresh called"); cb.setTimeout(refresh, 15000); cb.drawPanel(); } function update_subject() { var new_subject = cb.settings.goal_description + " [" + tips_remaining() + " tokens remaining]"; cb.log("Changing subject to: " + new_subject); cb.changeRoomSubject(new_subject); } function goalReached() { last_time_goal_reached = new Date(); var curr_times_reached = Math.floor(current_goal_tipped / cb.settings.tokens); for (var i = 0; i < curr_times_reached; i++) { times_goal_reached++; current_goal_tipped -= cb.settings.tokens; cb.chatNotice("Goal was reached for the " + getNumberString(times_goal_reached) + " time!"); } } function getNumberString(number) { var numberString = null; if (number == 1) { numberString = "1st"; } else if (number == 2) { numberString = "2nd"; } else if (number == 3) { numberString = "3rd"; } else { numberString = "" + number + "th"; } return (numberString); } function tips_remaining() { var r = cb.settings.tokens - current_goal_tipped; if (r < 0) { return 0; } else { return r; } } function init() { update_subject(); } init(); cb.setTimeout(refresh, 15000);
© Copyright Chaturbate 2011- 2025. All Rights Reserved.