Skip to content

Instantly share code, notes, and snippets.

@BitChop
Forked from dsetzer/Shim.js
Created August 18, 2019 04:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BitChop/b71d9d0899b11da0d287a9e20180b8d6 to your computer and use it in GitHub Desktop.
Save BitChop/b71d9d0899b11da0d287a9e20180b8d6 to your computer and use it in GitHub Desktop.
Runs v1 bustabit scripts on bustabit v2
///////////////////////// PLACE V1 SCRIPT AT THE END OF THIS BLOCK /////////////////////////
var config = {};
var initialized = false;
function patchFunctions(debugging = false) {
if (!initialized) {
engine.placeBet = function (bet, multiplier, callback) {
engine.bet(bet, parseFloat(multiplier / 100));
}
engine.getMaxBet = function () {
return userInfo.balance;
}
engine.getCurrentPayout = function () {
return (engine.gameState != 'IN_PROGRESS' ? null : (engine.bust * 100));
}
engine.getBalance = function () {
return userInfo.balance;
}
engine.getUsername = function () {
return userInfo.uname;
}
engine.getEngine = function () {
return engine;
}
engine.lastGamePlayed = function () {
return (engine.lastGamePlay() != 'NOT_PLAYED' ? true : false);
}
engine.lastGamePlay = function () {
let lastGame = engine.history.first();
if (lastGame.wager) {
if (lastGame.cashedAt) {
return 'WON';
}
return 'LOST';
}
return 'NOT_PLAYED';
}
engine.stop = function (reason) {
stop(reason);
}
engine.on('GAME_STARTING', function () {
if (this._events['game_starting']) {
if (debugging) { console.log(`[debug] Remit 'GAME_STARTING'->'game_starting' {game_id: ${engine.gameId}, time_till_start: 5000}`); }
engine.emit('game_starting', { game_id: engine.gameId, time_till_start: 5000 });
}
});
engine.on('GAME_STARTED', function () {
if (this._events['game_started']) {
if (debugging) { console.log(`[debug] Remit 'GAME_STARTED'->'game_started' {${engine.playing}}`); }
engine.emit('game_started', engine.playing);
}
});
engine.on('GAME_ENDED', function () {
if (this._events['game_crash']) {
let lastGame = engine.history.first();
let elapsed = parseInt(lastGame.lastGameTick - lastGame.startTime);
if (debugging) { console.log(`[debug] Remit 'GAME_ENDED'->'game_crash' {elapsed: ${elapsed}, game_crash: ${lastGame.bust}, bonuses: 0, hash: ${lastGame.hash}}`); }
engine.emit('game_crash', { elapsed: elapsed, game_crash: (lastGame.bust * 100), bonuses: 0, hash: lastGame.hash });
}
});
engine.on('CASHED_OUT', function (bet) {
if (this._events['cashed_out']) {
if (debugging) { console.log(`[debug] Remit 'CASHED_OUT'->'cashed_out' {username: ${bet.uname}, amount: ${bet.wager}, stopped_at: ${bet.cashedAt}}`); }
engine.emit('cashed_out', { username: bet.uname, amount: bet.wager, stopped_at: (bet.cashedAt * 100) });
}
});
engine.on('BET_PLACED', function (bet) {
if (this._events['player_bet']) {
if (debugging) { console.log(`[debug] Remit 'BET_PLACED'->'player_bet' {username: ${bet.uname}, bet: ${bet.wager}`); }
engine.emit('player_bet', { username: bet.uname, bet: bet.wager });
}
});
initialized = true;
}
}
patchFunctions();
///////////////////////// PLACE BUSTABIT V1 SCRIPT BELOW THIS LINE /////////////////////////
@owersite
Copy link

owersite commented Oct 3, 2020

Actually, this is not really valid, you should use:

var config = {};

here paste the script

(e=>{e.placeBet=((a,t,s)=>{e.bet(a,parseFloat(t/100))}),
e.getMaxBet=(()=>userInfo.balance), e.getBalance=(()=>userInfo.balance),
e.getCurrentPayout=(()=>"IN_PROGRESS"!=e.gameState?null:100e.bust),
e.lastGamePlayed=(()=>"NOT_PLAYED"!==e.lastGamePlay()),e.lastGamePlay=(()=>{
let a=e.history.first();return a.wager?a.cashedAt?"WON":"LOST":"NOT_PLAYED"
}),e.getEngine=e.getState,e.stop=stop,e.on("GAME_STARTING",()=>{
e._events.game_starting&&e.emit("game_starting",{game_id:e.gameId,time_till_start:5e3
})}),e.getUsername=(()=>userInfo.uname),e.on("GAME_STARTED",()=>{
e._events.game_started&&e.emit("game_started",e.playing)}),e.on("GAME_ENDED",()=>{
if(e._events.game_crash){let t=e.history.first(),s=parseInt(t.lastGameTick-t.startTime);
e.emit("game_crash",{elapsed:s,game_crash:100
t.bust,bonuses:0,hash:t.hash})}
}),e.on("CASHED_OUT",t=>{e._events.cashed_out&&e.emit("cashed_out",{username:t.uname,
amount:t.wager,stopped_at:100*t.cashedAt})}),e.on("BET_PLACED",a=>{
e._events.player_bet&&e.emit("player_bet",{username:a.uname,bet:a.wager})})})(engine);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment