User Submitted CoyoteScript

Translation & Modifier Toggle

Author: Sander

Script Version: 1

Minimum CoyoteMIDI Build: 820

With this script you can toggle translations, modifiers, and their respective folders on or off directly from a translation. You can choose exactly which controls get toggled by specifying their name tag.

This script will add the following translation parameters:
Target: The type of control that will be targeted, such as Translation, Translation Folder, Modifier, or Modifier Folder.
State: The active state to set the control to. By default this will be toggle, which will just switch the control to the state it wasn’t already on, but you can also specify on or off manually.
Tag: The tag that the control has to match exactly for it to be toggled by this script. Tags can be set by clicking the arrow graphic in translations, or the names of folders and modifiers.
				
					// Ensure this script is ran from a translation.
enforcetrigger translation
// Get the tag from the translation parameter.
$tag = ($parameters tag)

// Get the target state from the translation parameter.
$state = ($parameters state)
// Convert On to True and Off to False for convenience.
if $state == On
    $state = True
else if $state == Off
    $state = False

// Switch based on whether the target control is a Translation, Modifier, or their respective folders.
switch ($parameters target)

    // Handle setting the active states of translations.
    case Translations
        // Loop through every translation.
        foreach $id : $translation in (gettranslations)
            // If the translation's tag matches our target tag, we will change its active state.
            if ($translation tag) == $tag
                // If our target state is 'Toggle' we will grab the translation's current state and flip it.
                $targetState = $state
                if $state == Toggle
                    $targetState = !($translation active)
                // Apply the desired active state to this translation.
                translationactive $id $targetState

    // Repeat the same logic for translation folders
    case "Translation Folders"
        foreach $id : $translationFolder in (gettranslationfolders)
            if ($translationFolder tag) == $tag
                $targetState = $state
                if $state == Toggle
                    $targetState = !($translationFolder active)
                translationfolderactive $id $targetState

    // Repeat the same logic for modifiers
    case "Modifiers"
        foreach $id : $modifier in (getmodifiers)
            if ($modifier tag) == $tag
                $targetState = $state
                if $state == Toggle
                    $targetState = !($modifier active)
                modifieractive $id $targetState

    // Repeat the same logic for modifier folders
    case "Modifier Folders"
        foreach $id : $modifierFolder in (getmodifierfolders)
            if ($modifierFolder tag) == $tag
                $targetState = $state
                if $state == Toggle
                    $targetState = !($modifierFolder active)
                modifierfolderactive $id $targetState

// Register the UI input fields shown in a translation when this script is selected.
event uirefreshed
    translationparameter target (combobox "Target" "The type of control to toggle the active state of." (Translations, "Translation Folders", Modifiers, "Modifier folders") Translations 0.75)
    translationparameter state (combobox "State" "The state to se the target control to." (Toggle, On, Off) Toggle 0.6)
    translationparameter tag (textbox "Tag" "The tag of the control to target the active state of.")
				
			

3 downloads