Slay the Spire

Slay the Spire

Slay the 7TV
 This topic has been pinned, so it's probably important
DandyLion  [developer] Jan 15, 2024 @ 12:50pm
FREQUENTLY ASKED QUESTIONS
What is 7TV?
7TV is 3rd-party emote site used on Twitch, the streaming platform. Twitch users upload images and gifs of whatever they want, and streamers can choose which emotes they want to allow in their channel by adding it to an emote set.

How do I load in my channel's 7TV emotes?
You need to configure the emote set ID in the mod options. Go into the mod options and you should see a button called 'Set Emote Set ID'. Clicking on it will show a dialog box where you can enter the emote set ID.

Where do I find the emote set ID?
Login to 7TV, go to your profile, and you should see a list of emote sets attached to your account. Click on one of the emote sets and in the URL you should see something that looks like this at the end of the path: 61ccff1f08a626f33fd10026
This is the emote set ID. Set this value in the mod settings. The above is a valid example and the emote set I used during testing.

That's all I have to do?
Yeah, that's it. I went to some crazy lengths to make this as easy as possible for the player.

Will this work for my BetterTTV or Twitch.tv emotes?
No, only 7TV emotes are supported at this time. If there is enough demand and someone can show me some documentation to look at, I could try to get it working for BetterTTV / Twitch.tv emotes.

What will you do if 7TV restricts their APIs or asks you not to use the APIs in this way?
Cry.

Boring tech details for those curious

When is the emote data loaded from the emote set?
The emote data is loaded when you start/continue a run. This is so if you add/remove an emote mid-run, all you need to do to refresh the emote list in-game is to exit and continue the run. As long as the emote set ID is configured, whenever the run starts/continues, the emote meta-data will be pulled from 7TV and your emotes can be referenced by Twitch chat.

How are you getting the actual emotes from 7TV into the game?
7TV has publicly available APIs: https://7tv.io/
I start by pulling the emote meta-data of all the emotes in the set when the run starts/continues. Whenever a word in the emote set is detected while creating the speech bubble, I fetch and cache that emote to keep things fast. This way, only the necessary emotes are actually loaded and rendered, and the popular ones are cached so response times are faster.

So all the emotes are loaded and rendered?
No, only the emotes directly requested are fetched and rendered. The meta-data of the other 99% of emotes aren't used.

How many emotes can be fetched and rendered at one time?
No clue. I couldn't find the limit. I did experience one crash, though, so be warned that things might be a little unstable in these early days.

How are you able to render the images and gifs on the fly? Don't you need an actual file on the computer for libgdx (Slay the Spire's engine) to use?
Every emote that's fetched from 7TV is stored as a temporary file on your computer. These temporary files are removed when the game closes and don't stay on your computer. I haven't seen a single case in my testing where the files remain. If downloading random images and gifs from the internet onto your computer makes you uncomfortable, then please don't use this mod.

Wait, did you say gif support? How is that even possible?
Friggin black magic. I found a gif decoder for libgdx a few months back. It was the last piece I needed to make this work: https://gamedev.stackexchange.com/questions/136659/is-it-possible-to-use-animated-gif-images-in-lbgdx
None of this would be possible without the hard work of Johannes Borchardt, who wrote the initial decoder, and Anton Person, who converted this for use in libgdx. I'm a bozo, so I wouldn't have been able to pull this off without them. They have my sincerest thanks.

Can I contribute or look at your source code?
Yes! I make all my mods publicly available on GitHub. Feel free to contribute, open issues, fork, or scrutinize any of my public repos. GH - https://github.com/TheDanDLion/SlayTheSevenTV

Bugs

The temp files are still on my computer! What do I do?
Clear them out, then make a post on the bug board with your operating system and hardware information. There is likely some edge case I didn't consider at the time that involves your specific setup.

An emote I'm using looks funny, or isn't showing up.
Test it out a bit using the "speak" console command before posting about it on the bug board. This forces the first enemy to say whatever you put after the command, rendering 7TV emotes in the process.
e.g. "speak Render this emote peepoGiggles", "speak monkaS"
Sometimes the decoder has a little accident, so what you're seeing could possibly be a one-off occurrence and should be verified before escalating.

Things aren't spaced properly / there are wide gaps when everything is rendered.
I know, I'm working on it. I have to patch a lot of calculations and it's a pain.

My zero-width emote isn't overlapping with the previous emote!
That's because it's not supported yet :)

Why does the dialogue bubble cut off the gif before the gif can loop?
I haven't adjusted the duration yet. I plan to make it so the bubble will last at least 1.25 loops when it's a gif. That way if you post a silly little gif it'll play out before the bubble disappears. This comes with a lot of added complexity I have to handle.
Last edited by DandyLion; Jan 25, 2024 @ 5:44pm