Apps Home
|
Create an App
decrement+randomnumber
Author:
habibso01
Description
Source Code
Launch App
Current Users
Created by:
Habibso01
/* Magic Number+decrement by habibso */ // vars var total_tipped = 0; var last_tip_username = null; var next_tip = 0; var goal_reach = 0; var high_tip_username = null; var high_tip_amount = 0; var last_tip_username = null; var last_tip_amount = 0; var numberGuessedCorrectly = false; cb.settings_choices = [ {name: 'Max_Number', type: 'int', minValue: 10, maxValue: 100, default: 50}, {name: 'Magic_Number', type: 'int', minValue: 0, maxValue: 100, default: 0}, {name: 'Prize4magic', type: 'str', minLength: 0, maxLength: 511, default: "put space if none"}, {name: 'Prize4HighestTipper', type: 'str', minLength: 1, maxLength: 511, default: "put space if none"}, {name: 'Prize4Goal', type: 'str', minLength: 0, maxLength: 511, default: "Fully Naked"}, ]; // handlers cb.onTip(function(tip) { total_tipped += tip['amount'] last_tip_user = tip['from_user'] if (tip['amount'] == cb.settings.Magic_Number) { last_tip_username = tip['from_user'] numberGuessedCorrectly = true } if (tip['amount'] >= next_tip) { if (tip['amount'] > high_tip_amount) { high_tip_amount = tip['amount'] high_tip_username = tip['from_user'] } next_tip -= 1 } else if (tip['amount'] < next_tip) { last_tip_username = tip['from_user'] last_tip_amount = tip['amount'] } update_App(); cb.drawPanel(); if (next_tip == 0) { goal_reach += 1 next_tip = cb.settings.Max_Number update_App(); cb.drawPanel(); } }); cb.onDrawPanel(function(user) { return { 'template': '3_rows_of_labels', 'row1_label': 'Next Tip Required:', 'row1_value': next_tip, 'row2_label': 'Highest tipper:', 'row2_value': format_username(high_tip_username) + '(' + high_tip_amount + ' tks)', 'row3_label': 'Goal Reached:', 'row3_value': goal_reach + ' times' }; }); // helper functions function update_App() { if (numberGuessedCorrectly == true) { var new_subject = "We have a winner!. " + last_tip_username + " has guessed the correct number, congratulations!" + cb.settings.Magic_Number + " \nTip in descending order from " + cb.settings.Max_Number + " to 1 " + " Next tip required: " + next_tip + "." + " \nThe Highest tipper gets: " + cb.settings.Prize4HighestTipper + "."; } else { var new_subject = "Tip in descending order from " + cb.settings.Max_Number + " to 1 " + " Next tip required: " + next_tip + "." if (trim_prize(cb.settings.Prize4magic) != "" & trim_prize(cb.settings.Prize4magic) != " ") { new_subject += " \nwho finds The Magic number gets: " + cb.settings.Prize4magic + "." } if (trim_prize(cb.settings.Prize4HighestTipper) != "" & trim_prize(cb.settings.Prize4HighestTipper) != " ") { new_subject += " \nThe Highest tipper gets: " + cb.settings.Prize4HighestTipper + "."; } } cb.log("Changing subject to: " + new_subject); cb.changeRoomSubject(new_subject) } function format_username(val) { if (val === null) { return "--"; } else { return val.substring(0, 12); } } function trim_prize(val) { if (val == null) { return val; } else { return val.trim(); } } function init() { next_tip = cb.settings.Max_Number; update_App(); } init();
© Copyright Chaturbate 2011- 2026. All Rights Reserved.