Bots Home
|
Create an App
testingafruitmachine
Author:
tstallulahhh
Description
Source Code
Launch Bot
Current Users
Created by:
Tstallulahhh
/************************************************************* ** 🍇,🍉,🍋,🍊,🍑,🍎,🍏,🍒,🍓,🍍,🍌,🌈 ** ** Title: Fruit Machine ** Author: TSTallulahhh forked from harry241 ** Version: 1.0 ** Description: I wanted a simple match 3 fruits slot machine ** in progress, you gotta paste this row of emoji fruits in the config *************************************************************/ var botVersion = "1.0"; var botTitle = "Funny Slots"; var notifyFgColor = '#009966'; var notifyFgColor2 = '#008855'; var notifyBgColor = '#efefef'; var smaWho, smaWhat, smaWhere; var smtWho = [], smtWhat = [], smtWhere = []; cb.settings_choices = [ { name: 'smTipAmount', label: 'Tip amount required to spin the reels', type: 'int', minValue: 1, maxValue: 999, required: true, defaultValue: 25 }, { name: 'smNotifyEmote', label: 'Notify gif/words', type: 'str', defaultValue: '⚠️' }, { name: 'smWho', label: 'reel1', type: 'str', defaultValue: 'grapes,melon,lemon,orange,strawberry,cherry,rainbow' }, { name: 'smWhat', label: 'reel2', type: 'str', defaultValue: 'grapes,melon,lemon,orange,strawberry,cherry,rainbow' }, { name: 'smWhere', label: 'reel3', type: 'str', defaultValue: 'grapes,melon,lemon,orange,strawberry,cherry,rainbow' }, { name: 'smMessage', label: 'chat message', type: 'str', defaultValue: 'Match 3 for 5 mins of whatever you like! 3 Rainbow Jackpot: 10 mins controlling my hush!' }, ]; 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 spin the reels.\n' + cb.settings.smMessage + ''; 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( cb.settings.smNotifyEmote + ' ' + u + ' spins! ' + sWho + '' + sWhat + '' + sWhere,'',notifyBgColor,notifyFgColor,'bold'); if (sWho == sWhat && sWhat == sWhere){ cb.sendNotice( cb.settings.smNotifyEmote + ' ' + u + ' W I N S !',notifyBgColor,notifyFgColor,'bolder'); } } 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 += 'Tip ' + cb.settings.smTipAmount + ' tokens to spin the reels.\n' + cb.settings.smMessage + ''; 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.