Apps Home
|
Create an App
countertest345
Author:
markus1987test111
Description
Source Code
Launch App
Current Users
Created by:
Markus1987test111
cb.settings_choices = [ {name: "goalUsers", type:"int", minValue: 1, maxValue: 999, defaultValue: 10, label: "Goal usercount"}, {name: "tipDecreaser", type:"int", minValue: 1, maxValue: 999, label: "Tip amount to decrease goal", required:false}, {name:"choiceStatus1", type:"choice", label:"User in room - Total amount of visitors", choice1:"User", choice2:"Total", defaultValue:"User", required:false}, {name:"choiceStatus2", type:"choice", label:"Automatic Status", choice1:"No", choice2:"Yes", defaultValue:"No", required:false}, {name: "choiceText", type:"str", minLength:1, maxLength:255, label:"Text of automatic status", defaultValue:"", required:false}, ]; var counter = 0; var arrayCount = -1; var missing = 0; var change = 0; var total_tipped = 0; var tipped = 0; var addUser = false; var goal = cb.settings.goalUsers; var tipDecreaseVar = cb.settings.tipDecreaser; var counterChoice = cb.settings.choiceStatus1; var autoStatus = cb.settings.choiceStatus2; var StatusText = cb.settings.choiceText; var goalR = false; var endfor = 0; var new_subject = ""; var visitors = []; var high_tip_username = null; var high_tip_amount = 0; var last_tip_username = null; var last_tip_amount = 0; cb.onDrawPanel(function(user) { return { 'template': '3_rows_of_labels', 'row1_label': 'Tip Received / Goal :', 'row1_value': '' + total_tipped + ' / ' + (((missing*tipDecreaseVar)+total_tipped)-tipped), 'row2_label': 'Highest Tip:', 'row2_value': format_username(high_tip_username) + ' (' + high_tip_amount + ')', 'row3_label': 'Latest Tip Received:', 'row3_value': format_username(last_tip_username) + ' (' + last_tip_amount + ')' }; }); function format_username(val) { if (val === null) { return "--"; } else { return val.substring(0, 12); } } cb.onEnter(function(user) { if (counterChoice == "Total") { checkentry(user); } else { counter = counter+1; missing = goal - counter; if (missing < 1 ) { missing = 0; goalReached(); } else { messageEnter(user); setStatus(); } } }); function checkentry(user) { addUser = true; for (var i=0; i<=arrayCount; i++) { if (visitors[i]["name"] == user["user"]) { addUser = false; cb.sendNotice("Welcome back, " + user["user"]); } } if (addUser == true) { arrayCount++; visitors[arrayCount] = new Object (); visitors[arrayCount]["name"] = user["user"]; counter = counter+1; missing = goal - counter; if (missing < 1 ) { missing = 0; goalReached(); } else { messageEnter(user); setStatus(); cb.drawPanel(); } } } cb.onLeave(function(user) { if (counterChoice == "User") { counter = counter-1; missing = goal - counter; cb.drawPanel(); if (missing < 0 ) { missing = 0; } else { messageLeave(user); } } }); cb.onTip(function (tip) { if (goalR == false) { if (tipDecreaseVar > 0) { tipped += parseInt(tip["amount"]); endfor = tipped; for (var i=0; i<= endfor; i++) { if (tipped >= tipDecreaseVar) { tipped = tipped-tipDecreaseVar; goal = goal-1; missing = goal - counter; /*cb.sendNotice("Missing" + missing);*/ if (missing <= 0) { goalReached(); } else if (tipped < tipDecreaseVar) { cb.sendNotice("Goal changed to " + goal + " user. " + missing + " are still missing to reach the goal."); cb.sendNotice(tipDecreaseVar-tipped + " tokens needed to decrease the goal"); setStatus(); cb.sendNotice(progressBar()); } } else { if (goalR == false) { cb.sendNotice(tipDecreaseVar-tipped + " tokens needed to decrease the goal"); i = endfor; } } } total_tipped += tip['amount'] 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.onMessage(function (msg) { if (msg["user"] == cb.room_slug) { if (msg["m"] == "/add") { goal = goal+1; missing = goal - counter; cb.sendNotice("Goal changed to " + goal + " user. " + missing + " are still missing to reach the goal."); setStatus(); cb.sendNotice(progressBar()); } else if (msg["m"] == "/del") { goal = goal-1; missing = goal - counter; cb.sendNotice("Goal changed to " + goal + " user. " + missing + " are still missing to reach the goal."); setStatus(); cb.sendNotice(progressBar()); } else if (msg["m"] == "/add5") { goal = goal+5; missing = goal - counter; cb.sendNotice("Goal changed to " + goal + " user. " + missing + " are still missing to reach the goal."); setStatus(); cb.sendNotice(progressBar()); } else if (msg["m"] == "/del5") { goal = goal-5; missing = goal - counter; cb.sendNotice("Goal changed to " + goal + " user. " + missing + " are still missing to reach the goal."); setStatus(); cb.sendNotice(progressBar()); } else if (msg["m"] == "/add10") { goal = goal+10; missing = goal - counter; cb.sendNotice("Goal changed to " + goal + " user. " + missing + " are still missing to reach the goal."); setStatus(); cb.sendNotice(progressBar()); } else if (msg["m"] == "/del10") { goal = goal-10; missing = goal - counter; cb.sendNotice("Goal changed to " + goal + " user. " + missing + " are still missing to reach the goal."); setStatus(); cb.sendNotice(progressBar()); } else if (msg["m"] == "/add100") { goal = goal+100; missing = goal - counter; cb.sendNotice("Goal changed to " + goal + " user. " + missing + " are still missing to reach the goal."); setStatus(); cb.sendNotice(progressBar()); } else if (msg["m"] == "/del100") { goal = goal-100; missing = goal - counter; cb.sendNotice("Goal changed to " + goal + " user. " + missing + " are still missing to reach the goal."); setStatus(); cb.sendNotice(progressBar()); } } }) function messageEnter(user) { if (goalR == false) { cb.sendNotice("User number " + counter + " entered the room. :-) " + missing + " user are still missing to reach the goal."); cb.sendNotice(progressBar()); cb.sendNotice("You can decrease the goal every " + tipDecreaseVar + " tokens."); if (tipDecreaseVar > 1) { cb.sendNotice(tipDecreaseVar-tipped + " tokens needed for the next decrease."); } } } function messageLeave(user) { if (goalR == false) { cb.sendNotice("One user left the room. :-( " + missing + " user are still missing to reach the goal."); cb.sendNotice(progressBar()); } } function goalReached() { cb.changeRoomSubject("!!! GOAL REACHED !!!"); cb.sendNotice("Goal reached! The show will start now :-D"); goalR = true; cb.sendNotice(progressBar()); } function setStatus() { if (autoStatus == "Yes"){ if (counterChoice == "Total") { new_subject = missing + " user missing - when " + goal + " different user visited my room: " + StatusText } else { new_subject = missing + " user missing - when " + goal + " stay in my room: " + StatusText } cb.changeRoomSubject(new_subject); } } function round(value, decimals) { return Number(Math.round(value+"e"+decimals)+"e-"+decimals); } function progressBar() { var countBar = ""; var countBars = ""; var countProgress = ""; var countPercenty = ""; var countPercent = ""; var countPercentInt = ""; var countLeft = ""; if (counter > goal) { countPercent = 100; } else { countPercent = round((counter/goal)*100,2); } countPercentInt = parseInt(countPercent,10); // 10 countLeft = (goal - counter); var countBars = { g00 : "\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592", g05 : "\u2593\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592", g10 : "\u2593\u2593\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592", g15 : "\u2593\u2593\u2593\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592", g20 : "\u2593\u2593\u2593\u2593\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592", g25 : "\u2593\u2593\u2593\u2593\u2593\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592", g30 : "\u2593\u2593\u2593\u2593\u2593\u2593\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592", g35 : "\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592", g40 : "\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592", g45 : "\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592", g50 : "\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592", g55 : "\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592", g60 : "\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2592\u2592\u2592\u2592\u2592\u2592\u2592\u2592", g65 : "\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2592\u2592\u2592\u2592\u2592\u2592\u2592", g70 : "\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2592\u2592\u2592\u2592\u2592\u2592", g75 : "\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2592\u2592\u2592\u2592\u2592", g80 : "\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2592\u2592\u2592\u2592", g85 : "\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2592\u2592\u2592", g90 : "\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2592\u2592", g95 : "\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2592", gxx : "\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593\u2593", }; // Expand to be more detailed. if (countPercentInt < 5) { countBar = countBars.g00; } else if (countPercentInt < 10) { countBar = countBars.g05; } else if (countPercentInt < 15) { countBar = countBars.g10; } else if (countPercentInt < 20) { countBar = countBars.g15; } else if (countPercentInt < 25) { countBar = countBars.g20; } else if (countPercentInt < 30) { countBar = countBars.g25; } else if (countPercentInt < 35) { countBar = countBars.g30; } else if (countPercentInt < 40) { countBar = countBars.g35; } else if (countPercentInt < 45) { countBar = countBars.g40; } else if (countPercentInt < 50) { countBar = countBars.g45; } else if (countPercentInt < 55) { countBar = countBars.g50; } else if (countPercentInt < 60) { countBar = countBars.g55; } else if (countPercentInt < 65) { countBar = countBars.g60; } else if (countPercentInt < 70) { countBar = countBars.g65; } else if (countPercentInt < 75) { countBar = countBars.g70; } else if (countPercentInt < 80) { countBar = countBars.g75; } else if (countPercentInt < 85) { countBar = countBars.g80; } else if (countPercentInt < 90) { countBar = countBars.g85; } else if (countPercentInt < 95) { countBar = countBars.g90; } else if (countPercentInt < 100) { countBar = countBars.g95; } else if (countPercentInt >= 100) { countBar = countBars.gxx; } countProgress = countBar+" ("+countPercent+"%)"; /* DEBUG var debug = "\n DEBUG: "; debug += "\n counter: "+counter; debug += "\n goal: "+goal; debug += "\n countPercenty: "+countPercenty; debug += "\n countPercent: "+countPercent; debug += "\n countPercentInt: "+countPercentInt; debug += "\n countLeft: "+countLeft; debug += "\n countBars: "+countBars; debug += "\n countBar: "+countBar; debug += "\n countProgress: "+countProgress+"\n"; cb.sendNotice(debug); */ return countProgress; } function init() { missing = goal; setStatus(); cb.changeRoomSubject(new_subject); cb.drawPanel(); } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.