I joke on stream that I'm not allowed to play videos, just code. So I wanted to take a video game that many programmers like (Factorio), and see if we could get the Twitch Chat to play it for me, while I code up easier ways of interacting with the fame.

The API for Factorio is very flexible, so we ended up being able to allow the Twitch Chat to pretty quickly control everything.

What it does

We have hooked up Twitch Chat to Factorio, with Channel Points allowing access to the Lua Console in Factorio Directly, as well as provide some bonus rewards to cause more chaos.

How we built it

We have a Go Application, that is listening to Twitch Chat over IRC, and Listening for Channel Points Webhooks using Helix.

When chatters type Factorio Commands, we forward them to our Game of Factorio Running Locally using Valve's RCON protocol:

This controls our character directly in the game, and provides abstractions for the player, to move around, craft, build, destroy and in general manipulate the game to progress.

Channel Point Rewards either help or hurt in the game, players can create explosions, or summon biters, or execute Raw Lua to do anything from research all tech to creating a thousand trees.

Challenges we ran into

  • There are differences in running Console Commands directly in Factorio, versus sending them over Rcon.

  • We can't send messages back to our Go application through RCON, and the version of Lua running in Factorio is more limited (for good reasons!)

  • There was a bug in the Go Helix library around fetching User Input from Channel Rewards that was hard to track down at first.

Accomplishments that we're proud of

  • The Chat was able to build some crazy of structures of 100's of biters of vehicles, writing Lua right in the Channel Points Input box!

  • The chat was able to setup electricty and build blue and green science, all through twitch commands.

What we learned

  • If you let the chat write raw lua, they will find a way to crash your program
  • Chat is better at Factorio than me
  • Channel Points Webhooks are pretty simple to Setup
  • RCON is a powerful tool

What's next for Begin-Factorio-World

  • We are going to lanch the game on a dedicated server so people can continue to play 24/7.
  • We are going to continue to refine both the in game and Channel Points commands, to make the game a fun balance between order and chaos.
  • We are going to see if we can get the Twitch Chat to beat a game all on their own.

Heres some clips from trying it out:

Also Note the the majority of the code written for this for channel points is located here:

And heres the Lua Mod for Factorio:

Full Stream before submission:

Built With

Share this project: