Apps Home
|
Create an App
countertest123
Author:
markus1987test111
Description
Source Code
Launch App
Current Users
Created by:
Markus1987test111
cb.settings_choices = [ {name: "goalUsernumber1", type:"int", minValue: 1, maxValue: 999, defaultValue: 10, label: "Usernumber goal #1"}, {name: "goalText1", type:"str", minLength:1, maxLength:255, label:"Text goal #1", defaultValue:"", required:true}, {name: "goalUsernumber2", type:"int", minValue: 1, maxValue: 999, defaultValue: 10, label: "Usernumber goal #2"}, {name: "goalText2", type:"str", minLength:1, maxLength:255, label:"Text goal #2", defaultValue:"", required:false}, {name: "goalUsernumber3", type:"int", minValue: 1, maxValue: 999, defaultValue: 10, label: "Usernumber goal #3"}, {name: "goalText3", type:"str", minLength:1, maxLength:255, label:"Text goal #3", defaultValue:"", required:false}, {name: "goalUsernumber4", type:"int", minValue: 1, maxValue: 999, defaultValue: 10, label: "Usernumber goal #4"}, {name: "goalText4", type:"str", minLength:1, maxLength:255, label:"Text goal #4", defaultValue:"", required:false}, {name: "goalUsernumber5", type:"int", minValue: 1, maxValue: 999, defaultValue: 10, label: "Usernumber goal #5"}, {name: "goalText5", type:"str", minLength:1, maxLength:255, label:"Text goal #5", defaultValue:"", required:false}, {name: "goalUsernumber6", type:"int", minValue: 1, maxValue: 999, defaultValue: 10, label: "Usernumber goal #6"}, {name: "goalText6", type:"str", minLength:1, maxLength:255, label:"Text goal #6", defaultValue:"", required:false}, {name: "goalUsernumber7", type:"int", minValue: 1, maxValue: 999, defaultValue: 10, label: "Usernumber goal #7"}, {name: "goalText7", type:"str", minLength:1, maxLength:255, label:"Text goal #7", defaultValue:"", required:false}, {name: "goalUsernumber8", type:"int", minValue: 1, maxValue: 999, defaultValue: 10, label: "Usernumber goal #8"}, {name: "goalText8", type:"str", minLength:1, maxLength:255, label:"Text goal #8", defaultValue:"", required:false}, {name: "tipDecreaser", type:"int", minValue: 1, maxValue: 999, label: "Tip amount to increase user number", required:false}, {name: "choiceStatus1", type:"choice", label:"User in room - Total amount of visitors", choice1:"User", choice2:"Total", defaultValue:"User", required:false}, ]; var goalUsernumber1 = cb.settings.goalUsernumber1; var goalUsernumber2 = cb.settings.goalUsernumber2; var goalUsernumber3 = cb.settings.goalUsernumber3; var goalUsernumber4 = cb.settings.goalUsernumber4; var goalUsernumber5 = cb.settings.goalUsernumber5; var goalUsernumber6 = cb.settings.goalUsernumber6; var goalUsernumber7 = cb.settings.goalUsernumber7; var goalUsernumber8 = cb.settings.goalUsernumber8; var goalText1 = ""; var goalText2 = ""; var goalText3 = ""; var goalText4 = ""; var goalText5 = ""; var goalText6 = ""; var goalText7 = ""; var goalText8 = ""; var tipIncreaseVar = cb.settings.tipDecreaser; var counterChoice = cb.settings.choiceStatus1; var goalNumbers = 1; var currentGoal = 1; var nextGoal = ""; var lastGoal = ""; var counter = 0; var arrayCount = -1; var missing = 0; var change = 0; var total_tipped = 0; var goal_tipped = 0; var tipped = 0; var addUser = false; var goal = cb.settings.goalUsers; 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': 'Tips received / Next goal:', 'row1_value': goal_tipped + ' / ' + (((missing*tipDecreaseVar)+goal_tipped)-tipped), 'row2_label': 'Last goal:', 'row2_value': lastGoal, 'row3_label': 'Highest tip / Latest tip received:', 'row3_value': format_username(high_tip_username) + ' (' + high_tip_amount + ') / '+format_username(last_tip_username) + ' (' + last_tip_amount + ')' }; }); */ cb.onDrawPanel(function(user) { return { 'template': '3_rows_of_labels', 'row1_label': 'Next goal:', 'row1_value': nextGoal, 'row2_label': 'Last goal:', 'row2_value': lastGoal, 'row3_label': '-', 'row3_value': '-' }; }); function format_username(val) { if (val === null) { return "--"; } else { return val.substring(0, 12); } } function checkGoal() { counter++; missing = goal - counter; if (missing=0) { } } 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 next 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 next 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 next 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 next 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 next 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 next 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 next 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 next goal."); setStatus(); cb.sendNotice(progressBar()); } else if (msg["m"] == "/restart") { if (counterChoice == "Total") { missing = goal; } } } }) function messageEnter(user) { if (goalR == false) { cb.sendNotice("User number " + counter + " entered the room. :-) " + missing + " user are still missing to reach the next goal."); cb.sendNotice(progressBar()); cb.sendNotice("You can increase the number of users with your tips! (1 user = " + 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 finalGoalReached() { cb.changeRoomSubject("!!! FINAL GOAL REACHED !!!"); cb.sendNotice("Goal reached! The show will start now :-D"); goalR = true; cb.sendNotice(progressBar()); } function GoalReached() { cb.changeRoomSubject("!!! FINAL GOAL REACHED !!!"); cb.sendNotice("Goal reached! The show will start now :-D"); goalR = true; cb.sendNotice(progressBar()); } function setStatus() { if (counterChoice == "Total") { new_subject = "Goal #" +currentGoal+ ": " + nextGoal + " - " + missing + " user missing (Number of visits in my room)"; } else { new_subject = "Goal #" +currentGoal+ ": " + nextGoal + " - " + missing + " user missing (Total number of user staying in my room)"; } cb.changeRoomSubject(new_subject); if (currentGoal == 2) { cb.sendNotice("Goal #1 reached: " +goalText1); } else if (currentGoal == 3) { cb.sendNotice("Goal #2 reached: " +goalText2); } else if (currentGoal == 4) { cb.sendNotice("Goal #3 reached: " +goalText3); } else if (currentGoal == 5) { cb.sendNotice("Goal #4 reached: " +goalText4); } else if (currentGoal == 6) { cb.sendNotice("Goal #5 reached: " +goalText5); } else if (currentGoal == 7) { cb.sendNotice("Goal #6 reached: " +goalText6); } else if (currentGoal == 8) { cb.sendNotice("Goal #7 reached: " +goalText7); } } 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() { goalText1 = cb.settings.goalText1; goalText2 = cb.settings.goalText2; goalText3 = cb.settings.goalText3; goalText4 = cb.settings.goalText4; goalText5 = cb.settings.goalText5; goalText6 = cb.settings.goalText6; goalText7 = cb.settings.goalText7; goalText8 = cb.settings.goalText8; if (goalText8 != "") { goalNumbers = 8; } else if (goalText7 != "") { goalNumbers = 7; } else if (goalText6 != "") { goalNumbers = 6; } else if (goalText5 != "") { goalNumbers = 5; } else if (goalText4 != "") { goalNumbers = 4; } else if (goalText3 != "") { goalNumbers = 3; } else if (goalText2 != "") { goalNumbers = 2; } missing = goalUsernumber1; nextGoal = goalText1; setStatus(); cb.changeRoomSubject(new_subject); cb.drawPanel(); } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.