Apps Home
|
Create an App
jenga3
Author:
lharuhirol
Description
Source Code
Launch App
Current Users
Created by:
Lharuhirol
/************************************************************* ** ** Title: Loli Jenga ** Author: zhim_zhum_dum_dee_dum ** Version: 1.0 ** Description: Random prizes for when playing Jenga. ** *************************************************************/ var botVersion = "1.0"; var botTitle = "Loli Jenga"; var notifyFgColor = '#009966'; var notifyFgColor2 = '#008855'; var notifyBgColor = '#D5EBF8'; var smNotifyEmote = ':lolijenga '; var smaWho, smaWhat, smaWhere; var smtWho = [], smtWhat = [], smtWhere = []; cb.settings_choices = [ { name: 'smTipAmount', label: 'Tip amount required to pull a block', type: 'int', minValue: 1, maxValue: 999, required: true, defaultValue: 25 }, { name: 'smWho', label: 'Who will pull the block (seperated by comma)', type: 'str', defaultValue: 'Loli' }, { name: 'smWhat', label: 'Instant prize (seperated by comma)', type: 'str', defaultValue: 'InstPrize1,InstPrize2,InstPrize3,InstPrize4,InstPrize5,InstPrize6,InstPrize7,InstPrize8,InstPrize9,InstPrize10,InstPrize11,InstPrize12' }, { name: 'smWhere', label: 'Main prize if the tower falls with this block pull (seperated by comma)', type: 'str', defaultValue: 'BigPrize1,BigPrize2,BigPrize3,BigPrize4,BigPrize5,BigPrize6,BigPrize7,BigPrize8,BigPrize9,BigPrize10,BigPrize11' }, ]; cb.onMessage(function(message) { var name = message['user']; var msg = message['m']; var isModel = (name == cb.room_slug); var isMod = message['is_mod']; if ((isModel) || (isMod)) { if (msg == 'spin') { spinReels(name); } else if (msg == 'info') { botInfo(); } else if (msg == 'stats') { botStats(); } } }); cb.onTip(function (tip) { var tipAmount = parseInt(tip['amount']); var name = tip['from_user']; if (tipAmount == cb.settings.smTipAmount) { spinReels(name); } }); cb.onEnter(function(user) { if (user['has_tokens']) { var s = ''; var s = 'Hi ' + user['user'] + ', we are playing ' + botTitle + '. '; s += 'Tip ' + cb.settings.smTipAmount + ' tokens to pull a block. Have some fun and win some great prizes!'; cb.sendNotice(s,user['user'],notifyBgColor,notifyFgColor,'bold'); } }); function spinReels(u) { var rnd,sWho,sWhat,sWhere; // randomize somehow? function rr(len) { var cnt,rnd; cnt = Math.floor(Math.random() * 5) + 1; while (cnt>0) { rnd = Math.floor(Math.random() * len); cnt--; } return rnd; } rnd = Math.floor(Math.random() * smaWho.length); //rnd = rr(smaWho.length); sWho = smaWho[rnd]; smtWho[rnd]++; cb.log(rnd); rnd = Math.floor(Math.random() * smaWhat.length); //rnd = rr(smaWhat.length); sWhat = smaWhat[rnd]; smtWhat[rnd]++; cb.log(rnd); rnd = Math.floor(Math.random() * smaWhere.length); //rnd = rr(smaWhere.length); sWhere = smaWhere[rnd]; smtWhere[rnd]++; cb.log(rnd); cb.sendNotice(smNotifyEmote + u + ' pulls a block..\n' + 'Instant prize: ' + sWhat + ' \n' + 'If it falls this pull: ' + sWhere,'',notifyBgColor,notifyFgColor,'bold'); } function reelToArray(val) { var a = []; if (val) { val = val.split(','); for (var i = 0; i < val.length; i++) { if (val[i] !== undefined && val[i] !== null && val[i] !== "") { a.push(val[i]); } } } cb.log(a); return a; } function repeatChar(count,ch) { var txt = ""; for (var i = 0; i < count; i++) { txt += ch; } return txt; } function botInfo() { var s = ''; s += botTitle + ' v' + botVersion + '\n'; s += repeatChar(30,'*') + '\n'; s += 'Tip ' + cb.settings.smTipAmount + ' tokens to pull a block. Have some fun and win some great prizes!\n'; s += repeatChar(30,'*'); cb.sendNotice(s,'',notifyBgColor,notifyFgColor,'bold'); s = 'Jenga with ' + smaWho + '\n'; s += 'Instant prize: ' + smaWhat + '\n'; s += 'If it falls: ' + smaWhere; cb.sendNotice(s,'',notifyBgColor,notifyFgColor2); s = repeatChar(30,'*') + '\n'; s += 'Type "info" to display the above information (bot promotion)\n'; s += 'Type "spin" to spin the reels for free (model & mods only)'; cb.sendNotice(s,cb.room_slug,notifyBgColor,notifyFgColor2,'bold'); cb.sendNotice(s,'',notifyBgColor,notifyFgColor2,'bold','red'); } function botStats() { cb.log(smtWho); cb.log(smtWhat); cb.log(smtWhere); } function loadSettings() { smaWho = reelToArray(cb.settings.smWho); smaWhat = reelToArray(cb.settings.smWhat); smaWhere = reelToArray(cb.settings.smWhere); var i; for (i=0;i<smaWho.length;i++) { smtWho[i] = 0; } for (i=0;i<smaWhat.length;i++) { smtWhat[i] = 0; } for (i=0;i<smaWhere.length;i++) { smtWhere[i] = 0; } botInfo(); } loadSettings();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.