Apps Home
|
Create an App
Ride
Author:
ride01
Description
Source Code
Launch App
Current Users
Created by:
Ride01
// variables // var roomTitle = ''; var startApp = new Date(); var startCost = 0; var stopCost = 0; var fasterCost = 0; var slowerCost = 0; var startSpeed = 0; var currentSpeed = 0; var highestSpeed = 1; var intenseSpeed = 1; var newSpeed = 0; var oldSpeed = 0; var masterTips = 0; var masterTipper = '--'; var totalTips = 0; var totalTippers = new Array(); var ttLength = 0; var tipJar = 0; var intervalDecay = 2; var ratioDecay = 0; var intenseDecay = 2; var timerDecay = 0; // settings // cb.settings_choices = [ { name: 'room_title', label: 'room title (prices added): ', type: 'str', defaultValue: 'riding my #fuckmachine!', minLength: 0, maxLength: 75 }, { name: 'start_cost', label: 'start cost: ', type: 'int', defaultValue: 10, minValue: 0, maxValue: 1000 }, { name: 'stop_cost', label: 'stop cost: ', type: 'int', defaultValue: 10, minValue: 0, maxValue: 1000 }, { name: 'faster_cost', label: 'speed up cost (0 to disable): ', type: 'int', defaultValue: 25, minValue: 0, maxValue: 1000 }, { name: 'slower_cost', label: 'speed down cost (0 to disable): ', type: 'int', defaultValue: 20, minValue: 0, maxValue: 1000 }, { name: 'highest_speed', label: 'highest speed (>1): ', type: 'int', defaultValue: 10, minValue: 1, maxValue: 20 }, { name: 'start_speed', label: 'start at speed (0 for OFF): ', type: 'int', defaultValue: 1, minValue: 0, maxValue: 20 }, { name: 'intense_speed', label: 'intense speed (>1): ', type: 'int', defaultValue: 6, minValue: 1, maxValue: 20 }, { name: 'ratio_decay', label: 'ratio_decay ratio (0 to disable): ', type: 'int', defaultValue: 500, minValue: 0, maxValue: 1000 }, { name: 'intense_decay', label: 'intense decay (>=1): ', type: 'int', defaultValue: 2, minValue: 1, maxValue: 1000 } ]; // listeners // cb.onMessage(function(msg) { var txt = msg['m']; var user = msg['user']; if (/\/speed \d/i.test(txt) && (msg['is_mod'] || cb.room_slug)) { var data = txt.trim(); data = data.split(' '); var commandIndex = 0; for (var i = 0; i < data.length; i++) { if (/!speed/i.test(data[i])) { commandIndex = i; } } setSpeed(data[commandIndex + 1]); var message = 'The ride has been manually set to speed ' + currentSpeed + '/' + highestSpeed; if (currentSpeed > 1) { message += ' (' + getDecay() + ' seconds)'; } cb.chatNotice(message, '', '', '#DC5500', 'bold'); } else if (/\/reset/i.test(txt) && (msg['is_mod'] || cb.room_slug)) { initRide(); } else if (/\/decay \d/i.test(txt) && (msg['is_mod'] || cb.room_slug)) { var data = txt.trim(); data = data.split(' '); var commandIndex = 0; for (var i = 0; i < data.length; i++) { if (/\/decay/i.test(data[i])) { commandIndex = i; } } setDecay(data[commandIndex + 1]); var message = 'The decay ratio has been set to ' + ratioDecay; cb.chatNotice(message, '', '', '#DC5500', 'bold'); } else if (/\/intense \d/i.test(txt) && (msg['is_mod'] || cb.room_slug)) { var data = txt.trim(); data = data.split(' '); var commandIndex = 0; for (var i = 0; i < data.length; i++) { if (/\/intense/i.test(data[i])) { commandIndex = i; } } intenseSpeed = data[commandIndex + 1]; var message = 'The intense speeds have been set to ' + intenseSpeed + ' - ' + highestSpeed; cb.chatNotice(message, '', '', '#DC5500', 'bold'); } else if (/\/help/i.test(txt) && (msg['is_mod'] || cb.room_slug)) { printHelp(); } else if (/\/stats/i.test(txt) && (msg['is_mod'] || cb.room_slug)) { printStats(); } else if (/\/tokens/i.test(txt) && (msg['is_mod'] || cb.room_slug)) { printTokens(); } return msg; }); cb.onTip(function(tip) { var amount = tip['amount']; var user = tip['from_user']; var exists = 0; var index = 0; for (i=0; i<totalTippers.length; i++) { if (totalTippers[i].user == user) { exists = 1; index = i; } } if (exists == 1) { totalTippers[index].amount += amount; } else { var tipper = new Object(); tipper.user = user; tipper.amount = amount; totalTippers[ttLength] = tipper; ttLength++; } for (i=0; i<totalTippers.length; i++) { if (totalTippers[i].amount > masterTips) { masterTips = totalTippers[i].amount; masterTipper = totalTippers[i].user; } } totalTips += amount; if (amount == fasterCost && currentSpeed < highestSpeed) { setSpeed(currentSpeed + 1); var message = 'The ride is speeding up to ' + currentSpeed + '/' + highestSpeed; if (currentSpeed > 1) { message += ' (' + getDecay() + ' seconds)'; } message += ' :hearts_bubbling_small'; cb.chatNotice(message, '', '', '#DC5500', 'bold'); } else if (amount == slowerCost && currentSpeed > 0) { setSpeed(currentSpeed - 1); var message = 'The ride is slowing down to ' + currentSpeed + '/' + highestSpeed; if (currentSpeed > 1) { message += ' (' + getDecay() + ' seconds)'; } message += ' :hearts_bubbling_small'; cb.chatNotice(message, '', '', '#DC5500', 'bold'); } else if (amount == startCost || amount == stopCost) { if (amount == startCost && startCost == stopCost) { if (currentSpeed > 0) { setSpeed(0); cb.chatNotice('The ride has stopped!', '', '', '#DC5500', 'bold'); } else { if (oldSpeed > 1) { setSpeed(oldSpeed); cb.chatNotice('The ride has been resumed! :hearts_bubbling_small', '', '', '#DC5500', 'bold'); } else { setSpeed(1); cb.chatNotice('The ride has started!', '', '', '#DC5500', 'bold'); } } } else { if (amount == startCost && currentSpeed == 0) { if (oldSpeed > 1) { setSpeed(oldSpeed); cb.chatNotice('The ride has been resumed! :hearts_bubbling_small', '', '', '#DC5500', 'bold'); } else { setSpeed(1); cb.chatNotice('The ride has started!', '', '', '#DC5500', 'bold'); } } else if (amount == stopCost && currentSpeed > 0) { setSpeed(0); cb.chatNotice('The ride has stopped!', '', '', '#DC5500', 'bold'); } else { } } } else { var div = Math.floor(amount / fasterCost); var rem = Math.floor(amount % fasterCost); if (div > 1) { setSpeed(currentSpeed + div); var message = 'The ride is speeding up to ' + currentSpeed + '/' + highestSpeed + ' (' + getDecay() + ' seconds) :hearts_bubbling_small'; cb.chatNotice(message, '', '', '#DC5500', 'bold'); } else { tipJar += amount; if (tipJar >= fasterCost) { var message = 'The tip jar contains enough tokens (' + tipJar + ') to speed up the ride!' cb.chatNotice(message, '', '', '#DC5500', 'bold'); tipJar -= fasterCost; setSpeed(currentSpeed + 1); var message = 'The ride is speeding up to ' + currentSpeed + '/' + highestSpeed + ' (' + getDecay() + ' seconds) :hearts_bubbling_small'; cb.chatNotice(message, '', '', '#DC5500', 'bold'); } else { var message = 'The tip jar contains ' + tipJar + ' tokens! Keep it up to speed up the ride (' + fasterCost + ' tokens)!' cb.chatNotice(message, '', '', '#DC5500', 'bold'); } } } cb.drawPanel(); }); cb.onDrawPanel(function(user) { var statusBar = ''; if (currentSpeed > 0) { for (i = 0; i < currentSpeed; i++) { statusBar += '!'; } for (i = statusBar.length; i < highestSpeed; i++) { statusBar += '.'; } statusBar += ' ' + currentSpeed + '/' + highestSpeed; if (currentSpeed > 1) { statusBar += ' (' + getDecay() + ' seconds)'; } } else { statusBar = 'OFF'; } return { 'template': '3_rows_11_21_31', 'row1_value': 'Status: ' + statusBar, 'row2_value': 'Master: ' + masterTipper + ' (' + masterTips + ' tokens)', 'row3_value': 'Tokens: ' + totalTips + ' / Tip Jar: ' + tipJar }; }); // functions // function getDecay () { if (currentSpeed > 0) { if (currentSpeed >= intenseSpeed) { return Math.floor((ratioDecay / intenseDecay) / currentSpeed); } else { return Math.floor(ratioDecay / currentSpeed); } } else { return 0; } } function setDecay (ratio) { if (ratio > 0) { ratioDecay = ratio; timerDecay = getDecay(); cb.drawPanel(); } } function setSpeed (speed) { if (speed > highestSpeed) { newSpeed = highestSpeed; } else if (speed < 0) { newSpeed = 0; } else { newSpeed = speed; } oldSpeed = currentSpeed; currentSpeed = newSpeed; timerDecay = getDecay(); cb.drawPanel(); } function checkDecay() { if (timerDecay <= 0) { if (currentSpeed > 1) { setSpeed(currentSpeed - 1); var message = 'The ride is automatically slowing down to ' + currentSpeed + '/' + highestSpeed; if (currentSpeed > 1) { message += ' (' + timerDecay + ' seconds)'; } cb.chatNotice(message, '', '', '#DC5500', 'bold'); } } else { timerDecay -= intervalDecay; // if (timerDecay <= 15) { // var message = 'The ride will slow down in 15 seconds. Tip to keep it going!'; // cb.chatNotice(message, '', '', '#DC5500', 'bold'); // } } cb.setTimeout(checkDecay, 1000 * intervalDecay); } function printHelp(to) { var help = '*** Elegen\'s Ride - Help ***\n\n'; help += 'Controls:'; if (startCost == stopCost) { help += ' ' + startCost + ' start/stop'; } else { help += ' ' + startCost + ' start, ' + stopCost + ' stop'; } if (fasterCost != 0) { help += ', ' + fasterCost + ' faster'; } if (slowerCost != 0) { help += ', ' + slowerCost + ' slower'; } help += '\n\n'; help += 'Type /help to show this message\n'; help += 'Type /stats to show statistics of the current session\n'; help += 'Type /tokens see the amount each tipper has tipped\n'; help += '\n'; help += 'The ride will slow down automatically based on the current speed. Tip to keep it going! All tips count!'; cb.chatNotice(help, to, '', '#DC5500', 'bold'); } function printStats(to) { var running = ((new Date()).getTime() - startApp.getTime()) / 1000; var minutes = Math.round(running/60); var hours = Math.floor(minutes/60); minutes = minutes%60; var runningStr = hours + ' hrs. ' + minutes + ' mins.'; var stats = "*** Elegen\'s Ride - Stats ***\n"; stats += "started: " + startApp + "\n"; stats += "runtime: " + runningStr + "\n"; stats += "tokens received: " + totalTips + "\n"; stats += "current speed: " + currentSpeed + "\n"; stats += "highest speed: " + highestSpeed + "\n"; stats += "intense speeds: " + intenseSpeed + " - " + highestSpeed + "\n"; stats += "decay: " + ratioDecay + "/speed seconds"; cb.chatNotice(stats, to, '', '#DC5500', 'bold'); } function printTokens(to) { cb.chatNotice("*** Elegen\'s Ride - Tips ***", to, '', '#DC5500', 'bold'); for (i=0; i<totalTippers.length; i++) { cb.chatNotice(totalTippers[i].user + " (" + totalTippers[i].amount + ")", to, '', '#DC5500', 'bold'); } cb.chatNotice("Total Tips: " + totalTips, to, '', '#DC5500', 'bold'); } function initRide(to) { startCost = cb.settings.start_cost; stopCost = cb.settings.stop_cost; fasterCost = cb.settings.faster_cost; slowerCost = cb.settings.slower_cost; ratioDecay = cb.settings.ratio_decay; intenseDecay = cb.settings.intense_decay; highestSpeed = cb.settings.highest_speed; intenseSpeed = cb.settings.intense_speed; startSpeed = cb.settings.start_speed; if (startSpeed > highestSpeed) { startSpeed = highestSpeed; } currentSpeed = startSpeed; cb.chatNotice("Elegen\'s Ride has been (re-)initialized. Enjoy the journey!", to, '', '#DC5500', 'bold'); } // init // function init() { if (cb.settings.room_title) { initRide(); roomTitle = cb.settings.room_title; roomTitle += ' [controls: '; if (startCost != 0 && stopCost != 0) { if (startCost == stopCost) { roomTitle += ' ' + startCost + ' start/stop'; } else { roomTitle += ' ' + startCost + ' start, ' + stopCost + ' stop'; } } if (fasterCost != 0) { roomTitle += ', ' + fasterCost + ' faster'; } if (slowerCost != 0) { roomTitle += ', ' + slowerCost + ' slower'; } roomTitle += ']'; cb.changeRoomSubject(roomTitle); cb.setTimeout(checkDecay, 1000 * intervalDecay); printHelp(); } } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.