Example Effects Driven Chat Game - crowbartools/Firebot GitHub Wiki
Overview
Using Firebot's effect system, you can build all sorts of complex chat and mixplay games. Here's an example setup of a "spin" gambling game.
Example !spin game setup
- Create custom command with trigger: !spin
- Effects:
- Conditional Effects (Verify user issued command correctly and that they have enough currency)
- If:
- Command Args Count is less than 1
- [Custom] $ensureNumber[$arg[1], 0] is less than 0
- [Custom] $currency["YOUR CURRENCY NAME", $user] is less than $arg[1]
- Effects:
- Chat
- Text: "Incorrect !spin usage: !spin [amount]"
- Whisper: $user
- Stop Effect Execution (Stop execution of these effects)
- Check "Bubble stop execution"
- Chat
- Effects:
- If:
- Update Currency
- Operation: Remove
- Target: Single User ($user)
- Amount: $arg[1] (removes the given amount of currency the user wagered in the command)
- Custom Variable (Create a variable to store how many times user wins a spin)
- Name: $user-spin-wins (uses $user to ensure this variable doesn't conflict with other users)
- Data: 0
- Loop Effects (Loop 3 times for 3 spins)
- Set to loop 3 times
- Effects:
- Custom Variable (Store a random number between 1-100 in a variable)
- Name: $user-spin-check
- Data: $randomNumber[1, 100]
- Conditional Effects (check results of random number)
- If:
- [Custom] $user-spin-check is less than or equal to 33 (1/3rd chance they win each spin)
- Effects:
- Custom Variable
- Name: $user-spin-wins
- Data: $math[$customVariable[$user-spin-wins] + 1] (adds 1 to the win counter)
- Chat
- Text: "Spin: Hit!"
- Whisper: $user
- Custom Variable
- Otherwise (spin wasnt successful)
- Effects:
- Chat
- Text: "Spin: Miss!"
- Whisper: $user
- Chat
- Effects:
- If:
- Delay (delay in between loops so it doesn't happen too fast, builds anticipation for the user)
- Duration: 2 (seconds)
- Custom Variable (Store a random number between 1-100 in a variable)
- Custom Variable (Calculate winnings)
- Name: $user-spin-winnings
- Data: $math[$arg[1] * $customVariable[$user-spin-wins]] (multiply the number of wins against the wager amount)
- Update Currency (Give winnings to user)
- Operation: Add
- Target: Single User ($user)
- Amount: $customVariable[$user-spin-winnings]
- Chat
- Text: "$user has won $commafy[$customVariable[$user-spin-winnings]] ($customVariable[$user-spin-wins]/3 spins hit)!"