Apps Home
|
Create an App
Auto-Reset Goal
Author:
kilian_90
Description
Source Code
Launch App
Current Users
Created by:
Kilian_90
var app = { name: "'CrazyGoal'", type: "App", version: "1.0", build: ".001", date: "2017.07.22" }; var COLOR = { DEVELOPER: "#D9F7F7", NOTICE: "#6900CC", RED: "#FF1407", MRED: "#D80A00", HIGHLIGHT: "#EEE5FF", SYNTAX: "#995B00", AMBER: "#E56B00", MOD: "#DC0000", HVTEXT: "#D80A00", HVBACK: "#FFFFBF", TBMBACK: "#E0EEFF", TBMTEXT: "#12447A", HELP: "#144D8C", INFO: "#144D8C", MAG: "#E509E5", BLUE: "#000099" }; var FLAG = { reset: false, multi: false, multiend: false, war: false, tmenu: false, end: false, won: false }; var black_circle = "\u25cf"; // ● var LOWER_HALF_BLOCK = "\u2584"; // ▄ var THIN_SPACE = "\u2009"; var FULL_BLOCK = "\u2588"; // █ var MEDIUM_SHADE = "\u2592"; // ▒ var LIGHT_SHADE = "\u2591"; // ░ var START_STAR = "\u25BF"; // ▿ var HALF_STAR = "\u2606"; // ☆ var FULL_STAR = "\u2605"; // ★ var tipTot = 0; var tipGoal = 0; var warGoal1 = 0; var warGoal2 = 0; var tipPercent = 0; var goalCnt = 0; var progBar = ""; var theWinner = ""; var MODS = "red"; var roomHost = cb["room_slug"]; var dashLine = charRepeat("-", 60); var multi = { goal: [], desc: [] }; cb["settings_choices"] = [{ name: "goalType", type: "choice", choice1: "Simple Tip Goal", choice2: "Auto-Reset Goal", choice3: "Goal War", defaultValue: "Simple Tip Goal", label: "Choose the type of Goal. If 'Goal War' is chosen fill in all fields labeled GOAL WAR" }, { name: "tipGoal", type: "int", minValue: 1, defaultValue: 100, label: "Enter the token amount for Simple Tip Goal or Auto-Reset Goal", required: false }, { name: "tipGoalDesc", type: "str", label: "Enter description for Simple Tip Goal or Auto-Reset Goal", required: false }, { name: "barStyle", type: "choice", choice1: "autumnvondoe", defaultValue: "autumnvondoe", label: "Choose Graphic Progress Bar style" }, { name: "wd", type: "choice", choice1: "", label: "******************** GOAL WAR SETTINGS ********************", required: false }, { name: "warMenu", type: "choice", choice1: "Menu", choice2: "Tip Note", defaultValue: "Tip Note", label: "** GOAL WAR ** Choose whether viewers will vote with the Tip Menu or by typing the voting word in a tip note. If you choose 'Menu', viewers will NOT be able to send ANY tip notes." }, { name: "warGoal1", type: "int", minValue: 1, defaultValue: 100, label: "** GOAL WAR ** Token amount for Goal #1", required: false }, { name: "warDesc1", type: "str", defaultValue: "Eat my hat", label: "** GOAL WAR ** Description for Goal #1", required: false }, { name: "warMenu1", type: "str", defaultValue: "HAT", label: "** GOAL WAR ** Tip Menu selection #1", required: false }, { name: "warGoal2", type: "int", minValue: 1, defaultValue: 100, label: "** GOAL WAR ** Token amount for Goal #2", required: false }, { name: "warDesc2", type: "str", defaultValue: "Eat my socks", label: "** GOAL WAR ** Description for Goal #2", required: false }, { name: "warMenu2", type: "str", defaultValue: "SOCKS", label: "** GOAL WAR **: Tip Menu selection #2", required: false }]; if (cb["settings"]["goalType"] === "Auto-Reset Goal") { FLAG["reset"] = true; } if (cb["settings"]["goalType"] === "Goal War") { FLAG["war"] = true; } if (cb["settings"]["warMenu"] === "Menu") { FLAG["tmenu"] = true; } if (FLAG["war"]) { re1 = new RegExp(cb["settings"]["warMenu1"], "i"); re2 = new RegExp(cb["settings"]["warMenu2"], "i"); } cb["onDrawPanel"](function(dataAndEvents) { if (FLAG["war"]) { if (!FLAG["end"]) { return { "template": "3_rows_11_21_31", "row1_value": "G O A L W A R !", "row2_value": cb["settings"]["warMenu1"] + ": " + warGoal1 + " / " + cb["settings"]["warGoal1"], "row3_value": cb["settings"]["warMenu2"] + ": " + warGoal2 + " / " + cb["settings"]["warGoal2"] }; } else { return { "template": "3_rows_11_21_31", "row1_value": "THE WINNER IS:", "row2_value": "-= " + theWinner + " =-", "row3_value": "" }; } } else { if (FLAG["reset"]) { return { "template": "3_rows_11_21_31", "row1_value": "Goals Reached: " + goalCnt + black_circle + " Current: " + tipGoal % cb["settings"]["tipGoal"] + " / " + cb["settings"]["tipGoal"], "row2_value": "Goal Progress: " + progBar + black_circle + tipPercent + "%", "row3_value": "Remaining for Goal #" + (goalCnt + 1) + ": " + (cb["settings"]["tipGoal"] - tipGoal % cb["settings"]["tipGoal"]) + black_circle + " Total: " + tipGoal }; } else { return { "template": "3_rows_11_21_31", "row1_value": "Tips / Goal " + +tipGoal + " / " + cb["settings"]["tipGoal"], "row2_value": "Goal Progress: " + progBar + black_circle + tipPercent + "%", "row3_value": "Remaining for Goal: " + (cb["settings"]["tipGoal"] - tipGoal) }; } } }); cb["onEnter"](function(args) { var pageX = args["user"]; if (FLAG["war"] && !FLAG["end"]) { cb["sendNotice"](dashLine + "\n" + black_circle + " Time for a 'CrazyGoal' War!\n" + black_circle + " To vote, tip and " + (FLAG["tmenu"] ? "choose from the menu:" : "type in a Tip Note:") + "\n" + black_circle + " '" + cb["settings"]["warMenu1"] + "' to vote for '" + cb["settings"]["warDesc1"] + "'\n" + black_circle + " '" + cb["settings"]["warMenu2"] + "' to vote for '" + cb["settings"]["warDesc2"] + (FLAG["tmenu"] ? "'" : "'\n" + black_circle + " Quotes not required and case does not matter.") + "\n" + dashLine, pageX, COLOR.HIGHLIGHT, COLOR.NOTICE, "bold"); } }); if (FLAG["war"] && FLAG["tmenu"]) { cb["tipOptions"](function(dataAndEvents) { return { options: [{ label: "Regular Tip - No vote" }, { label: cb["settings"]["warMenu1"] }, { label: cb["settings"]["warMenu2"] }], label: "CHOOSE ONE:" }; }); } cb["onTip"](function(args) { var pageX = args["from_user"]; var callback = args["message"]; var charCodeToReplace = parseInt(args["amount"], 10); var _0x6220x15 = 0; var _0x6220x16 = 0; tipTot += charCodeToReplace; if (FLAG["war"]) { if (re1["test"](callback) && re2["test"](callback)) { cb["sendNotice"](dashLine + "\n" + black_circle + " Nope, you can't vote for both.\n" + dashLine, pageX, "", COLOR.RED, "bold"); return; } } if (FLAG["war"]) { if (!FLAG["end"]) { if (re1["test"](callback)) { warGoal1 += charCodeToReplace; cb["sendNotice"](black_circle + "'" + pageX + "' voted for '" + cb["settings"]["warDesc1"] + "'.", "", "", COLOR.NOTICE, "bold"); if (warGoal1 >= cb["settings"]["warGoal1"]) { warGoal1 = cb["settings"]["warGoal1"]; FLAG["end"] = true; theWinner = cb["settings"]["warDesc1"]; } } if (re2["test"](callback)) { warGoal2 += charCodeToReplace; cb["sendNotice"](black_circle + "'" + pageX + "' voted for '" + cb["settings"]["warDesc2"] + "'.", "", "", COLOR.NOTICE, "bold"); if (warGoal2 >= cb["settings"]["warGoal2"]) { warGoal2 = cb["settings"]["warGoal2"]; FLAG["end"] = true; theWinner = cb["settings"]["warDesc2"]; } } } if (FLAG["end"] && !FLAG["won"]) { cb["changeRoomSubject"]("'CrazyGoal War'! THE WINNING GOAL: " + theWinner); cb["sendNotice"](dashLine + "\n" + black_circle + " THE WINNING GOAL: " + theWinner + "\n" + dashLine, "", "", COLOR.RED, "bold"); FLAG["won"] = true; } } else { if (FLAG["reset"]) { tipGoal += charCodeToReplace; _0x6220x16 = goalCnt; goalCnt = parseInt(tipGoal / cb["settings"]["tipGoal"], 10); if (goalCnt > _0x6220x16 && goalCnt - _0x6220x16 < 2) { cb["sendNotice"](dashLine + "\n" + black_circle + " Goal has been reached " + goalCnt + " " + (goalCnt === 1 ? "time.\n" : "times.\n") + dashLine, "", "", COLOR.MRED, "bold"); } else { if (goalCnt > _0x6220x16 && goalCnt - _0x6220x16 >= 2) { cb["sendNotice"](dashLine + "\n" + black_circle + " Goal has been reached " + (_0x6220x16 + 1) + " thru " + goalCnt + " times!\n" + dashLine, "", "", COLOR.MRED, "bold"); } } _0x6220x15 = tipGoal; tipGoal = tipGoal % cb["settings"]["tipGoal"]; progressBar(); tipGoal = _0x6220x15; } else { tipGoal += charCodeToReplace; progressBar(); if (tipGoal >= cb["settings"]["tipGoal"]) { tipGoal = cb["settings"]["tipGoal"]; if (!FLAG["end"]) { cb["changeRoomSubject"]("'CrazyGoal': GOAL ATTAINED !! " + (cb["settings"]["tipGoalDesc"] ? "[ " + cb["settings"]["tipGoalDesc"] + " ]" : "")); cb["sendNotice"](dashLine + "\n" + black_circle + " GOAL ATTAINED !!\n" + (cb["settings"]["tipGoalDesc"] ? black_circle + "[" + cb["settings"]["tipGoalDesc"] + "]\n" : "") + dashLine, "", "", COLOR.RED, "bold"); FLAG["end"] = true; } } } } cb["drawPanel"](); }); cb["onMessage"](function(tokens) { var regexS = "^" + "/" + "(S+)(?:\bs*)(.*)?"; var pos0 = /[,\s]+/; var regex = new RegExp(regexS); var target = tokens["m"]["match"](regex); var src; var data; var result0; if (target) { src = target[1]; data = target[2]; if (data != null) { data = data["replace"](/^\s+|\s+$/g, ""); } if (data != null) { result0 = data["split"](pos0); } else { result0 = ""; } } var ns = tokens["m"]; var token = tokens["user"]; var firstArgTkn = tokens["is_mod"]; var point = token === roomHost; if (tokens["m"][0] === "/") { tokens["X-Spam"] = true; } }); function progressBar() { progBar = ""; tipPercent = 0; var oldMillis; var millis; var attributes; var r20; var _0x6220x29; var rreturn; if (cb["settings"]["barStyle"] === "autumnvondoe") { r20 = START_STAR; _0x6220x29 = HALF_STAR; rreturn = FULL_STAR; } if (tipGoal > cb["settings"]["tipGoal"]) { tipGoal = cb["settings"]["tipGoal"]; tipPercent = 100; } else { tipPercent = Math["round"](tipGoal / cb["settings"]["tipGoal"] * 100); if (tipPercent === 100 && tipGoal % cb["settings"]["tipGoal"] != 0) { tipPercent = 99; } } oldMillis = (tipPercent - tipPercent % 10) / 10; millis = tipPercent % 10 > 0 ? 1 : 0; attributes = 10 - (oldMillis + millis); progBar += charRepeat(rreturn, oldMillis); if (millis === 1) { progBar += _0x6220x29; } else { progBar += ""; } progBar += charRepeat(r20, attributes); } function charRepeat(regex, opt_attributes) { var optsData = ""; for (var i = 1; i <= opt_attributes; i++) { optsData += regex; } return optsData; } function init() { startTime = new Date; var r20 = dashLine + "\n" + black_circle + " " + app["name"] + "\n" + black_circle + " Version: " + app["version"] + app["build"] + " (" + app["date"] + ")\n" + dashLine; cb["sendNotice"](r20, roomHost, "", COLOR.INFO, "bold"); progressBar(); cb["sendNotice"](dashLine + "\n" + black_circle + " " + app["name"] + " Version " + app["version"] + app["build"] + " (" + app["date"] + ") started.\n" + dashLine, "", "", COLOR.INFO, "bold"); } init();
© Copyright Chaturbate 2011- 2026. All Rights Reserved.