Apps Home
|
Create an App
Multi-Goal Time Counter
Author:
gargoyle1
Description
Source Code
Launch App
Current Users
Created by:
Gargoyle1
/** * App: Multi-Goal Time Counter * Version: 1.0 * Author: gargoyle1 * Date: 04.11.15 */ 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 goalcount = 1; var goalslots = 0; var timeleft = cb.settings.timer; var textcolor = '#669a5e'; var goalcolor = '#b84040'; cb.settings_choices = [ {name: 'goal', type:'int', minValue:1, maxValue:9999, label:'Tip for Goal', defaultValue:100}, {name: 'timer', type:'int', label:'Goal Timer (minutes)', minValue:5, maxValue:999, defaultValue:30}, {name: 'goal1', type:'str', minLength:1, maxLength:255, label:'Multi-Goal order', defaultValue:'', required:false }, {name: 'goal2', type:'str', minLength:1, maxLength:255, label:'', defaultValue:'', required:false }, {name: 'goal3', type:'str', minLength:1, maxLength:255, label:'', defaultValue:'', required:false }, {name: 'goal4', type:'str', minLength:1, maxLength:255, label:'', defaultValue:'', required:false }, {name: 'goal5', type:'str', minLength:1, maxLength:255, label:'', defaultValue:'', required:false }, {name: 'goal6', type:'str', minLength:1, maxLength:255, label:'', defaultValue:'', required:false }, {name: 'goal7', type:'str', minLength:1, maxLength:255, label:'', defaultValue:'', required:false }, {name: 'goal8', type:'str', minLength:1, maxLength:255, label:'', defaultValue:'', required:false }, {name: 'goal9', type:'str', minLength:1, maxLength:255, label:'', defaultValue:'', required:false }, {name: 'goal10', type:'str', minLength:1, maxLength:255, label:'', defaultValue:'', required:false }, ]; cb.onEnter(function(user) { cb.sendNotice('Multi-Goal Time Counter by Gargoyle1!', user['user'], '', textcolor, 'bold'); cb.sendNotice('Welcome to ' + cb.room_slug + 's time limited Tip goals!', user['user'], '', textcolor, 'bold'); if (cb.settings.goal > 0) { cb.sendNotice('Actual goal is: ' + cb.settings['goal'+goalcount] + '!', user['user'], '', goalcolor, 'bold'); cb.sendNotice('More than ' + timeleft + ' minutes left for goal!', user['user'], '', goalcolor, 'bold'); } }); cb.onTip(function (tip) { total_tipped += tip['amount'] goalcheck(); 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(); username = tip['from_user']; roomsubject(); }); cb.onDrawPanel(function(user) { return { 'template': '3_rows_of_labels', 'row1_label': 'Tip Received / Goal :', 'row1_value': '' + total_tipped + ' / ' + cb.settings.goal, 'row2_label': 'Highest Tip:', 'row2_value': format_username(high_tip_username) + ' (' + high_tip_amount + ')', 'row3_label': 'Latest Tip Received:', 'row3_value': format_username(last_tip_username) + ' (' + last_tip_amount + ')' }; }); function format_username(val) { if (val === null) { return "--"; } else { return val.substring(0, 12); } } function goalcheck() { if (cb.settings.goal > 0) { if (total_tipped >= cb.settings.goal) { total_tipped = total_tipped - cb.settings.goal; cb.sendNotice('Goal reached!', '', '', goalcolor, 'bold'); cb.sendNotice('Thanks to all tippers!', '', '', goalcolor, 'bold'); cb.sendNotice(cb.room_slug + ' get started! ' + cb.settings['goal'+goalcount] + '!', '', '', goalcolor, 'bold'); cb.sendNotice('', '', '', '', ''); goalchange(); goalcheck(); } } } function goalchange() { timeleft = cb.settings.timer; goalcount = goalcount +1; if (goalcount > goalslots) { goalcount = 1; } cb.sendNotice('New goal is: ' + cb.settings['goal'+goalcount] + '!', '', '', goalcolor, 'bold'); cb.sendNotice('', '', '', '', ''); cb.drawPanel(); if (total_tipped < cb.settings.goal) { cb.setTimeout(timecount, 1000); } } function countslots() { for(var i=1;i<=10;i++) { if (cb.settings['goal'+i] != '') { goalslots = goalslots + 1; } } } function roomsubject() { var remaining = cb.settings.goal - total_tipped; cb.changeRoomSubject('Goal is: ' + cb.settings['goal'+goalcount] + ' [' + remaining + ' Token remaining] This Goal is time limited!'); } function timecount() { if (timeleft > 0) { if (timeleft == 1) { cb.sendNotice('Only ' + timeleft + ' minute left for goal!', '', '', textcolor, 'bold'); var remaining = cb.settings.goal - total_tipped; cb.sendNotice('Just ' + remaining + ' Token to finish the goal!', '', '', textcolor, 'bold'); } else { cb.sendNotice(timeleft + ' minutes left for goal!', '', '', textcolor, 'bold'); } timeleft = timeleft - 1; cb.setTimeout(timecount, 60000); } else { cb.sendNotice('Time is up for actual goal!!!', '', '', textcolor, 'bold'); total_tipped = 0; goalchange(); roomsubject(); } } roomsubject(); countslots(); timecount();
© Copyright Chaturbate 2011- 2026. All Rights Reserved.