Apps Home
|
Create an App
Naughty Elf Present Unwrap
Author:
garterxxx
Description
Source Code
Launch App
Current Users
Created by:
Garterxxx
/** * App: Naughty Elf Present Unwrap * Version: 1.0 β Holiday Gift Edition * Theme: πβ¨ Santaβs Secret Hideaway β Tip Presents to Unwrap the Fun! π₯ */ // ===================== // SETTINGS // ===================== cb.settings_choices = [ { name: 'price', type: 'int', minValue: 1, label: 'Present price (tokens) to unwrap access', defaultValue: 99 }, { name: 'show_name', type: 'str', label: 'Hideaway Name', defaultValue: 'Naughty Elf Hideaway π₯' }, { name: 'free_for_mods', type: 'choice', label: 'Mods unwrap free?', choice1: 'Yes', choice2: 'No', defaultValue: 'Yes' }, { name: 'unwrap_timer_minutes', type: 'choice', label: 'Elf Timer until unwrap (minutes)', choice1:'5', choice2:'10', choice3:'15', choice4:'20', choice5:'25', choice6:'30', choice7:'35', choice8:'40', choice9:'45', choice10:'50', choice11:'55', choice12:'60', defaultValue:'30' }, { name: 'silence_grays', type: 'choice', label: 'Silence grays during unwrap?', choice1:'Yes', choice2:'No', defaultValue:'Yes' } ]; // ===================== // STATE // ===================== let timeLeft = 0; let showStarted = false; let showEnded = false; let showStartTime = null; let showEndTime = null; let presentCounter = 0; // ===================== // HELPERS // ===================== function secondsToHms(d) { d = Number(d); const h = Math.floor(d / 3600); const m = Math.floor(d % 3600 / 60); const s = Math.floor(d % 60); return [h ? `\( {h}h` : '', m ? ` \){m}m` : '', s ? `${s}s` : ''].filter(Boolean).join(' '); } function getTimeLeft() { const mins = Math.floor(timeLeft / 60); const secs = timeLeft % 60; return `\( {mins}m \){secs < 10 ? '0' : ''}${secs}s`; } function getTokensLabel() { return cb.settings.price > 1 ? 'tokens' : 'token'; } // ===================== // TIP HANDLER β "Unwrap Present" // ===================== cb.onTip((tip) => { const user = tip.from_user; const amount = Number(tip.amount); presentCounter += amount; const accessList = cb.limitCam_allUsersWithAccess() || []; if (amount >= cb.settings.price && !accessList.includes(user)) { cb.limitCam_addUsers([user]); cb.sendNotice( `πβ¨ ${user} β Ho ho ho! Your Naughty Present is unwrapped π Access to the elf hideaway granted! π₯`, user, '#FF1493', '#000000', 'bold' ); } cb.drawPanel(); }); // ===================== // PANEL β Festive & Clean // ===================== cb.onDrawPanel(() => { const accessList = cb.limitCam_allUsersWithAccess() || []; const tokensLabel = getTokensLabel(); if (!showStarted && !showEnded) { return { template: '3_rows_of_labels', row1_label: 'π Present Price', row1_value: `\( {cb.settings.price} \){tokensLabel}`, row2_label: 'π§ Naughty Elves', row2_value: `\( {accessList.length} ( \){presentCounter} presents collected)`, row3_label: 'π Unwrap In', row3_value: getTimeLeft() }; } else if (showStarted && !showEnded) { return { template: '3_rows_of_labels', row1_label: 'π Present Price', row1_value: `\( {cb.settings.price} \){tokensLabel}`, row2_label: 'π§ Elves / Presents', row2_value: `\( {accessList.length} / \){presentCounter}`, row3_label: 'Started', row3_value: showStartTime ? showStartTime.toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'}) : 'N/A' }; } else if (showEnded) { const duration = secondsToHms((showEndTime - showStartTime) / 1000); return { template: '3_rows_of_labels', row1_label: 'π° Total Presents', row1_value: presentCounter, row2_label: 'β± Hideaway Time', row2_value: duration, row3_value: 'π Unwrap Over β Merry Next Time!' }; } }); // ===================== // MESSAGE HANDLER // ===================== cb.onMessage((msg) => { const user = msg.user; const text = msg.message.trim().toLowerCase(); const accessList = cb.limitCam_allUsersWithAccess() || []; // Broadcaster commands if (user === cb.room_slug) { if (text === '/unwrap' && !showStarted) startShow(); if (text === '/wrapup') stopShow(); if (text === '/restart') resetShow(); } // Check presents if (text === '/presents' || text === '/naughty') { let notice = 'π Naughty Elf Present List π\n'; if (accessList.length === 0) { notice += 'No presents unwrapped yetβ¦ tip to add yours!'; } else { accessList.forEach((u, i) => notice += `\( {i+1}) \){u}\n`); } cb.sendNotice(notice, user, '#FF1493'); msg['X-Spam'] = true; return msg; } // Chat restrictions if (cb.limitCam_isRunning() && !accessList.includes(user)) { if (msg.is_mod && cb.settings.free_for_mods === 'Yes') { cb.limitCam_addUsers([user]); cb.sendNotice(`${user} β mod present unwrapped free! Enjoy the hideaway π`, ''); } else if (!msg.has_tokens && cb.settings.silence_grays === 'Yes') { msg['X-Spam'] = true; cb.sendNotice('Only tippers can chat while the elves unwrap presents. Tip to join! π', user); } else { msg['X-Spam'] = true; cb.sendNotice('Naughty elves only in the hideaway right now. Unwrap your present to talk π₯', user, '', '#FF1493'); } } return msg; }); // ===================== // SHOW CONTROL // ===================== function startShow() { showStarted = true; showEnded = false; showStartTime = new Date(); timeLeft = 0; cb.limitCam_start(`πβ¨ Naughty Elf Hideaway is unwrapped & live! Only present holders inside π₯`); cb.sendNotice('π Hideaway unwrapped! Only naughty elves & present givers get to play π', '', '#FF1493', '#000000', 'bold'); cb.drawPanel(); } function stopShow() { if (!showStarted) return; showEnded = true; showStarted = false; showEndTime = new Date(); cb.limitCam_stop(); cb.limitCam_removeAllUsers(); cb.sendNotice('πβ¨ Presents all unwrappedβ¦ thanks for the naughty gifts! See you next unwrap π₯'); cb.changeRoomSubject('π Hideaway Wrapped β Next Unwrap Soon'); cb.drawPanel(); } function resetShow() { stopShow(); presentCounter = 0; timeLeft = parseInt(cb.settings.unwrap_timer_minutes) * 60; showEnded = false; showStarted = false; advertise(); cb.setTimeout(updateTimeLeft, 5000); } // ===================== // TIMER & ADVERTISE // ===================== function updateTimeLeft() { if (timeLeft > 0 && !showEnded) { timeLeft -= 5; cb.drawPanel(); if (timeLeft % 300 === 0) advertise(); if (timeLeft === 60) { cb.sendNotice('πβ¨ 60 seconds until the hideaway unwraps! Last chance to give your present π', '', '#FF1493', '#000000', 'bold'); } cb.setTimeout(updateTimeLeft, 5000); } else if (!showStarted && !showEnded) { const accessList = cb.limitCam_allUsersWithAccess() || []; if (accessList.length > 0) { startShow(); } else { resetShow(); } } } function advertise(toUser = null) { const tokens = getTokensLabel(); let msg = `πβ¨ ${cb.settings.show_name}\n` + `Tip \( {cb.settings.price} \){tokens} to give a Naughty Present & unwrap the elf hideaway! π\n` + `Elf timer: ${getTimeLeft()}\n` + `Type /presents to see who's already unwrapped π`; cb.sendNotice(msg, toUser || '', '', '#FF1493', 'bold'); } // ===================== // INIT // ===================== function init() { timeLeft = parseInt(cb.settings.unwrap_timer_minutes) * 60; cb.changeRoomSubject(`πβ¨ \( {cb.settings.show_name} β Tip \){cb.settings.price} tokens to Unwrap the Hideaway! π`); advertise(); cb.setTimeout(updateTimeLeft, 5000); } init();
© Copyright Chaturbate 2011- 2026. All Rights Reserved.