Apps Home
|
Create an App
jenga test
Author:
lharuhirol
Description
Source Code
Launch App
Current Users
Created by:
Lharuhirol
cb.settings_choices = [ { name: 'tokens', type: 'int', minValue: 1, maxValue: 100, label: 'How much do you want to charge per Jenga block?', defaultValue: 25 }, { name: 'notice_wait_time', type: 'choice', label: 'In minutes, how often should the app advertise itself?', choice1: 5, choice2: 10, choice3: 15, choice4: 20, choice5: 25, choice6: 30, choice7: 45, choice8: 60, defaultValue: 10 } ]; var langTokens = (cb.settings.tokens > 1) ? 'tokens' : 'token'; var lastRoller = '--'; var rollCounter = 0; var tipCounter = 0; cb.onTip(function (tip) { tipCounter += parseInt(tip['amount']); if (parseInt(tip['amount']) >= cb.settings.tokens) { var numberOfRolls = Math.floor(parseInt(tip['amount']) / cb.settings.tokens); for (var i = 0; i < numberOfRolls; i++) { roll(tip['from_user']); lastRoller = tip['from_user']; } } else { cb.drawPanel(); } }); cb.onDrawPanel(function (user) { return { 'template': '3_rows_12_22_31', 'row1_label': '', 'row1_value': '', 'row2_label': 'Last player:', 'row2_value': lastRoller, 'row3_value': tipCounter + ' ' + langTokens + ' received / ' + rollCounter + ' Jenga block(s) pulled' }; }); cb.onEnter(function (user) { showAppAd(user['user']); }); function roll(username) { rollCounter++; var msg = username + " tipped for Lolita Jenga´s!\n"; msg += "A Jenga block will contain a prize!"; var textColor = '#F11DF1'; var bgColor = '#FBC4FB'; cb.sendNotice(msg, '', bgColor, textColor, 'bold'); cb.drawPanel(); } function advertise() { showAppAd(); cb.setTimeout(advertise, parseInt(cb.settings.notice_wait_time) * 60000); } function showAppAd(username) { var msg = ""; if (username != undefined) { msg += "Welcome, " + username + "! We are playing Crazy Jenga! \n"; } else { msg += "Tip remove a block and win a prize \n"; } msg += "Each Jenga block pulled could result in a prize. \n"; msg += "Tip " + cb.settings.tokens + " " + langTokens + " to have a Jenga block pulled."; cb.sendNotice(msg, username, '', '#660033', 'bold'); } function init() { advertise(); cb.changeRoomSubject('Tip ' + cb.settings.tokens + ' to have a Jenga block pulled.'); } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.