Apps Home
|
Create an App
aa
Author:
bbwchat
Description
Source Code
Launch App
Current Users
Created by:
Bbwchat
/* App: Token Climber Multi-Goal - v1.0 * * By: xNinja666x * Based on: * TOKEN CLIMBER By: Beans * SEQUENCE TIPS ORIGNALLY DEVELOPED BY: Cliche123 & Nolidoux, * highest tipper code from Elle Sterling Sequential Tips * * Reasons for changes. * Same logic as TOKEN CLIMBER but added the ability to set multiple goals, inspired by SkyeWatson * * Modification History * */ // vars var max_tip_level = null; var next_level_amount = 1; var support_level_amount = 0; var goal_reached = false; var imena = new Array(); var tipovi = new Array(); var mGoal = []; var mIndex = 0; var mDoneFlag = 0; // var version = 1 // Limit goal description as we add some text cb.settings_choices = [ { name: 'display_goals', type: 'choice', label: 'Display detail goal status notice messages to', choice1: 'Everyone', choice2: '-', default: '-' }, { name: 'active1', type: 'choice', label: '=== (1) Set Goal ======', choice1: 'active', choice2: '-', default: 'active' }, { name: 'goal_description1', required: false, type: 'str', minLength: 1, maxLength: 190, label:"Goal Description" }, { name: 'goal_value1', required: false, type: 'int', minValue: 1, maxValue: 100000, default: 1000, label:"Token Goal" }, { name: 'order1', required: false, type: 'choice', label: 'Order', choice1: 'ascending', choice2: 'descending', default: 'ascending' }, { name: 'active2', type: 'choice', label: '=== (2) Set Goal ======', choice1: 'active', choice2: '-', default: '-' }, { name: 'goal_description2', required: false, type: 'str', minLength: 0, maxLength: 190, label:"Goal Description" }, { name: 'goal_value2', required: false, type: 'int', minValue: 0, maxValue: 100000, default: 0, label:"Token Goal" }, { name: 'order2', required: false, type: 'choice', label: 'Order', choice1: 'ascending', choice2: 'descending', default: 'ascending' }, { name: 'active3', type: 'choice', label: '=== (3) Set Goal ======', choice1: 'active', choice2: '-', default: '-' }, { name: 'goal_description3', required: false, type: 'str', minLength: 0, maxLength: 190, label:"Goal Description" }, { name: 'goal_value3', required: false, type: 'int', minValue: 0, maxValue: 100000, default: 0, label:"Token Goal" }, { name: 'order3', required: false, type: 'choice', label: 'Order', choice1: 'ascending', choice2: 'descending', default: 'ascending' }, { name: 'active4', type: 'choice', label: '=== (4) Set Goal ======', choice1: 'active', choice2: '-', default: '-' }, { name: 'goal_description4', required: false, type: 'str', minLength: 0, maxLength: 190, label:"Goal Description" }, { name: 'goal_value4', required: false, type: 'int', minValue: 0, maxValue: 100000, default: 0, label:"Token Goal" }, { name: 'order4', required: false, type: 'choice', label: 'Order', choice1: 'ascending', choice2: 'descending', default: 'ascending' }, { name: 'active5', type: 'choice', label: '=== (5) Set Goal ======', choice1: 'active', choice2: '-', default: '-' }, { name: 'goal_description5', required: false, type: 'str', minLength: 0, maxLength: 190, label:"Goal Description" }, { name: 'goal_value5', required: false, type: 'int', minValue: 0, maxValue: 100000, default: 0, label:"Token Goal" }, { name: 'order5', required: false, type: 'choice', label: 'Order', choice1: 'ascending', choice2: 'descending', default: 'ascending' }, { name: 'active6', type: 'choice', label: '=== (6) Set Goal ======', choice1: 'active', choice2: '-', default: '-' }, { name: 'goal_description6', required: false, type: 'str', minLength: 0, maxLength: 190, label:"Goal Description" }, { name: 'goal_value6', required: false, type: 'int', minValue: 0, maxValue: 100000, default: 0, label:"Token Goal" }, { name: 'order6', required: false, type: 'choice', label: 'Order', choice1: 'ascending', choice2: 'descending', default: 'ascending' }, { name: 'active7', type: 'choice', label: '=== (7) Set Goal ======', choice1: 'active', choice2: '-', default: '-' }, { name: 'goal_description7', required: false, type: 'str', minLength: 0, maxLength: 190, label:"Goal Description" }, { name: 'goal_value7', required: false, type: 'int', minValue: 0, maxValue: 100000, default: 0, label:"Token Goal" }, { name: 'order7', required: false, type: 'choice', label: 'Order', choice1: 'ascending', choice2: 'descending', default: 'ascending' } ]; cb.onTip( function (tip) { if (mGoal.length == 0) return; if (checkGoalReached()) { if ((mIndex + 1) > (mGoal.length - 1)) { if (mDoneFlag == 0) { mDoneFlag = 1; mGoal[mIndex]["goal_status"] = "COMPLETED" displayGoals(); } return; } else { mGoal[mIndex]["goal_status"] = "COMPLETED"; mIndex += 1; startGoal(); } } najvisi(tip['from_user'], tip['amount']); var diff = tip['amount']; diff += support_level_amount; support_level_amount = diff; while ((diff > 0) && (!checkGoalReached())) { diff -= next_level_amount; if (diff >= 0) { support_level_amount = diff; setNextLevelNeeded(); } } update_subject(); cb.drawPanel(); } ); cb.onDrawPanel( function (user) { if (mGoal.length == 0) return; if (checkGoalReached()) { var result = { 'template': '3_rows_11_21_31', 'row1_value': '*** Goal ' + (mIndex + 1) + ' / ' + mGoal.length + ' reached! ***', 'row2_value': format_username(mGoal[mIndex].high_tip_username) + " ("+mGoal[mIndex].high_tip_amount+")", 'row3_value': 'Thanks to all tippers' }; return result; } else { if (isAscendingOrder()) { return { 'template': '3_rows_of_labels', 'row1_label': 'Current Level:', 'row1_value': next_level_amount-1 + ' (of 1 to ' + max_tip_level + ")", 'row2_label': 'Additional Tips:', 'row2_value': support_level_amount, 'row3_label': 'Highest Total Tips:', 'row3_value': format_username(mGoal[mIndex].high_tip_username) + " ("+mGoal[mIndex].high_tip_amount+")" }; } else { return { 'template': '3_rows_of_labels', 'row1_label': 'Current Level:', 'row1_value': next_level_amount+1 + ' (of ' + max_tip_level + ' to 1)', 'row2_label': 'Additional Tips:', 'row2_value': support_level_amount, 'row3_label': 'Highest Total Tips:', 'row3_value': format_username(mGoal[mIndex].high_tip_username) + " ("+mGoal[mIndex].high_tip_amount+")" }; } } } ); cb.onMessage(function (msg) { if (mGoal.length == 0) return; if (msg['user'] == mGoal[mIndex].high_tip_username) { msg['background'] = '#9F9'; } return msg; }); // helper functions function update_subject() { if (goal_reached) { return; } var new_subject = ""; var tip_for_next_level = next_level_amount - support_level_amount; if (checkGoalReached()) { new_subject = mGoal[mIndex].goal_description + " [Goal " + (mIndex + 1) + " / " + mGoal.length + " reached! Thanks to all tippers.]"; goal_reached = true; } else { if (isAscendingOrder()) { new_subject = mGoal[mIndex].goal_description + " [Tip to ascend levels from 1 to " + max_tip_level + ". Tip for next level: " + tip_for_next_level + "]"; } else { new_subject = mGoal[mIndex].goal_description + " [Tip to descend levels from " + max_tip_level + " to 1. Tip for next level: " + tip_for_next_level + "]"; } } cb.changeRoomSubject(new_subject); } function format_username(val) { if (val === null) { return "--"; } else { return val.substring(0, 12); } } function najvisi(ime, tip) { var index = imena.indexOf(ime); if (index == -1) { //cb.log("new"); imena[imena.length] = ime; tipovi[tipovi.length] = tip; if (mGoal[mIndex].high_tip_amount == 0 || mGoal[mIndex].high_tip_amount < tip) { mGoal[mIndex].high_tip_amount = tip; mGoal[mIndex].high_tip_username = ime; } } else { //cb.log("old"); tipovi[index] += tip; if (tipovi[index] > mGoal[mIndex].high_tip_amount) { mGoal[mIndex].high_tip_amount = tipovi[index]; mGoal[mIndex].high_tip_username = imena[index]; } } } function isAscendingOrder() { return (mGoal[mIndex].order == 'ascending'); } function setNextLevelNeeded() { if (isAscendingOrder()) { next_level_amount++; } else { next_level_amount--; } } function checkGoalReached() { if (isAscendingOrder()) { return (next_level_amount > max_tip_level); } else { return (next_level_amount <= 0); } } function startGoal() { max_tip_level = null; next_level_amount = 1; support_level_amount = 0; goal_reached = false; imena = new Array(); tipovi = new Array(); max_tip_level = Math.floor(Math.sqrt(mGoal[mIndex].goal_value * 2)) + 1; if (isAscendingOrder()) { next_level_amount = 1; } else { next_level_amount = max_tip_level; } update_subject(); displayGoals(); } function displayGoals() { var displayOption = cb.settings.display_goals; var user = ""; if (displayOption == "-") { return; } if (displayOption == "Me") { user = cb.room_slug; } var fgColor1 = "#87CEEB"; var bgColor1 = "#ffffff"; var fontw1 = "bold"; var fgColor2 = "#4169E1"; var fgColor; cb.chatNotice("***********************************************", user, bgColor1, fgColor1, fontw1); var numGoal = mGoal.length; for (var i=0;i<numGoal;i++) { if ( mGoal[i]["goal_status"] == "COMPLETED") fgColor = fgColor1; else fgColor = fgColor2; var status = mGoal[i]["goal_status"]; if (i == mIndex && mDoneFlag == 0) { status = "Current Goal"; } cb.chatNotice("\n==== Goal " + (i + 1) + " / " + numGoal + " - " + status, user, bgColor1, fgColor, fontw1); cb.chatNotice(mGoal[i]["goal_description"], user, bgColor1, fgColor, fontw1); if (mGoal[i]["order"] == "descending") cb.chatNotice("Level: " + mGoal[i]["max_tip_level"] + " to 1", user, bgColor1, fgColor, fontw1); else cb.chatNotice("Level: 1 to " + mGoal[i]["max_tip_level"], user, bgColor1, fgColor, fontw1); if (mGoal[i]["high_tip_username"]) { cb.chatNotice("High Tipper: " + mGoal[i]["high_tip_username"] + " (" + mGoal[i]["high_tip_amount"] + ")", user, bgColor1, fgColor, fontw1); } } cb.chatNotice("\n***********************************************", user, bgColor1, fgColor1, fontw1); } function createGoal(gdesc, gvalue, gorder) { var tmp1 = { "goal_description": gdesc, "goal_value" : gvalue, "order" : gorder, "high_tip_amount" : 0, "high_tip_username" : null, "max_tip_level" : 0, "goal_status" : "Not Started" }; tmp1["max_tip_level"] = Math.floor(Math.sqrt(gvalue * 2)) + 1; return tmp1; } function init() { cb.chatNotice("***********************************************", "", "#ffffff", "#00BFFF", "bold"); cb.chatNotice("Token Climber Multi-Goal - Version 1.0", "", "#ffffff", "#00BFFF", "bold"); cb.chatNotice("Developer: xNinja666x ", "", "#ffffff", "#00BFFF", "bold"); cb.chatNotice("***********************************************", "", "#ffffff", "#00BFFF", "bold"); mIndex = 0; var goalCount = 0; if (cb.settings.active1 == "active" && cb.settings.goal_description1 && cb.settings.goal_value1 > 0) { goalCount++; mGoal.push (createGoal(cb.settings.goal_description1, cb.settings.goal_value1, cb.settings.order1)); } if (cb.settings.active2 == "active" && cb.settings.goal_description2 && cb.settings.goal_value2 > 0) { goalCount++; mGoal.push (createGoal(cb.settings.goal_description2, cb.settings.goal_value2, cb.settings.order2)); } if (cb.settings.active3 == "active" && cb.settings.goal_description3 && cb.settings.goal_value3 > 0) { goalCount++; mGoal.push (createGoal(cb.settings.goal_description3, cb.settings.goal_value3, cb.settings.order3)); } if (cb.settings.active4 == "active" && cb.settings.goal_description4 && cb.settings.goal_value4 > 0) { goalCount++; mGoal.push (createGoal(cb.settings.goal_description4, cb.settings.goal_value4, cb.settings.order4)); } if (cb.settings.active5 == "active" && cb.settings.goal_description5 && cb.settings.goal_value5 > 0) { goalCount++; mGoal.push (createGoal(cb.settings.goal_description5, cb.settings.goal_value5, cb.settings.order5)); } if (cb.settings.active6 == "active" && cb.settings.goal_description6 && cb.settings.goal_value6 > 0) { goalCount++; mGoal.push (createGoal(cb.settings.goal_description6, cb.settings.goal_value6, cb.settings.order6)); } if (cb.settings.active7 == "active" && cb.settings.goal_description7 && cb.settings.goal_value7 > 0) { goalCount++; mGoal.push (createGoal(cb.settings.goal_description7, cb.settings.goal_value7, cb.settings.order7)); } if (goalCount > 0) { startGoal(); } else { cb.chatNotice("** No Goals Set **", "", "#ffffff", "#FF0000", "bold"); } } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.