Apps Home
|
Create an App
tyub
Author:
ultrablack_
Description
Source Code
Launch App
Current Users
Created by:
Ultrablack_
cb.settings_choices = [ { name: 'goalAmount', type: 'str', label: 'Goal amount', defaultValue: 500, minValue: 1, maxValue: 10000, }, { name: 'minimumPrizeValue', type: 'int', label: 'Minimum goal prize value', minValue: 0, maxValue: 10000, }, { name: 'maximumPrizeValue', type: 'int', label: 'Maximum goal prize value', minValue: 0, maxValue: 1000, }, { name:'title', type:'str', minLength:1, maxLength:255, label:'Show title', }, { name:'ticketShowThreshold', type:'int', minValue:1, maxValue:10000, label: 'the amount people need to have tipped to get into the HIDDEN SHOW WOOOAOAOAOAOAOAAOAH', }, ]; let tokensPerUser = {}; let menuItems = []; let prizeItems = []; let totalTokens = 0; let numberOfGoals = tokens => { return Math.floor(tokens / cb.settings.goalAmount); }; let getTicketShowUsers = () => { const threshold = cb.settings.ticketShowThreshold; const tippers = Object.keys(tokensPerUser); let showgoers = []; for (const tipper of tippers) { if (tokensPerUser[tipper] >= threshold) { showgoers.push(tipper); } } return showgoers; }; cb.onStart(() => { let tipMenuEntries = cb.settings.tipMenu.split(','); for (const entry of tipMenuEntries) { const amountDescriptionPair = entry.split('='); const amount = parseInt(amountDescriptionPair[0].trim()); const description = amountDescriptionPair[1].trim(); menuItems.push({amount: amount, description: description}); } let minimumPrizeValue = cb.settings.minimumPrizeValue; let maximumPrizeValue = cb.settings.maximumPrizeValue; prizeItems = menuItems.filter(item => item.amount >= minimumPrizeValue && item.amount <= maximumPrizeValue); }); cb.onTip(tip => { tokensPerUser[tip.from_user] += tip.amount; const newTokenTotal = totalTokens + tip.amount; let currentNumberOfGoals = numberOfGoals(totalTokens); let newNumberOfGoals = numberOfGoals(newTokenTotal); let goalsEarned = newNumberOfGoals - currentNumberOfGoals; if (goalsEarned > 0) { for (let newGoal = 0; newGoal < goalsEarned; newGoal++) { cb.sendNotice(tip.from_user + ' reached goal #' + (currentNumberOfGoals + newGoal)); let wonItem = prizeItems[Math.floor(Math.random() * prizeItems.length)].description; cb.sendNotice('Goal prize: ' + wonItem); } } });
© Copyright Chaturbate 2011- 2024. All Rights Reserved.