Apps Home
|
Create an App
TestPanelDraw2.0
Author:
mwldevapp
Description
Source Code
Launch App
Current Users
Created by:
Mwldevapp
var totalTip = 0; var topTip = 0; var topTipName = null; var lastTip = 0; var lastTipName = null; var goalReached = false; var fontSize = 11; cb.settings_choices = [ { name: 'tokens', type: 'int', minValue: 1, default: 200, label: 'Token required for the goal' }, { name: 'goal_description', type: 'str', minLength: 1, maxLength: 255, label: 'Description (dont forget the tags)' } ]; cb.onDrawPanel(function(user) { return { "template": "image_template", "layers": [ { 'type': 'image', 'fileID': "570a4c89-03b8-412b-b003-52094c156f44" }, { 'type': 'text', 'text': 'Received Tips', 'top': 5, 'left': 58, 'font-size': fontSize, 'color': 'lightblue', }, { 'type': 'text', 'text': 'Highest Tip', 'top': 29, 'left': 68, 'font-size': fontSize, 'color': 'yellow', }, { 'type': 'text', 'text': 'Latest Tip', 'top': 52, 'left': 74, 'font-size': fontSize, 'color': 'orange', }, { 'type': 'text', 'text': totalTip + ' / ' + cb.settings.tokens, 'top': 5, 'left': 147, 'font-size': fontSize, 'color': 'white', }, { 'type': 'text', 'text': FormatUser(topTipName) + ' (' + topTip + ')', 'top': 29, 'left': 147, 'font-size': fontSize, 'color': 'white', }, { 'type': 'text', 'text': FormatUser(lastTipName) + ' (' + lastTip + ')', 'top': 51, 'left': 147, 'font-size': fontSize, 'color': 'white', }, ], }; }); cb.onTip(function(tip) { totalTip += tip['amount']; if (totalTip > cb.settings.tokens) { totalTip = cb.settings.tokens; } lastTip = tip['amount']; lastTipName = tip['from_user']; if (tip['amount'] > topTip) { topTip = tip['amount']; topTipName = tip['from_user']; } cb.drawPanel(); update(); }); function TipsRemaining() { var t = cb.settings.tokens - totalTip; if (t <= 0) { goalReached = true; return 0; } return t; } function FormatUser(usr) { if (usr === null) { return "--"; } return usr.substring(0, 12); } function update() { if (goalReached) { return; } var new_subject = cb.settings.goal_description + " [" + TipsRemaining() + " tokens remaining]"; cb.log("Changing subject to: " + new_subject); cb.changeRoomSubject(new_subject); } //Main function init() { update(); } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.