Skip to content

Instantly share code, notes, and snippets.

@FatsackFails

FatsackFails/toggle.txt

Last active May 5, 2021
Embed
What would you like to do?
Toggle System for Kruiz Control
#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!"
@FatsackFails

This comment has been minimized.

Copy link
Owner Author

@FatsackFails FatsackFails commented Mar 14, 2021

Description: basic framework of toggle system to switch between two states with the same command or event. On/Off, Red Mode/Blue Mode, etc.
KC Version: v1.3.4
Usage: !toggle to switch back and forth between two states
Usage !checktoggle to check which state toggle is currently in

@FatsackFails

This comment has been minimized.

Copy link
Owner Author

@FatsackFails FatsackFails commented May 5, 2021

For a more in depth look at this code snippet, check out the post on my website.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment