Apps Home
|
Create an App
Fit Princess' Token Climber
Author:
jamjamsplayroom
Description
Source Code
Launch App
Current Users
Created by:
Jamjamsplayroom
/* App: TOKEN CLIMBER * Based on: SEQUENCE TIPS ORIGNALLY DEVELOPED BY: Cliche123 & Nolidoux, * highest tipper code from Elle Sterling Sequential Tips * Modified For Gianna Renee AKA FitPrincess * Reasons for changes. * Many tokens are wasted with sequence tips as the tip is too small or too big. This could be because the tipper misunderstood the app, * couldn't afford more, was tipping for a request, didn't want to make a large tip or somebody else tipped at the same time for example. * Large tip levels can make the goal hard to reach. * * This app does not waste the tokens as they will build towards climbing to the next level. It also works out the approximate level * needed to achieve the desired tokens for the broadcasters goal. Highest total tipper is highlighted in chat and on the info panel. * * Modification History * 1.0 19 Sep 2016 by JAMIEJAM1 - Intitial release */ // vars var max_tip_level = null; var next_level_amount = 1; var support_level_amount = 0; var goal_reached = false; var high_tip_amount = 0; var high_tip_username = null; var imena = new Array(); var tipovi = new Array(); // var version = 1 // Limit goal description as we add some text cb.settings_choices = [ { name: 'goal_description', type: 'str', minLength: 1, maxLength: 190, label:"Goal Description" }, { name: 'goal_value', type: 'int', minValue: 1, maxValue: 100000, default: 1000, label:"Gianna's Goal" }, { name: 'order', type: 'choice', choice1: 'ascending', choice2: 'descending', default: 'ascending' } ]; cb.onTip( function (tip) { 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 (checkGoalReached()) { return { 'template': '3_rows_11_21_31', 'row1_value': '*** Gias Goal Reached! ***', 'row2_value': format_username(high_tip_username) + "("+high_tip_amount+")", 'row3_value': 'Thanksto all contributors!' }; } 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': 'Extra Tips on board:', 'row2_value': support_level_amount, 'row3_label': 'Highest Total Tips:', 'row3_value': format_username(high_tip_username) + "("+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': 'Extra Tips on Board:', 'row2_value': support_level_amount, 'row3_label': 'Highest Total Tips:', 'row3_value': format_username(high_tip_username) + "("+high_tip_amount+")" }; } } } ); cb.onMessage(function (msg) { if (msg['user'] == 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 = cb.settings.goal_description + " [ Gia's Goal reached! Thanks to all Contributors!]"; goal_reached = true; } else { if (isAscendingOrder()) { new_subject = cb.settings.goal_description + " [Tip to ascend levels from 1 to " + max_tip_level + ". Tip for next level: " + tip_for_next_level + "]"; } else { new_subject = cb.settings.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(high_tip_amount==0 || high_tip_amount<tip) { high_tip_amount=tip; high_tip_username=ime; } } else { cb.log("old"); tipovi[index]+=tip; if (tipovi[index]>high_tip_amount) { high_tip_amount=tipovi[index]; high_tip_username=imena[index]; } } } function isAscendingOrder() { return (cb.settings.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 init() { cb.chatNotice("***********************************************"); cb.chatNotice("----------Token Climber Modified for Fit Princess---------- "); cb.chatNotice("-------------------------Jamiejam1----------------------- "); cb.chatNotice("------------------------Version 2.1-------------------------"); cb.chatNotice("***********************************************"); max_tip_level = Math.floor(Math.sqrt(cb.settings.goal_value * 2)) + 1; if (isAscendingOrder()) { next_level_amount = 1; } else { next_level_amount = max_tip_level; } update_subject(); } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.