Apps Home
|
Create an App
BrittDev TestApp
Author:
brittdev
Description
Source Code
Launch App
Current Users
Created by:
Brittdev
//function block //generates random numbers function getRandomNumber(min, max) { min = Math.ceil(min); max = Math.floor(max); // both min and max are inclusive return Math.floor(Math.random() * (max - min + 1)) + min; } //removes target values from array function removeElement(arrayName,arrayElement) { for(let i=0; i<arrayName.length;i++ ) { if(arrayName[i]==arrayElement) arrayName.splice(i,1); } } //init block //var total_tipped = 0; var reducer = (previousValue, currentValue) => previousValue + currentValue; //setup sequence for the day var numbers = []; numbers.push(getRandomNumber(0,400)); var sum = numbers[0]; for (let i=1;i<=5;i++) { numbers.push(getRandomNumber(0,1000-sum)); sum += numbers[i]; } //debug //cb.log('before:' + sum); //cb.log(numbers); //numbers[2]=1; //sum=numbers.reduce(reducer); //cb.log('after:' + sum); //additional check to make sure total sum of array amounts to at least 800 - if hit will set last array element to difference between total value (currently) and target of 800. if (sum < 801) { numbers[5] = numbers[5]+(801-sum); } //check for 0-values in array and remove them removeElement(numbers,'0'); //debug output cb.log(numbers); //cb.log(tip_seq[0],tip_seq[1],tip_seq[2]) //cb.chatNotice('Todays tips are: '+ tip_seq[0] +', ' + tip_seq[1] + ', ' + tip_seq[2] + ', ' + tip_seq[3]+ ', ' + tip_seq[4]); //completely different test function to grab latest tip from chat and do an action. This is a WIP prototype for the screen draw effect stuff. TBC.. //cb.onTip(function (tip) { //cb.chatNotice(tip.from_user + " tipped " + tip.amount) //});
© Copyright Chaturbate 2011- 2024. All Rights Reserved.