Apps Home
|
My Uploads
|
Create an App
Cambiando
Author:
crearapp
Description
Source Code
Launch App
Current Users
Created by:
Crearapp
App Images
// vars var total_tipped = 0; var high_tip_username = null; var high_tip_amount = 0; var last_tip_username = null; var last_tip_amount = 0; var subject_is_set_with_0 = false; var backgroundImage = '879dc086-54d0-42c7-b210-82b011c996c6'; var fontSize = 11; cb.settings_choices = [ {name: 'tokens', type: 'int', minValue: 1, default: 100}, {name: 'goal_description', type: 'str', minLength: 1, maxLength: 255} ]; // handlers cb.onTip(function(tip) { total_tipped += tip['amount'] if (total_tipped > cb.settings.tokens) { total_tipped = cb.settings.tokens; } update_subject(); last_tip_amount = tip['amount'] last_tip_username = tip['from_user'] if (tip['amount'] > high_tip_amount) { high_tip_amount = tip['amount'] high_tip_username = tip['from_user'] } cb.drawPanel(); }); cb.onDrawPanel(function(user) { return { "template": "image_template", "layers": [ {'type': 'image', 'fileID': backgroundImage}, { 'type': 'text', 'text': 'TIPS RECEIVED', 'top': 5, 'left': 61, 'font-size': fontSize, 'color': 'orange', }, { 'type': 'text', 'text': 'HIGHEST TIP', 'top': 29, 'left': 73, 'font-size': fontSize, 'color': 'orange', }, { 'type': 'text', 'text': 'LATEST TIP RECEIVED', 'top': 52, 'left': 28, 'font-size': fontSize, 'color': 'orange', }, { 'type': 'text', 'text': total_tipped, 'top': 5, 'left': 147, 'font-size': fontSize, 'color': 'white', }, { 'type': 'text', 'text': high_tip_amount, 'top': 29, 'left': 147, 'font-size': fontSize, 'color': 'white', }, { 'type': 'text', 'text': last_tip_username, 'top': 51, 'left': 147, 'font-size': fontSize, 'color': 'white', }, ], }; }); // helper functions function update_subject() { if (tips_remaining() == 0) { if (subject_is_set_with_0) { return; } subject_is_set_with_0 = true; } else { subject_is_set_with_0 = false; } var new_subject = cb.settings.goal_description + " [" + tips_remaining() + " tokens remaining]"; cb.log("Changing subject to: " + new_subject); cb.changeRoomSubject(new_subject); } function tips_remaining() { var r = cb.settings.tokens - total_tipped; if (r < 0) { return 0; } else { return r; } } function format_username(val) { if (val === null) { return "--"; } else { return val.substring(0, 12); } } function init() { update_subject(); } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.