Apps Home
|
My Uploads
|
Create an App
James T Tip Menu
Author:
jamest12
Description
Source Code
Launch App
Current Users
Created by:
Jamest12
App Images
// Made by James T - chaturbate.com/jamestbay12 // Version: 0.1 - 2021/02/07 // Built from Tip Menu by faynight & Rotating Notifier by badbadbubba // Variables var backgroundImage = 'beee04b9-471c-4123-b88e-42663cdb4f98'; var total_tips = 0; var goal_tips = 0; var last_tipper = null; var last_tip = 0; var ht_username = null; var ht_amount = 0; var goal = 0; var i = 0; var MAXITEMS = 6; var separator = " | "; // Settings cb.settings_choices = [ { name: 'title', type: 'str', label: 'Room Title', minLength: 1, maxLength: 255, }, { name: 'tags', type: 'str', label: 'Tags', minLength: 1, maxLength: 255, }, { name: 'backgroundImage', type: 'str', label: 'Goal Counter Background Image', defaultValue: backgroundImage }, { name: 'goal', 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: 'goalAd', type: 'str', minLength: 0, MaxLength: 300, label: "Goal Description. Will automatically post in chat when Goal is reached (Optional)", required: false }, { name: 'item1', type: 'str', minLength: 1, maxLength: 30, label: "Menu Item 1 (required)" }, { name: 'price1', type: 'int', minValue: 0, defaultValue: 10, label: "Item 1 Price (required)" }, { name: 'item2', type: 'str', minLength: 1, maxLength: 50, label: "Menu Item 2 (required)" }, { name: 'price2', type: 'int', minValue: 0, defaultValue: 20, label: "Item 2 Price (required)" }, { name: 'item3', type: 'str', minLength: 1, maxLength: 50, label: "Menu Item 3", required: false }, { name: 'price3', type: 'int', minValue: 0, label: "Item 3 Price", required: false }, { name: 'item4', type: 'str', minLength: 1, maxLength: 50, label: "Menu Item 4", required: false }, { name: 'price4', type: 'int', minValue: 0, label: "Item 4 Price", required: false }, { name: 'item5', type: 'str', minLength: 1, maxLength: 50, label: "Menu Item 5", required: false }, { name: 'price5', type: 'int', minValue: 0, label: "Item 5 Price", required: false }, { name: 'item6', type: 'str', minLength: 1, maxLength: 50, label: "Menu Item 6", required: false }, { name: 'price6', type: 'int', minValue: 0, label: "Item 6 Price", required: false }, { name: 'chat_ad', type: 'int', minValue: 0, maxValue: 999, defaultValue: 10, label: 'Advertise Menu in Chat Every _____ Mins (Set 0 to Disable)' }, { name: 'msg1', type: 'str', required: true, label: 'Message 1', }, { name: 'msg2', type: 'str', required: false, label: 'Message 2', }, { name: 'msg3', type: 'str', required: false, label: 'Message 3', }, { name: 'msg4', type: 'str', required: false, label: 'Message 4', }, { name: 'msg5', type: 'str', required: false, label: 'Message 5', }, { name: 'msg6', type: 'str', required: false, label: 'Message 6', }, { name: 'msgcolor', type: 'str', label: 'Notice color (html code default dark red #9F000F)', defaultValue: '#9F000F' }, { name: 'chat_ad', type: 'int', minValue: 1, maxValue: 999, defaultValue: 2, label: 'Delay in minutes between notices being displayed (minimum 1)' }, ]; // Handlers cb.onTip(function(tip) { total_tips += tip['amount']; goal_tips += tip['amount']; if (tip['amount'] === cb.settings.price1) { cb.chatNotice(cb.settings.item1); } if (tip['amount'] === cb.settings.price2) { cb.chatNotice(cb.settings.item2); } if (tip['amount'] === cb.settings.price3) { cb.chatNotice(cb.settings.item3); } if (tip['amount'] === cb.settings.price4) { cb.chatNotice(cb.settings.item4); } if (tip['amount'] === cb.settings.price5) { cb.chatNotice(cb.settings.item5); } if (tip['amount'] === cb.settings.price6) { cb.chatNotice(cb.settings.item6); } update_app(); last_tip = tip['amount']; last_tipper = tip['from_user']; if (tip['amount'] > ht_amount) { ht_amount = tip['amount']; ht_username = tip['from_user']; } cb.drawPanel(); }); // Chat Commands cb.onMessage(function(msg) { if (msg['user'] == ht_username) { msg['background'] = '#CCFF99 '; } if (msg['m'] == '/menu') { cb.chatNotice('-----' + cb.room_slug + 's Tip Menu -----', msg['user']); for (var i = 0; i < listMenu.length; i++) { cb.chatNotice(listMenu[i], msg['user']); } } if (msg['m'] == '/showmenu' && msg['user'] == cb.room_slug) { cb.chatNotice('-----' + cb.room_slug + 's Tip Menu -----'); for (var i = 0; i < listMenu.length; i++) { cb.chatNotice(listMenu[i]); } } return msg; }); // Display Panels cb.onDrawPanel(function(user) { return { "template": "image_template", "layers": [{ 'type': 'image', 'fileID': backgroundImage }, { 'type': 'text', 'text': 'GOAL', 'top': 5, 'left': 28, 'color': 'white', }, { 'type': 'text', 'text': goal_tips + '/' + cb.settings.goal + '(' + total_tips + ')', 'top': 5, 'left': 147, 'color': 'white', }, { 'type': 'text', 'text': 'Tip Menu is active type /menu to see it', 'top': 29, 'left': 28, 'color': 'white', }, { 'type': 'text', 'text': 'Thank you last tipper: ', 'top': 52, 'left': 28, 'color': 'white', }, { 'type': 'text', 'text': last_tipper, 'top': 51, 'left': 147, 'color': 'white', }, ], }; }); // Makings of the Menu var menu1 = '' + cb.settings.item1 + ' For ' + cb.settings.price1 + 'tks '; var menu2 = '' + cb.settings.item2 + ' For ' + cb.settings.price2 + 'tks '; var menu3 = '--------'; var menu4 = '-------'; var menu5 = '------'; var menu6 = '-----'; if (cb.settings.price3 !== undefined) { menu3 = '' + cb.settings.item3 + ' For ' + cb.settings.price3 + 'tks '; } if (cb.settings.price4 !== undefined) { menu4 = '' + cb.settings.item4 + ' For ' + cb.settings.price4 + 'tks '; } if (cb.settings.price5 !== undefined) { menu5 = '' + cb.settings.item5 + ' For ' + cb.settings.price5 + 'tks '; } if (cb.settings.price6 !== undefined) { menu6 = '' + cb.settings.item6 + ' For ' + cb.settings.price6 + 'tks '; } var listMenu = [menu1, menu2, menu3, menu4, menu5, menu6, ]; // Function Junction function update_app() { if (cb.settings.goal === 0) {} else if (goal_tips >= cb.settings.goal) { goal_reached(); } cb.changeRoomSubject(cb.settings.title + separator + "[" + goal_tips + '/' + cb.settings.goal + "]" + separator + cb.settings.tags) } function goal_reached() { if (tips_remaining() === 0) { if (cb.settings.reset === "Yes") { reset_goal(); } else; goal += 1; { if (goal <= 1) { cb.chatNotice("Goal Reached! " + cb.settings.goalAd); } } } } function reset_goal() { goal_tips -= cb.settings.goal; goal -= 1; } function tips_remaining() { var r = cb.settings.goal - goal_tips; if (r < 0) { return 0; } else { return r; } } function nullCheck(str) { if (str === null) { return "---"; } else return str.substring(0, 15); } function chatAd() { var msg; while (cb.settings['msg' + (i + 1)] == 0) { //skip empty messages i++; i %= MAXITEMS; } msg = cb.settings['msg' + (i + 1)]; i++; i %= MAXITEMS; cb.sendNotice(msg, '', '', cb.settings['msgcolor'], 'bold'); cb.sendNotice('Tip Menu Is Active! Type /menu to see the full menu.', '', '', cb.settings['msgcolor'], 'bold'); cb.setTimeout(chatAd, (cb.settings.chat_ad * 60000)); } if (cb.settings.chat_ad > 0) { cb.setTimeout(chatAd, (cb.settings.chat_ad * 60000)); } cb.onEnter(function(user) { cb.sendNotice('Welcome ' + user['user'] + '! Thanks for stopping by','', '', cb.settings['msgcolor'],'bold'); }); cb.onStart() { cb.changeRoomSubject(cb.settings.title + separator + "[" + goal_tips + '/' + cb.settings.goal +"]" + separator + cb.settings.tags) }; function init() { update_app(); } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.