Kruiser8 / Kruiz-Control

Kruiz Control enables a pseudo code approach to manage and automatically handle Twitch Channel Points, Twitch Chat, OBS or SLOBS, and StreamElements or Streamlabs alerts.
Other
231 stars 32 forks source link

Is it possible to call sub-routines? #46

Closed scruffyfox closed 2 years ago

scruffyfox commented 2 years ago

Basically the title.

I have a couple scripts that are quite complex and lengthy, but I would like them to trigger also from another trigger, is this possible?

This is my use-case: channel point redemption for "randomise vfx", which executes a long script to generate and send some API values, but at the end, I want to also Chat Send the result of the randomisation which is another long script triggered with !chain. I could Chat Send '!chain' which would trigger the command via chat, but was wondering if there's a nicer way of doing that from within the script.

I read about the Action section but didnt really understand how it's used or if it would help in my use-case.

Cheers!

Kruiser8 commented 2 years ago

Hey @scruffyfox, when you say "a couple scripts" are you referencing Kruiz Control events? Making sure you don't mean Javascript scripts.

The OnAction section would fit your use case. OnAction takes the event code and injects it into another event.

OnCommand b 0 !chain
Chat Send "Pre-Chain stuff..."
DoTheThing
Chat Send "Chained stuff..."

OnChannelPoint "Randomize VFX"
Chat Send "Randomizing stuff..."
DoTheThing

OnAction DoTheThing
Chat Send "Hey, we're doing the thing!"

is equivalent to

OnCommand b 0 !chain
Chat Send "Pre-Chain stuff..."
Chat Send "Hey, we're doing the thing!"
Chat Send "Chained stuff..."

OnChannelPoint "Randomize VFX"
Chat Send "Randomizing stuff..."
Chat Send "Hey, we're doing the thing!"
scruffyfox commented 2 years ago

@Kruiser8 this is perfect! I had a feeling OnAction would be what I needed but I couldn't make full sense of the documentation. Thanks!