Apps Home
|
Create an App
Raven's Tip Menu And Multi-Goal
Author:
raven_hart
Description
Source Code
Launch App
Current Users
Created by:
Raven_Hart
// Tip Menu and Multi-Goal App by Raven Hart V.1.0 // // Based on Tip Menu App by FayNight V.1.0 And Tip Goal by Admin // Variables 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 currentGoal = 0; var currentItem = 0; var prefKeys = []; var prefValues = []; var goalText = []; var goalAmount = []; var menuText = []; var menuAmount = []; /* // Handlers cb.onTip(function(tip) { total_tips += tip['amount']; goal_tips += tip['amount']; for (var i = 0; i < priceArray.length; i++) { if (tip['amount'] === priceArray[i]) { cb.chatNotice(itemArray[i]); } } 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']; } currentItem+=1; if (currentItem >= itemArray.length) { currentItem = 0; } cb.drawPanel(); }); // Chat Commands cb.onMessage(function(msg) { if (msg['user'] == ht_username) { msg['background'] = '#CCFF99 '; } if (msg['m'].includes('/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'].includes('/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': '3_rows_12_22_31', 'row1_label': 'Goal:', 'row1_value': goal_tips + '/' + goalAmounts[currentGoal], 'row2_label': 'Tip Menu is Active!', 'row2_value': 'Type /menu to see it', 'row3_value': 'Tip ' + priceArray[currentItem] + 'tks For "' + itemArray[currentItem] + '"' }; }); // Function Junction function update_app() { if (currentGoal == -1) { } else if (goal_tips >= goalAmounts[currentGoal]) { goal_reached(); } update_subject(); } function update_subject() { var new_subject; if (currentGoal == -1) { new_subject = cb.settings.finalDescription; } else { new_subject = goalDescriptions[currentGoal] + " [" + tips_remaining() + " tokens remaining]"; } cb.log("Changing subject to: " + new_subject); cb.changeRoomSubject(new_subject); } function goal_reached() { if (tips_remaining() === 0) { cb.chatNotice("Goal Reached! " + goalDescriptions[currentGoal]); goal_tips -= goalAmounts[currentGoal]; currentGoal += 1; if (currentGoal >= goalAmounts.length) { currentGoal = -1; } cb.log("Current Goal: " + currentGoal); cb.log("Amounts Length: " + goalAmounts.length); } } function tips_remaining() { var r = goalAmounts[currentGoal] - goal_tips; if (r < 0) { return 0; } else { return r; } } */ function nullCheck(str) { if (str === null) { return "---"; } else return str.substring(0, 15); } function format_username(val) { if (val === null) { return "--"; } else { return val.substring(0, 12); } } function chatAd() { cb.chatNotice('/// Tip Menu Is Active! Tip ' + menuAmount[0] + 'tks for "' + menuText[0] + '" Or, Type /menu to see the full menu.'); cb.setTimeout(chatAd, (prefValues[prefKeys.findIndex(function(e){return e=="ad_time";})] * 60000)); } function init() { parse_settings(); //update_app(); //update_subject(); var ad_time = prefValues[prefKeys.findIndex(function(e){return e=="ad_time";})]; if (ad_time > 0) { cb.setTimeout(chatAd, (ad_time * 60000)); } } // Settings cb.settings_choices = [{ name: 'prefsString', type: 'str', minLength: 0, MaxLength: 2048, label: "Preferences String" }, { name: 'goalsString', type: 'str', minLength: 0, MaxLength: 2048, label: "Goals String" }, { name: 'menuString', type: 'str', minLength: 0, MaxLength: 2048, label: "Menu String" } ]; function parse_settings() { var prefs = parseCSV(cb.settings.prefsString); var goals = parseCSV(cb.settings.goalsString); var menu = parseCSV(cb.settings.menuString); for (var i=0; i<prefs.length; i+=2) { prefKeys[i/2]=prefs[i]; prefValues[i/2]=prefs[i+1]; } for (var i=0; i<goals.length; i+=2) { goalText[i/2]=goals[i]; goalAmount[i/2]=goals[i+1]; } for (var i=0; i<menu.length; i+=2) { menuText[i/2]=menu[i]; menuAmount[i/2]=menu[i+1]; } } init(); function parseCSV(i) { str = new String(i); var arr = []; var quote = false; for (var row = c = 0; c < str.length; c++) { var cc = str[c], nc = str[c+1]; arr[row] = arr[row] || []; if (cc == '"' && quote && nc == '"') { arr[row] += cc; ++c; continue; } if (cc == '"') { quote = !quote; continue; } if (cc == ',' && !quote) { ++row; continue; } if (cc == '\r' && nc == '\n' && !quote) { ++row; ++c; continue; } if (cc == '\n' && !quote) { ++row; continue; } if (cc == '\r' && !quote) { ++row; continue; } arr[row] += cc; } return arr; }
© Copyright Chaturbate 2011- 2025. All Rights Reserved.