Skip to main content

Ankhbot - Creating A Simple Dice Game

This is an older article but is kept here for posterity's sake. Ankhbot is now Streamlabs Chatbot and does not function in the same matter. This code will not work.
+ + + 

Followers come to your channel to interact with you and your community, but it doesn’t hurt to have something else for them to do while there. Many broadcasters have adapted the Ankhbot (or other) heist program for their channels in varying ways to fit their channel’s theme (mine being an !ambush), but as we all know a little variety goes a long way.

So, following the lead of Moobot, a popular Twitch channel bot, I created a dice game that allows my followers to quickly gain (and lose) supplies. Where an !ambush allows them to gain/lose a larger sum of Supplies (my currency), the !dice command allows them to gain/lose smaller amounts. It is a faster, easier way for followers to win smaller amounts and get their fix because they don’t have to wait on other followers to join or the system to countdown to start.

That said, let’s take a look at how I made my dice game in Ankhbot.


On the surface it may seem that there’s a lot going on with calculations of dice and currency, but in reality there are only a couple of things being done when the !dice command is entered. 1) Ankhbot randomly chooses one line from 36 lines of code saved in a .txt document which match up to a dice combination 2) Ankhbot calculates how many supplies to give or take away.


First, in the !dice command you must have Ankhbot read the .txt file in which you have the code (coming up). So, in my command I have:

$user, you roll the dice and… $readrandline(C:\users\…\dice.txt)

The first part refers to the $user who uses the command followed by some filler text telling the user what he or she is doing and then linking the dice.txt with the $readrandline() parameter. It’s that simple!

Next, we have to work on the code inside of the .txt file.

My game is a two dice game so there are a total of 36 numerical combinations for the dice which are the following:

(1,1) (1,2) (1,3) (1,4) (1,5) (1,6)
(2,1) (2,2) (2,3) (2,4) (2,5) (2,6)
(3,1) (3,2) (3,3) (3,4) (3,5) (3,6)
(4,1) (4,2) (4,3) (4,4) (4,5) (4,6)
(5,1) (5,2) (5,3) (5,4) (5,5) (5,6)
(6,1) (6,2) (6,3) (6,4) (6,5) (6,6)

To have these choices available to the user all we have to do is create a .txt document giving you a result for each of the combinations above. As I stated, in my game evens and doubles win, and odds lose. Therefore, for evens and doubles we are going to use the parameter $addpoints(“target”,”min”,”max”,”succeed”,”fail”) and for odds we are going to apply the $removepoints(“target”,”min”,”max”,”succeed”,”fail”,”forceremove”) parameter.

So, my .txt document (which I labeled dice.txt) has 36 entries in a row that look like:

$addpoints(“$user”,”100",”100",”You rolled snake eyes (1,1)! 100 Supplies have been added to your inventory!”,”You gained nothing”)

$removepoints(“$user”,”25",”100",”You rolled odds (1,2)! $value Supplies have been removed from your inventory!”,”You don’t have enough to roll!”,”false”)

$addpoints(“$user”,”25",”100",”You rolled evens (1,3)! $value Supplies have been added to your inventory!”,”You gained nothing”)

The $addpoints() parameter I use for the rolls that land on evens and doubles. It has the following information in it:

"$user" — leave as is to define who the activating user is.

"min”,”max” — I put this at “25”,”100″ so they win anywhere from 25–100 supplies randomly on roll. On doubles I multiply a single die by 100 so a pair of threes would be “300”,”300″ for example earning a player 300 supplies.

“succeed” — “You rolled snake eyes! blah blah” This just tells the user what they rolled, that they won and how many supplies they won.

“fail” — This is not needed as our fail state is in the $removepoints() paramater (coming up next), but must have some text in it to function.

The $removepoints() parameter I use for the rolls that land on odds. It has the following in it:

“$user” — leave as is to define who the activating user is.

“min”,”max” — Again, this is at “25”,”100″ but because of the parameter the player loses anywhere from 25–100 supplies instead of gains.

“succeed” — This is actually fail text… “You rolled odds (1,2)! $value Supplies have been removed from your inventory!” What they rolled and how much they lost.

“fail” — This is needed if they do not have enough currency so a simple message like, “You do not have enough to roll!” works.

“forceremove” — “False” so if they can’t lose any more than 0 currency.

That’s it for the game. Roll away and relish in your gains (and losses)! You may want to consider putting it on a cooldown per user if they get a little too spammy with the command, but it should be all aces from here!


Sadly, there are limitations to Ankhbot, as in any program. Also, I am no expert at Ankhbot. I learned everything from YouTube videos and posts on Reddit and other forums, but what I do know I try to share. If you have any questions about this article, my previous article, “Ankhbot — Creating an (almost) completely autonomous user-created custom welcome message program” or any ideas you have for things you would like to do with Ankhbot just let me know here in the comments or on social media!

Popular posts from this blog

Eternally Doomed

Four years after the phenomenal Doom 2016 was laid upon us unexpecting gamers, id Software releases their highly anticipated follow up - Doom Eternal - which manages to not only take and build upon what was created in the earlier games of the series, but to add in new mechanics as well; however, is it all a worthwhile experience? ☠ ☠ ☠Doom Eternal picks up sometime after the events of the first game with the "Doom Slayer" hovering above Earth like some omnipresent God lording over his flock in the Fortress of Doom - a towering citadel planted on a jagged piece of rock that acts as his personal headquarters he will visit after almost every mission. Last seen being teleported away to somewhere by Samuel Hayden at the end of Doom 2016, the Slayer's presumably just arrived somehow after a long journey to find Earth overwhelmed by demons. The resistance - whom you never see and who manage to put out radio broadcasts like John Conner in some demon-infested reimagining of Term…

D&D Variants: Dash

There are a slew of actions that players can take whilst in combat that can help them do a multitude of things from aiding in battle to avoiding it altogether. However, I feel that although some of these rules as written (RAW) get the job done, they often feel subpar, uninspired or even a little overpowered so I thought it would be interesting and fun to take an objective look at all the D&D rules and propose variant rules.Being a big proponent of actions and consequences, I have come up with some ideas that fit within this mold making these actions less of a "sure thing" and more chaotic. To allow for multiple levels of fun, I came up with three tiers of increasing complexity that the DM (with their players) can decide to use.That said, let's take a look at the Dash action.DASH The Dash rules as written (RAW) on page 192 of the PHB are:Dash
When you take the Dash action, you gain extra movement for the current turn. The increase equals your speed, after applying any m…

Betrayal at House on the Hill - Tabletop Review

Wanting to get together with friends during this Covid-19 lockdown but not wanting to break quarantine protocol and spread the disease, I reached out to a member of my community who was wonderful enough to gift me a copy of Tabletop Simulator and promptly got a list of games together to play which included Betrayal at House on the Hill, but with so many games out there, is this game worth your money and time?  ⚅⚅⚅ The story behind Betrayal at House on the Hill doesn't matter.

Rather, the story behind Betrayal at House on the Hill is simply whatever you want or need it to be in order to get your group of various characters to the house sitting atop the hill because this wonderful game by Avalon Hill knows it's what happens within these walls that truly matters. It's what transpires behind that locked door that provides the most entertainment, and what happens is a lot of fun with a twist of betrayal!

I played this game with three of my friends, but it can be played with up…