Bots Home
|
Create an App
Token Tower
Author:
hell_lena
Description
Source Code
Launch Bot
Current Users
Created by:
Hell_Lena
cb.settings_choices=[{name:"game",type:"choice",choice1:"Token Tower",defaultValue:"Token Tower",label:"Choose your Game to play"},{name:"textcolor",type:"str",defaultValue:"#FF0000",label:"Fontcolor of messages"},{name:"background",type:"str",defaultValue:"#FFFFFF",label:"Backgroundcolor of messages"},{name:"min_value",type:"int",minValue:1,defaultValue:1,label:"Bottom of the Tower"},{name:"max_value",type:"int",minValue:1,defaultValue:20,label:"Top of the Tower"},{name:"welcome",type:"str",minLength:1,maxLength:255,defaultValue:"Let's play Token Tower with me. Shoot the bricks with your tips. After each number is tiped the goal is reached.",label:"Welcome Message for new Users"},{name:"notice",type:"str",minLength:1,maxLength:255,defaultValue:"Token Tower is running. Shoot the bricks with your tips. After each number is tiped the goal is reached.",label:"Regular Notice for the chat"},{name:"notice_interval",type:"int",minValue:0,maxValue:60,defaultValue:3,label:"Notice interval (0 = disabled)"},{name:"success",type:"str",minLength:1,maxLength:255,defaultValue:"Got it! Brick have been removed!",label:"Message if a Bricks falls"},{name:"failure",type:"str",minLength:1,maxLength:255,defaultValue:"Shot on the hole! No brick was removed!",label:"Message if Bricks already taken"},{name:"win",type:"str",minLength:1,maxLength:255,defaultValue:"Tower Down!",label:"Message if Tower is down"},{name:"price",type:"str",minLength:1,maxLength:255,label:"Price Description"},{name:"playerlist",type:"choice",choice1:"yes",choice2:"no",defaultValue:"yes",label:"Show leaderboard"},{name:"player_max",type:"int",minValue:1,defaultValue:5,label:"Maximum players on the leaderboard"}];var devinfo={author:"hell_lena",modder:"currently none",branch:"Original",version:"0.9",date:"18/03/19",description:"With tokentower you set up a range of numbers.\nAfter each number is tiped the goal is reached."},tkt={free_bricks:[],gamer:[],gamer_string:"",notice_id:0,towervalue:function(){return x=cb.settings.max_value,y=cb.settings.min_value,(x+1-y)*((x+y)/2)},removebrick:function(e){return idx=tkt.checkbrick(e),-1!=idx&&(tkt.free_bricks=tkt.free_bricks.filter(function(t){return t!=e}),!0)},addbrick:function(e){return idx=tkt.checkbrick(e),-1==idx&&(tkt.free_bricks.push(e),tkt.free_bricks.sort(),!0)},checkbrick:function(e){return tkt.free_bricks.findIndex(function(t){return t==e})},bricksremaining:function(){return arrayToFormatString(tkt.free_bricks)},gamerlist:function(){tkt.gamer_string="";var e=tkt.gamer.sort(sortArrByVal),t=e.length<cb.settings.player_max?e.length:cb.settings.player_max;for(i=0;i<t;i++)tkt.gamer_string+="Atacker '"+e[i][0]+"' hitted "+e[i][1]+" times",i!=e.length-1&&(tkt.gamer_string+="\n");return tkt.gamer_string},onTip:function(e){suc=tkt.removebrick(e.amount),suc?(idx=tkt.gamer.findIndex(function(t){return t[0]==e.from_user}),-1==idx?tkt.gamer.push([e.from_user,1]):tkt.gamer[idx]=[e.from_user,tkt.gamer[idx][1]+=1],sendMessage2All(cb.settings.success)):sendMessage2All(cb.settings.failure),remains=tkt.bricksremaining(),""!=remains?sendMessage2All("Remaining Bricks are: "+tkt.bricksremaining()+tkt.addInformation()):sendMessage2All(cb.settings.win+"\nYou won: "+cb.settings.price)},onMessage:function(e){if(e.is_mod||e.user==cb.room_slug){var t=e.m.split(" ");switch(cb.sendNotice("Command: "+t[0],"Parameter: "+t[1]),t[0]){case"/tokentower":sendMessage2Mod("You can use following commands:\n/tkt_notice #1 - will imidiatly send the notice and set the timer to #1 (number of seconds).\n/tkt_bricks - will send the remaining bricks to all users once.");break;case"/tkt_notice":2==t.length?(cb.cancelTimeout(tkt.notice_id),cb.settings.notice_interval=t[1],tkt.notice_id=tkt.notice()):sendMessage2Mod("Not enough parameters for following command: /tkt_notice - timer in seconds needed");break;case"/tkt_bricks":sendMessage2All("Remaining bricks are: "+tkt.bricksremaining());break;case"/tkt_testtip":if(sendMessage2Mod("DEBUG: tkt_testtip "+t[1]+" "+t[2]),3==t.length&&"hell_lena"==cb.room_slug){var n=[];n.amount=t[1],n.from_user=t[2],tkt.onTip(n)}}}},notice:function(){if(""!=tkt.bricksremaining()&&(sendMessage2All(cb.settings.notice+"\nYou can win: "+cb.settings.price+tkt.addInformation()+"\nRemaining bricks are: "+tkt.bricksremaining()),0!=cb.settings.notice_interval)){var e=1e3*cb.settings.notice_interval*60;tkt.notice_id=cb.setTimeout(tkt.notice,e)}},onEnter:function(e){""!=tkt.bricksremaining()&&sendMessage2User(cb.settings.welcome+tkt.addInformation()+"\nRemaining bricks are: "+tkt.bricksremaining(),e)},addInformation:function(){return"yes"==cb.settings.playerlist&&(tkt.gamerlist(),""!=tkt.gamer_string)?"\n"+tkt.gamer_string:""},init:function(){for(i=cb.settings.min_value;i<=cb.settings.max_value;i++)tkt.free_bricks.push(i);tkt.notice(),sendMessage2Mod("Message for Owner and Mod\nYour Towervalue: "+tkt.towervalue()+"\nApp created by: "+devinfo.author+" and modified by: "+devinfo.modder+"\nYou are using Branch: "+devinfo.branch+", Version "+devinfo.version+", Date "+devinfo.date+"\nUse /tokentower for help.")}},game=new Object;function arrayToFormatString(e){for(res="",i=0;i<e.length;i++)0==i?res+=e[i]:i==e.length-1?(e[i-1]==e[i]-1?res+="-":res+=",",res+=e[i]):(prev=e[i-1],curr=e[i],next=e[i+1],curr==prev+1&&curr==next-1||(curr==prev+1&&curr!=next-1?res+="-"+e[i]:curr!=prev+1&&(res+=","+e[i])));return res}function sortArrByVal(e,t){return(e=e[1])<(t=t[1])?1:e>t?-1:0}function sendMessage2All(e){cb.sendNotice(e,"",cb.settings.background,cb.settings.textcolor,"bold")}function sendMessage2User(e,t){cb.sendNotice(e,t,cb.settings.background,cb.settings.textcolor,"bold")}function sendMessage2Mod(e){cb.sendNotice(e,cb.room_slug,cb.settings.background,cb.settings.textcolor,"bold"),cb.sendNotice(e,"",cb.settings.background,cb.settings.textcolor,"bold","red")}function init(){switch(cb.settings.game){case"Token Tower":game=tkt;break;default:game=tkt}game.init()}cb.onTip(function(e){game.onTip(e)}),cb.onMessage(function(e){game.onMessage(e)}),cb.onEnter(function(e){game.onEnter(e)}),init();
© Copyright Chaturbate 2011- 2025. All Rights Reserved.