Last active
April 26, 2022 00:09
-
-
Save FatsackFails/4ca2b87384468da79f4538255ef3a319 to your computer and use it in GitHub Desktop.
Toggle System for Kruiz Control
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Sets toggle01 to off when KC starts up | |
OnInit | |
Variable Set toggle01 false | |
#Send Message to switch toggle01 | |
OnCommand b 0 !toggle | |
Message Send switchToggle | |
#Switches toggle01 on and off | |
OnMessage switchToggle | |
Variable Load toggle01 | |
Function "var toggle = {toggle01};toggle = !toggle;return {result: toggle};" | |
Variable Set toggle01 {result} | |
#Checks to see if toggle01 is on or off | |
OnCommand b 0 !checktoggle | |
Variable Load toggle01 | |
If 2 {toggle01} = false | |
Chat Send "This toggle is off!" | |
exit | |
Chat Send "This toggle is on!" |
This uses new Actions brought into v1.5.3
The original still works, this just uses newer built in ways to achieve the same thing.
# Sets toggle01 to off when KC starts up
OnInit
Variable Set toggle01 false
# Send Message to switch toggle01
OnCommand b 0 !toggle
switchToggle
# Switches toggle01 on and off
OnAction switchToggle
Variable Load toggle01
Param Negate toggle01
Variable Set toggle01 {toggle01}
Chat Send "toggle01 set to {toggle01}"
# Checks to see if toggle01 is set to true or false
OnCommand b 0 !checktoggle
Variable Load toggle01
Chat Send "toggle01 set to {toggle01}"
# Tests toggle01 and does a different action depending on if its on or off
OnCommand b 0 !testtoggle
Variable Load toggle01
If 2 {toggle01} = false
Chat Send "Toggle is off!"
Exit
Chat Send "Toggle is on!"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For a more in depth look at this code snippet, check out the post on my website.