Apps Home
|
Create an App
Cam Quest
Author:
camquest
Description
Source Code
Launch App
Current Users
Created by:
Camquest
/* CamQuest v0.1 Interactive tip adventure app for Chaturbate. */ cb.settings_choices = [ { name: 'theme', type: 'choice', choice1: 'Fantasy Dungeon', choice2: 'Space Mission', choice3: 'Haunted Hotel', defaultValue: 'Fantasy Dungeon', label: 'Quest Theme' }, { name: 'goal_tokens', type: 'int', minValue: 10, maxValue: 9999, defaultValue: 250, label: 'Tokens Needed Per Quest Stage' }, { name: 'announce_minutes', type: 'int', minValue: 1, maxValue: 30, defaultValue: 5, label: 'Auto Announce Every X Minutes' } ]; var totalTips = 0; var stageTips = 0; var currentStage = 0; var lastTipper = 'None yet'; var lastEvent = 'Quest is waiting to begin.'; var voteOpen = false; var voteOne = 0; var voteTwo = 0; var voters = {}; function getGoal() { return parseInt(cb.settings.goal_tokens, 10) || 250; } function getStages() { if (cb.settings.theme === 'Space Mission') { return [ { name: 'Launch Pad', goal: 'Fuel the rocket', win: 'š The rocket launches into the stars!', vote1: 'Visit the Moon Base', vote2: 'Enter the Asteroid Cave' }, { name: 'Moon Base', goal: 'Repair the airlock', win: 'š The Moon Base doors open.', vote1: 'Search the lab', vote2: 'Follow the signal' }, { name: 'Alien Ruins', goal: 'Activate the crystal gate', win: 'š½ The ancient alien gate glows to life.', vote1: 'Step through', vote2: 'Scan the ruins' } ]; } if (cb.settings.theme === 'Haunted Hotel') { return [ { name: 'Hotel Lobby', goal: 'Unlock the elevator', win: 'šÆļø The elevator unlocks with a spooky ding.', vote1: 'Go to the Penthouse', vote2: 'Go to the Basement' }, { name: 'Basement Hall', goal: 'Light the old lantern', win: 'š¦ The lantern flickers on.', vote1: 'Open the red door', vote2: 'Follow the whisper' }, { name: 'Penthouse Suite', goal: 'Find the silver key', win: 'š The silver key appears under the rug.', vote1: 'Escape the hotel', vote2: 'Enter the mirror room' } ]; } return [ { name: 'Village Gate', goal: 'Open the old gate', win: 'šļø The old gate creaks open.', vote1: 'Enter the forest', vote2: 'Enter the cave' }, { name: 'Crystal Cave', goal: 'Wake the crystal', win: 'š The crystal begins to glow.', vote1: 'Touch the crystal', vote2: 'Search deeper' }, { name: 'Dragon Chamber', goal: 'Defeat the tiny dragon', win: 'š The tiny dragon has been defeated!', vote1: 'Claim treasure', vote2: 'Befriend dragon' } ]; } function getStage() { var stages = getStages(); return stages[currentStage % stages.length]; } function progressText() { var stage = getStage(); return 'š® CamQuest: ' + cb.settings.theme + '\nš Stage: ' + stage.name + '\nšÆ Goal: ' + stage.goal + '\nš° Progress: ' + stageTips + '/' + getGoal() + ' tokens' + '\nš Total Quest Tips: ' + totalTips + '\nš Last Tipper: ' + lastTipper; } function announceStatus(toUser) { cb.sendNotice( progressText(), toUser || '', '#201030', '#ffffff', 'bold' ); } function startVote() { var stage = getStage(); voteOpen = true; voteOne = 0; voteTwo = 0; voters = {}; cb.sendNotice( 'š³ļø QUEST VOTE OPEN!\n' + 'Type /vote 1 for: ' + stage.vote1 + '\n' + 'Type /vote 2 for: ' + stage.vote2 + '\n' + 'Voting closes in 60 seconds.', '', '#301040', '#ffffff', 'bold' ); cb.setTimeout(closeVote, 60000); } function closeVote() { if (!voteOpen) { return; } voteOpen = false; var stage = getStage(); var winner; if (voteOne > voteTwo) { winner = stage.vote1; } else if (voteTwo > voteOne) { winner = stage.vote2; } else { winner = 'Tie! The quest path is chosen by fate.'; } currentStage += 1; stageTips = 0; lastEvent = 'Vote result: ' + winner; cb.sendNotice( 'ā VOTE CLOSED!\n' + 'Result: ' + winner + '\n\n' + 'New quest stage unlocked:\n' + progressText(), '', '#103020', '#ffffff', 'bold' ); cb.drawPanel(); } function unlockStage() { var stage = getStage(); lastEvent = stage.win; cb.sendNotice( '⨠QUEST GOAL COMPLETE! āØ\n' + stage.win, '', '#402000', '#ffffff', 'bold' ); startVote(); cb.drawPanel(); } function randomMiniEvent(username) { var events = [ 'found a hidden key', 'triggered a mystery sparkle', 'opened a secret drawer', 'summoned a tiny helper', 'activated double quest energy' ]; var pick = events[Math.floor(Math.random() * events.length)]; lastEvent = username + ' ' + pick + '!'; cb.sendNotice( 'š² Random Quest Event!\n' + username + ' ' + pick + '!', '', '#102040', '#ffffff', 'bold' ); } cb.onStart(function(user) { cb.sendNotice( 'š® CamQuest has started!\n' + 'Type /quest to see the current adventure.\n' + 'Tip to move the quest forward.', '', '#201030', '#ffffff', 'bold' ); announceStatus(); var minutes = parseInt(cb.settings.announce_minutes, 10) || 5; function autoAnnounce() { announceStatus(); cb.setTimeout(autoAnnounce, minutes * 60 * 1000); } cb.setTimeout(autoAnnounce, minutes * 60 * 1000); }); cb.onTip(function(tip) { var amount = parseInt(tip.amount, 10) || 0; var username = tip.is_anon_tip ? 'Anonymous' : tip.from_user; totalTips += amount; stageTips += amount; lastTipper = username + ' +' + amount; if (amount >= 100) { randomMiniEvent(username); } cb.sendNotice( 'š° ' + username + ' added ' + amount + ' tokens to the quest!\n' + 'Progress: ' + stageTips + '/' + getGoal(), '', '#202020', '#ffffff', 'bold' ); if (stageTips >= getGoal() && !voteOpen) { unlockStage(); } cb.drawPanel(); }); cb.onMessage(function(msg) { var text = msg.m.toLowerCase(); if (text === '/quest') { announceStatus(msg.user); msg['X-Spam'] = true; return msg; } if (text === '/resetquest') { if (msg.user === cb.room_slug || msg.is_mod) { totalTips = 0; stageTips = 0; currentStage = 0; lastTipper = 'None yet'; lastEvent = 'Quest was reset.'; voteOpen = false; voteOne = 0; voteTwo = 0; voters = {}; cb.sendNotice( 'š CamQuest has been reset.', '', '#301010', '#ffffff', 'bold' ); cb.drawPanel(); } msg['X-Spam'] = true; return msg; } if (text === '/vote 1' || text === '/vote1') { if (voteOpen && !voters[msg.user]) { voteOne += 1; voters[msg.user] = true; cb.sendNotice(msg.user + ' voted for option 1.', '', '#101020', '#ffffff', 'bold'); } msg['X-Spam'] = true; return msg; } if (text === '/vote 2' || text === '/vote2') { if (voteOpen && !voters[msg.user]) { voteTwo += 1; voters[msg.user] = true; cb.sendNotice(msg.user + ' voted for option 2.', '', '#101020', '#ffffff', 'bold'); } msg['X-Spam'] = true; return msg; } return msg; }); cb.tipOptions(function(user) { return { label: 'CamQuest action:', options: [ { label: 'Explore' }, { label: 'Use item' }, { label: 'Mystery event' }, { label: 'Help the quest' } ] }; }); cb.onDrawPanel(function(user) { var stage = getStage(); return { template: '3_rows_of_labels', row1_label: 'CamQuest', row1_value: cb.settings.theme, row2_label: 'Stage', row2_value: stage.name, row3_label: 'Progress', row3_value: stageTips + '/' + getGoal() + ' tokens' }; }); cb.drawPanel();
© Copyright Chaturbate 2011- 2026. All Rights Reserved.