Apps Home
|
Create an App
tip_menu_testbed
Author:
evie_android_testbed
Description
Source Code
Launch App
Current Users
Created by:
Evie_Android_Testbed
/* original version: Tip Menu App by FayNight V.1.0 * this version edited by evie_android * to do: * voting events */ //state variables var total_tips = 0; var goal_tips = 0; var goal = ''; var resetting_goal = false; var last_tipper = null; var last_tip = 0; var ht_username = null; var ht_amount = 0; var menuDisplay = ''; var chatAdMenuDisplay = ''; var welcome_message = ''; //look and feel var BACKGROUND = '#cbdce6'; var WHITE = '#ffffff'; var GREY = '#303030' var ACCENT = '#dc562b' //hard coded responses var MANYVIDSLINK = 'https://www.evie_android.manyvids.com'; var HOWBIG = 'This model is equipped with an insertable length of 6"/16cm'; var HOWTALL = "This model stands 5'6\"/167cm from head to toe"; var INVALID_COMMAND = "invalid slash command. Try typing /help"; var USER_HELP = "Valid commands: /menu - gives current tip menu (to only you) | /manyvids - gives link to manyvids page"; var ADMIN_HELP = "Valid commands: /menu - shows current tip menu to only you /showmenu - shows current tip menu to all chat /manyvids - shows manyvids link to only you /showmanyvids - shows manyvids link to all chat /howbig - shows dick size response to all chat /howtall - shows height response to all chat /setgoal - set tip goal to a new goal with app running, with options for keeping current tips to count towards the new goal"; // Settings cb.settings_choices = [{ name: 'goal_tips', type: 'int', minValue: 0, defaultValue: 100, label: "goal amount (set to 0 to disable)" }, { name: 'reset', type: 'choice', choice1: 'Yes', choice2: 'No', label: "reset the goal when it is met?" }, { name: 'goalDescrip', type: 'str', minLength: 0, MaxLength: 300, label: "goal description, will be displayed on panel and posted in chat when reached", required: false }, { name: 'item0', type: 'str', minLength: 1, maxLength: 30, label: "menu item 1" }, { name: 'price0', type: 'int', minValue: 0, defaultValue: 10, label: "item 1 price" }, { name: 'item1', type: 'str', minLength: 1, maxLength: 50, label: "menu item 2" }, { name: 'price1', type: 'int', minValue: 0, defaultValue: 20, label: "item 2 price" }, { name: 'item2', type: 'str', minLength: 1, maxLength: 50, label: "menu item 3", required: false }, { name: 'price2', type: 'int', minValue: 0, label: "item 3 price", required: false }, { name: 'item3', type: 'str', minLength: 1, maxLength: 50, label: "menu item 4", required: false }, { name: 'price3', type: 'int', minValue: 0, label: "item 4 price", required: false }, { name: 'item4', type: 'str', minLength: 1, maxLength: 50, label: "menu item 5", required: false }, { name: 'price4', type: 'int', minValue: 0, label: "item 5 price", required: false }, { name: 'item5', type: 'str', minLength: 1, maxLength: 50, label: "menu item 6", required: false }, { name: 'price5', type: 'int', minValue: 0, label: "item 6 price", required: false }, { name: 'item6', type: 'str', minLength: 1, maxLength: 50, label: "menu item 7", required: false }, { name: 'price6', type: 'int', minValue: 0, label: "item 7 price", required: false }, { name: 'item7', type: 'str', minLength: 1, maxLength: 50, label: "menu item 8", required: false }, { name: 'price7', type: 'int', minValue: 0, label: "item 8 price", required: false }, { name: 'item8', type: 'str', minLength: 1, maxLength: 50, label: "menu item 9", required: false }, { name: 'price8', type: 'int', minValue: 0, label: "item 9 price", required: false }, { name: 'item9', type: 'str', minLength: 1, maxLength: 50, label: "menu item 10", required: false }, { name: 'price9', type: 'int', minValue: 0, label: "item 10 price", required: false }, { name: 'chat_ad_del', type: 'int', minValue: 0, maxValue: 999, defaultValue: 10, label: 'advertise current goal status + menu in chat every ___ minutes (set to 0 to disable)' } ]; // Handlers cb.onTip(function(tip) { total_tips += tip['amount']; //trigger tip menu items, if any apply switch(tip['amount']) { case cb.settings.price0: cb.chatNotice(cb.settings.item0); break; case cb.settings.price1: cb.chatNotice(cb.settings.item1); break; case cb.settings.price2: cb.chatNotice(cb.settings.item2); break; case cb.settings.price3: cb.chatNotice(cb.settings.item3); break; case cb.settings.price4: cb.chatNotice(cb.settings.item4); break; case cb.settings.price5: cb.chatNotice(cb.settings.item5); break; case cb.settings.price6: cb.chatNotice(cb.settings.item6); break; case cb.settings.price7: cb.chatNotice(cb.settings.item7); break; case cb.settings.price8: cb.chatNotice(cb.settings.item8); break; case cb.settings.price9: cb.chatNotice(cb.settings.item9); break; } //update tipper information last_tip = tip['amount']; last_tipper = tip['from_user']; if (tip['amount'] > ht_amount) { ht_amount = tip['amount']; ht_username = tip['from_user']; } if(goal_tips > 0) { if (total_tips >= goal_tips) { goal_reached(); } chatAdMenuDisplay = total_tips + '/' + goal_tips + ' tokens until goal: ' + goal + '. Type /menu anytime to see the tip menu.'; } cb.drawPanel(); }); cb.onMessage(function(msg) { if (msg['user'] == ht_username) { msg['background'] = BACKGROUND; } if(msg['m'].charAt(0) == '/') { if (msg['m'] == '/menu') { cb.chatNotice(menuDisplay, msg['user'], BACKGROUND, GREY); } else if (msg['m'] == '/showmenu' && msg['user'] == cb.room_slug) { msg['m'] = ''; msg['X-Spam'] = true; cb.chatNotice(menuDisplay, '', BACKGROUND, GREY); } else if (msg['m'] == '/manyvids') { cb.chatNotice(MANYVIDSLINK, msg['user'], BACKGROUND, GREY); } else if (msg['m'] == '/showmanyvids' && msg['user'] == cb.room_slug) { msg['m'] = ''; msg['X-Spam'] = true; cb.chatNotice(MANYVIDSLINK, '', BACKGROUND, GREY); } else if (msg['m'] == '/howbig' && msg['user'] == cb.room_slug) { cb.chatNotice(HOWBIG, '', BACKGROUND, GREY); } else if (msg['m'] == '/howtall' && msg['user'] == cb.room_slug) { cb.chatNotice(HOWTALL, '', BACKGROUND, GREY); } else if (msg['m'].substring(0,8) == '/setgoal') { var arguments = parseCSV(msg['m'].substring(8)); if(arguments.length >= 3) { goal = arguments[0]; var newGoal = Number(arguments[1]); if(newGoal !== newGoal || newGoal <= 0) { goal_tips = 0; cb.chatNotice("goal amount negative or not a number", msg['user'], BACKGROUND, GREY); } else { goal_tips = newGoal; } if(arguments[2] === 'r') { resetting_goal = true; } else if(arguments[2] === 'o') { resetting_goal = false; } if(arguments.length >= 4) { if(arguments[3] !== 'x') { total_tips = 0; } } if(goal_tips > 0) { chatAdMenuDisplay = total_tips + '/' + goal_tips + ' tokens until goal: ' + goal + '. Type /menu anytime to see the tip menu.'; } else { chatAdMenuDisplay = 'Type /menu anytime to see the tip menu.'; } cb.drawPanel(); } else { cb.chatNotice("too few arguments for /setgoal: try /setgoal stuff,500,x", msg['user'], BACKGROUND, GREY); } msg['m'] = ''; msg['X-Spam'] = true; } else if (msg['m'] == '/help') { if(msg['user'] == cb.room_slug) { cb.chatNotice(ADMIN_HELP, msg['user'], BACKGROUND, GREY); } else { cb.chatNotice(USER_HELP, msg['user'], BACKGROUND, GREY); } } else { cb.chatNotice(INVALID_COMMAND, msg['user'], BACKGROUND, GREY); } } return msg; }); cb.onEnter(function(user) { cb.chatNotice(welcome_message, user['user'], BACKGROUND, GREY); }); cb.onDrawPanel(function(user) { if (goal_tips === 0) { return { 'template': '3_rows_12_22_31', 'row1_label': 'Tip menu Active!', 'row1_value': 'Type /menu to see it.', 'row2_label': 'Highest Tip:', 'row2_value': nullCheck(ht_username) + '(' + ht_amount + ')', 'row3_value': 'Tip ' + cb.settings.price0 + 'tks for "' + cb.settings.item0 + '"' }; } else { return { 'template': '3_rows_12_22_31', 'row1_label': total_tips + '/' + goal_tips + ' for goal:', 'row1_value': goal, 'row2_label': 'Tip menu is active!', 'row2_value': 'Type /menu to see it', 'row3_value': 'Tip ' + cb.settings.price0 + ' for "' + cb.settings.item0 + '"' }; } }); // Function Junction function parseCSV(str) { //parsing a single user-entered string into an a array of keyword strings var arr = []; // iterate over each character, keep track of current column (of the returned array) for (col = 0, index = 0; index < String(str).length; index++) { var cc = String(str)[index], nc = String(str)[index+1]; // current character, next character arr[col] = arr[col] || ''; // create a new column (start with empty string) if necessary // If it's a comma, move on to the next column if (cc == ',') { ++col; continue; } // If it's a newline, move on to the next column if (cc == '\r' && nc == '\n') { ++index; continue; } // Otherwise, append the current character to the current column arr[col] += cc; } return arr; } function nullCheck(str) { if (str === null) { return "---"; } else return str.substring(0, 15); } function goal_reached() { cb.chatNotice("Goal reached! " + goal, '', BACKGROUND, ACCENT); total_tips = total_tips - goal_tips; if(resetting_goal === false) { goal_tips = 0; goal = ''; } if(goal_tips === 0) { chatAdMenuDisplay = 'Type /menu anytime to see the tip menu.'; } } function chatAd() { cb.chatNotice(chatAdMenuDisplay, '', BACKGROUND); cb.setTimeout(chatAd, (cb.settings.chat_ad_del * 60000)); } function init() { if (cb.settings.chat_ad_del > 0) { cb.setTimeout(chatAd, (cb.settings.chat_ad_del * 60000)); } if(cb.settings.reset === "Yes") { resetting_goal = true; } else { resetting_goal = false; } if(cb.settings.goal_tips > 0) { goal_tips = cb.settings.goal_tips; goal = cb.settings.goalDescrip; total_tips = 0; } // builds the menu and chat ads from the results of the form if(goal_tips > 0) { chatAdMenuDisplay = total_tips + '/' + goal_tips + ' tokens until goal: ' + goal + '. Type /menu anytime to see the tip menu.'; } else { chatAdMenuDisplay = 'Type /menu anytime to see the tip menu.'; } welcome_message = "Welcome to " + cb.room_slug + "'s room. Type /menu for the tip menu <3" menuDisplay = '' + cb.room_slug + "'s menu || "; menuDisplay = menuDisplay + cb.settings.price0 + ' - ' + cb.settings.item0 + ' | '; menuDisplay = menuDisplay + cb.settings.price1 + ' - ' + cb.settings.item1; if (cb.settings.price2 !== null && cb.settings.item2 !== null) { menuDisplay = menuDisplay + ' | ' + cb.settings.price2 + ' - ' + cb.settings.item2; } if (cb.settings.price3 !== null && cb.settings.item3 !== null) { menuDisplay = menuDisplay + ' | ' + cb.settings.price3 + ' - ' + cb.settings.item3; } if (cb.settings.price4 !== null && cb.settings.item4 !== null) { menuDisplay = menuDisplay + ' | ' + cb.settings.price4 + ' - ' + cb.settings.item4; } if (cb.settings.price5 !== null && cb.settings.item5 !== null) { menuDisplay = menuDisplay + ' | ' + cb.settings.price5 + ' - ' + cb.settings.item5; } if (cb.settings.price6 !== null && cb.settings.item6 !== null) { menuDisplay = menuDisplay + ' | ' + cb.settings.price6 + ' - ' + cb.settings.item6; } if (cb.settings.price7 !== null && cb.settings.item7 !== null) { menuDisplay = menuDisplay + ' | ' + cb.settings.price7 + ' - ' + cb.settings.item7; } if (cb.settings.price8 !== null && cb.settings.item8 !== null) { menuDisplay = menuDisplay + ' | ' + cb.settings.price8 + ' - ' + cb.settings.item8; } if (cb.settings.price9 !== null && cb.settings.item9 !== null) { menuDisplay = menuDisplay + ' | ' + cb.settings.price9 + ' - ' + cb.settings.item9; } } init(); // Thanks for checking out this code! Feel free to use and modify it, but always keep credit at the top!
© Copyright Chaturbate 2011- 2025. All Rights Reserved.