TwitchSpawn
Search…
πŸ“—
Creating Basic Ruleset
This page will help you create your very basic ruleset!
Rulesets are pretty important since they define how a received event should be handled by the mod. But before creating our own ruleset, we need to understand TwitchSpawn's inner workings of loading the rules.

Ruleset Files

Ruleset files are TSL files which are named like rules.xxx.tsl. Unless it is default, xxx defines associated streamer's Minecraft nickname (which is case insensitive unlike credentials.toml).
TSL files named not like rules.xxx.tsl are considered as malformed and are not loaded by the mod. However, they do not crash the loading process.
Default ruleset is used to handle incoming events, if and only if there were no ruleset loaded associated with the relevant streamer. Also default ruleset file is always generated by the mod, if it is not there. However, it is discouraged to use default ruleset mainly unless there is only one streamer in the credentials.toml

Ditching Default Ruleset

Now that you know how the mod loads in the rulesets, you are now ready to define your own rules! Start by creating a TSL file with your Minecraft nickname in it. (E.g if your Minecraft nickname is iGoodie, create a TSL file named rules.igoodie.tsl)
TSL files are nothing more than text files, so creating a text file with .tsl extension is enough. Or you can copy default ruleset file and rename it.

"Hello World" TSL

In programming world, it is always so exciting to get your very first program work: "Hello World Program"! Get ready to experience a similar thing using the TSL language!
πŸŽ‰

TSL Structure

The TSL Language provides a readable rule defining interface to users. Its general structure for defining single rule is like following:
ACTION_NAME arguments seperated by space or %grouped to contain spaces% ON Event Name WITH some > predicate
TSL files (the ruleset files) are consisted of multiple rules seperated by blank lines.
Basics about TSL can be found on following page:

Basic Examples

Lets start by implementing our very first rules.
  1. 1.
    We want the mod to drop a stick on donation between [0,10]
  2. 2.
    We want the mod to drop an apple on donation between [11,20]
  3. 3.
    And finally we want the mod to drop a diamond between [21,30]
It is easy as following:
rules.somebody.tsl
# You can write everything in-line
DROP minecraft:stick ON Donation WITH amount IN RANGE [0,10]
​
# You can seperate various parts by a new line and a SPACE.
# Continuing lines without a space character counts as malformed.
DROP minecraft:apple
ON Donation
WITH amount IN RANGE [11,20]
# You can input anything accepted by Minecraft!
DROP %diamond{display:{Name:"\"A DIAMOOND!\""}}% # Grouping mandatory here, since contains space
ON Donation
WITH amount IN RANGE [21,30]
# You can also override display message!
DROP diamond
DISPLAYING %[{text:"Here, a diamond for you!", color:"dark_purple"}]%
ON Donation
WITH amount > 30
Copy link
On this page
Ruleset Files
Ditching Default Ruleset
"Hello World" TSL
TSL Structure
Basic Examples