Apps Home
|
Create an App
Multi-Goal Marries TipJar
Author:
roxy1131
Description
Source Code
Launch App
Current Users
Created by:
Roxy1131
cb.settings_choices = [ {name: 'admins', label: '[GENERAL SETUP] ------------- Admins', type: 'str', defaultValue: 'codeanon', required: false}, {name: 'color', label: 'Text color', type: 'str', defaultValue: '#990000', required: false}, {name: 'capacity', label: 'Tip jar capacity', type: 'int', minValue: 1, defaultValue: 900}, {name: 'init', label: 'Amount initially in tip jar', type: 'int', minValue: 0, defaultValue: 242}, {name: 'delay', label: 'Pause the timer for how many seconds after a tip', type: 'int', minValue: 0, defaultValue: 10}, {name: 'pause_minimum', label: 'Minimum tip amount needed to pause the timer', type: 'int', minValue: 1, defaultValue: 10}, {name: 'obj1_name', label: '[OBJECTIVES] ------------- Objective 1 Name', type: 'str', defaultValue: 'topless'}, {name: 'obj1_rate', label: 'Objective 1 drain rate', type: 'int', minValue: 1, defaultValue: 24}, {name: 'obj2_name', label: 'Objective 2 Name', type: 'str', defaultValue: 'naked', required: false}, {name: 'obj2_rate', label: 'Objective 2 Drain Rate', type: 'int', minValue: 1, defaultValue: 24, required: false}, {name: 'obj2_goal', label: 'Objective 2 Goal Amount', type: 'int', defaultValue: 1000}, {name: 'obj3_name', label: 'Objective 3 Name', type: 'str', defaultValue: 'hitachi torture', required: false}, {name: 'obj3_rate', label: 'Objective 3 Drain Rate', type: 'int', minValue: 1, defaultValue: 24, required: false}, {name: 'obj3_goal', label: 'Objective 3 Goal Amount', type: 'int', defaultValue: 2500}, {name: 'obj4_name', label: 'Objective 4 Name', type: 'str', required: false}, {name: 'obj4_rate', label: 'Objective 4 Drain Rate', type: 'int', minValue: 1, required: false}, {name: 'obj4_goal', label: 'Objective 4 Goal Amount', type: 'int', defaultValue: 5000}, {name: 'obj5_name', label: 'Objective 5 Name', type: 'str', required: false}, {name: 'obj5_rate', label: 'Objective 5 Drain Rate', type: 'int', minValue: 1, required: false}, {name: 'obj5_goal', label: 'Objective 5 Goal Amount', type: 'int', defaultValue: 7000}, {name: 'double_time', label: '[ENHANCEMENTS] ------------- Double the drain rate without tips for __ minutes', type: 'int', minvalue: 0, defaultValue: 3}, {name: 'double_minimum', label: 'Minimum tip required to remove/prevent the multiplier', type: 'int', minValue: 1, defaultValue: 10}, {name: 'double_stack', label: 'How many times the multiplier can be doubled', type: 'int', minValue: 1, defaultValue: 2}, {name: 'subj', label: 'Room subject', type: 'str', defaultValue: '[objective] while the jar isn\'t empty! #bigboobs #hitachi #tipjar', required: false}, {name: 'reminder', label: 'Show reminder every ___ minutes', type: 'int', minValue: 0, defaultValue: 3} ]; /*-------------------- //////// SETUP /////// --------------------*/ var $ = cb.settings ? JSON.parse(JSON.stringify(cb.settings)) : {}; var admins = $.admins ? $.admins.toLowerCase().split(/\s*,\s*/) : []; var say = (text, user, fg, bg, wt) => cb.sendNotice(newLines(text), user, bg, fg || $.color || '#990000', wt || 'bold'); var newLines = (input) => '|\u2007 ' + input.replace(/\n/g, '\n|\u2007 '); var delaySecs = 0; var doubleSecs = $.double_time * 60; var multiplier = 0; var tipCount = 0; var amountInJar = $.init || 0; var jarCapacity = $.capacity || 500; var empty = amountInJar === 0; $.rate = $.obj1_rate; var goals = function () { var arr = []; for (var i = 1; i < 6; i++) { var name = $['obj' + i + '_name']; var rate = $['obj' + i + '_rate']; var goal = $['obj' + i + '_goal']; if (name && goal) { arr.push({ name: name, rate: rate, goal: goal }); } } arr.sort((a,b) => a.goal - b.goal); return arr; }(); /*-------------------- /////// TIMERS /////// --------------------*/ (function drainTimer () { var r = Math.floor($.rate * Math.pow(2, multiplier) / 12); cb.setTimeout (function () { if (delaySecs <= 0) { cb.log('Draining ' + r + ' from tip jar...') if (amountInJar > r) { checkJar(r); } else { amountInJar = 0; if (!empty) { alertEmptyJar(); empty = true; multiplier = 0; } } cb.drawPanel(); } else { cb.log('Delay active, waiting...'); } drainTimer(); }, 5000); })(); function checkJar(num) { var initRatio = Math.floor(amountInJar * 100/jarCapacity); amountInJar = Math.min(amountInJar - num, jarCapacity); var num = Math.floor(amountInJar * 100/jarCapacity); if (initRatio > 5 && num <= 5) alertAlmostEmptyJar(); } (function delayTimer () { cb.setTimeout(function delay() { if (delaySecs) delaySecs--; delayTimer(); }, 1000); })(); (function doubleTimer () { cb.setTimeout(function () { if ($.double_time) { if (doubleSecs) { doubleSecs--; } else { doubleSecs = $.double_time * 60; if (multiplier) alertMultiplier(); if (multiplier < $.double_stack && !empty) { multiplier++; } } } doubleTimer(); }, 1000); })(); /*-------------------- /////// DISPLAY ////// --------------------*/ var light = '\u2591'; var mid = '\u2592'; var dark = '\u2593'; var black = '\u2588'; function displayJar() { if (amountInJar >= jarCapacity) return black.repeat(10); var num = Math.floor(amountInJar * 100/jarCapacity); var p = (Math.min(num, 100) + '').split(''); var ones = Number(p.pop()); var tens = Number(p.pop()); var output = black.repeat(tens) + displayOnes(ones); output = output + light.repeat(10 - output.length); return output; } function displayOnes(num) { if (num < 4) return light; if (num < 7) return mid; return dark; } function displayGoals () { if (goals[0]) return 'S&A GOAL: ' + goals[0].name + ' (' + tipCount + '/' + goals[0].goal + ' tks)'; return 'All goals reached Thanks!'; } cb.onDrawPanel(function () { var g = displayGoals(); return { template: '3_rows_12_21_31', row1_label: 'Keep the show going! \u2007', row1_value: '\u2007 JAR: [' + amountInJar + '/' + jarCapacity + ']', row2_value: 'EMPTY | ' + displayJar() + ' | FULL', row3_value: displayGoals() }; }); cb.onDrawPanel(function(user) { return { 'template': '3_rows_12_22_31', 'row1_label': 'Tip Received / Goal :', 'row1_value': '0', 'row2_label': 'Highest Tip:', 'row2_value': user['user'], 'row3_value': '0' }; }); /*------------------ /////// TIPS /////// ------------------*/ cb.onTip(doTip); function doTip(tip) { empty = false; tipCount += tip.amount; amountInJar = Math.min(amountInJar + tip.amount, jarCapacity); calcGoals(); checkDelay(tip.amount); checkDouble(tip.amount); cb.drawPanel(); } function checkDelay (num) { if (num >= $.pause_minimum) delaySecs = $.delay; } function checkDouble (num) { if (num >= $.double_minimum) { doubleSecs = $.double_time * 60; if (multiplier) say('Multiplier removed!'); multiplier = 0; } } function calcGoals() { while (goals[0] && tipCount >= goals[0].goal) { var newGoal = goals.shift(); $.objective = newGoal.name; if (newGoal.rate) $.rate = newGoal.rate; say(':starx\nGOAL REACHED - ' + $.objective + '\n:starx'); if ($.subj) cb.changeRoomSubject($.subj.replace('[objective]', $.objective).replace('[obj]', $.objective)); } } /*--------------------------- /////// COMMUNICATION /////// ---------------------------*/ cb.onMessage(function (msg) { if (msg.m.charAt(0) === '/') { msg['X-Spam'] = true; if (admins.includes(msg.user)) cmd(msg.m.slice(1), msg.user); } }); cb.onEnter((user) => showOnEnter(user.user)); function cmd (data, user) { data = data.split(/\s+/); switch(data[0].toLowerCase()) { case '#': evaluate(data.slice(1).join(' '), user); break; case 'dotip': doTip({from_user: user, amount: Number(data[1]) || 10}); break; case 'subj': var newSubj = data.slice(1).join(' '); if (newSubj) { $.subj = newSubj; cb.changeRoomSubject($.subj.replace('[objective]', $.objective).replace('[obj]', $.objective)); } break; case 'rate': if (Number(data[1])) { $.rate = Math.floor(Number(data[1])); } break; case 'pause': delaySecs = Infinity; say('Drain paused!'); break; case 'resume': delaySecs = 0; say('Drain resumed!'); break; } } function evaluate(str, user) { try { var result = eval(str); var notice = 'INPUT: ' + str + '\nTYPE: ' + typeof result + '\nVALUE: '; result === void 0 ? notice += 'undefined' : notice += JSON.stringify(result, null, '\u2007\u2007\u2007\u2007'); cb.setTimeout(() => {cb.sendNotice(newLines(notice), user, '', '#00CC00', '', '')}, 100); } catch (e) { cb.setTimeout(() => {cb.sendNotice(newLines(e.name + ': ' + e.message), user, '', '#FF0000', '', '')}, 100); } cb.drawPanel(); } function alertMultiplier () { say(':tipjarx_mult\nJar is draining ' + Math.pow(2, multiplier) + 'X as fast as normal!\nTip ' + $.double_minimum + ' or more to remove the multiplier!'); } function alertEmptyJar () { say(':tipjarx_empty\nKeep tipping to keep the show going! \n :tipjarkeep 1 Token – 2 Seconds'); } function alertAlmostEmptyJar () { say(':tipjarx_warning\nKeep tipping to keep the show going! \n :tipjarkeep \n-------------------'); } function showOnEnter (user) { say('-------------------\nKeep the tip jar from running out and the show continues!\n-------------------\n :insertTokens \n-------------------', user); } ///////////////////////////////////////////////// if ($.subj) cb.changeRoomSubject($.subj.replace('[objective]', $.obj1_name).replace('[obj]', $.obj1_name)); (function rotate () { if ($.reminder) { showOnEnter(); cb.setTimeout(rotate, $.reminder * 60000); } })();
© Copyright Freesexcam 2011- 2024. All Rights Reserved.