Bots Home
|
Create an App
thisnthat
Author:
indshadow3
Description
Source Code
Launch Bot
Current Users
Created by:
Indshadow3
cb.settings_choices = [ { name: 'color_list', type: 'str', minLength: 1, maxLength: 255, defaultValue: "red, orange, yellow, green, blue, indigo, violet", label: "List of colors, use a comma to separate them" }, { name: 'color0', type: 'str', minLength: 7, maxLength: 7, defaultValue: '#FF0000', label: "Hex Code for Color 1" }, { name: 'color0_tip', type: 'int', minValue: 1, defaultValue: 10, label: "Tokens for Color 1" }, { name: 'color1', type: 'str', minLength: 7, maxLength: 7, defaultValue: '#FF7F00', label: "Hex Code for Color 2" }, { name: 'color1_tip', type: 'int', minValue: 1, defaultValue: 11, label: "Tokens for Color 2" }, { name: 'color2', type: 'str', minLength: 7, maxLength: 7, defaultValue: '#FFFF00', label: "Hex Code for Color 3" , required: false }, { name: 'color2_tip', type: 'int', minValue: 1, defaultValue: 12, label: "Tokens for Color 3", required: false }, { name: 'color3', type: 'str', minLength: 7, maxLength: 7, defaultValue: '#00FF00', label: "Hex Code for Color 4" , required: false }, { name: 'color3_tip', type: 'int', minValue: 1, defaultValue: 13, label: "Tokens for Color 4", required: false }, { name: 'color4', type: 'str', minLength: 7, maxLength: 7, defaultValue: '#0000FF', label: "Hex Code for Color 5" , required: false }, { name: 'color4_tip', type: 'int', minValue: 1, defaultValue: 14, label: "Tokens for Color 5", required: false }, { name: 'color5', type: 'str', minLength: 7, maxLength: 7, defaultValue: '#4B0082', label: "Hex Code for Color 6" , required: false }, { name: 'color5_tip', type: 'int', minValue: 1, defaultValue: 15, label: "Tokens for Color 6", required: false }, { name: 'color6', type: 'str', minLength: 7, maxLength: 7, defaultValue: '#9400D3', label: "Hex Code for Color 7" , required: false }, { name: 'color6_tip', type: 'int', minValue: 1, defaultValue: 16, label: "Tokens for Color 7", required: false } ] var color_list = String(cb.settings.color_list).replace(/\s+/g, ''); var colors = color_list.split(','); var rainbow = new Array(); for (var i = 0; i < colors.length; i++) { color_name = colors[i]; color_code = cb.settings['color' + i]; color_tip = cb.settings['color' + i + '_tip']; rainbow.push( { name: color_name, color_code: color_code, tip_amount: color_tip, user: null } ) } function rainbow_info() { cb.sendNotice("Rainbow Colors:"); for ( var i = 0; i < rainbow.length; i++ ) { var notice = rainbow[i].name + " is " + rainbow[i].tip_amount; if ( rainbow[i].user ) notice += "(" + rainbow[i].user + ")"; cb.sendNotice(notice, '', rainbow[i].color_code); } } function search_rainbow_tip(tip_value) { for ( var i = 0; i < rainbow.length; i++ ) { if ( rainbow[i].tip_amount === tip_value ) return i; } return -1; } function search_rainbow_user(user) { for ( var i = 0; i < rainbow.length; i++ ) { if ( rainbow[i].user === user ) return i; } return -1; } cb.onTip(function (tip) { cb.sendNotice("Received: " + parseInt(tip['amount'])); var rainbow_result = search_rainbow_tip(parseInt(tip['amount'])); cb.sendNotice("result: " + rainbow_result); if ( rainbow_result >= 0 ) { var rainbow_result_user = search_rainbow_user(tip['from_user']); if ( rainbow_result_user >= 0 && rainbow[rainbow_result].user != tip['from_user'] ) { cb.sendNotice(tip['from_user'] + " is switching from " + rainbow[rainbow_result_user].name + " to " + rainbow[rainbow_result].name); rainbow[rainbow_result_user].user = null; } else if ( rainbow[rainbow_result].user == null ) { cb.sendNotice(tip['from_user'] + " is now " + rainbow[rainbow_result].name); } else if ( rainbow[rainbow_result].user == tip['from_user'] ) { cb.sendNotice(tip['from_user'] + " is already " + rainbow[rainbow_result].name); } else { cb.sendNotice(tip['from_user'] + " stole " + rainbow[rainbow_result].name + " from " + rainbow[rainbow_result].user); } rainbow[rainbow_result].user = tip['from_user']; rainbow_info(); } }); cb.onMessage(function (message) { var rainbow_result = search_rainbow_user(message['user']) cb.sendNotice("result: " + rainbow_result); if ( rainbow_result >= 0 ) { message['background'] = rainbow[rainbow_result].color_code; // message['foreground'] = '#FFFFFF'; return message } }); rainbow_info();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.