Custom Code Event
Details
This event can only be triggered with the CPH.TriggerCodeEvent
C# Method. You can use two methods. With the first method you can use the variables of the current action. With the second method you can specify a dictionary of variables for the trigger.
When registering a trigger your trigger will end up in the Custom
folder under triggers. You can nest the trigger in multiple folders by using the catergories
parameter. To give the trigger a name use the triggerName
parameter. Use the eventName
parameter for a name only used in C# for triggering the method.
Variables
Variables are dependent on the custom event.
C# Usage
Register a custom trigger
public bool RegisterCustomTrigger(string triggerName, string eventName, String[] categories)
triggerNamestring required Name of the trigger shown in the context menu
eventNamestring required Define the name of the event for later use in TriggerCodeEvent method
categoriesString[] required Define the categories in the context menu in which the trigger will be shown
using System;
public class CPHInline
{
public void Init()
{
// Preferably Custom Triggers are registered during initialization of the code instance
// Often in combination with Pre-Compile on Application start in the Execute-Code settings
//Define the categories in custom trigger menu
string[] categories = {"Streamer.bot","Documentation"};
//Define the event name for later usage in code with CPH.TriggerCodeEvent(eventName)
//Advise on making it fairly unique names to your code/extension
string eventName = "sbDocsUpdate";
//Register custom trigger. Will give boolean result if successfull
bool success = CPH.RegisterCustomTrigger(triggerName, eventName, categories);
}
public bool Execute()
{
// Custom Trigger can also be registered with Execute but common usage is
// in the Init() method as shown above
return true;
}
}
Triggers a custom code event name (see RegisterCustomTrigger)
public void TriggerCodeEvent(string eventName, bool useArgs = true)
eventNamestring required useArgsbool
CPH.TriggerCodeEvent(eventName);
CPH.TriggerCodeEvent(eventName, useArgs);