[0.2.1+] Block Actions and Images in plugins

Hello everyone,

since version 0.2.1 of OB2 it is possible to add actions and images to your plugins.


You can now decorate methods with the BlockAction attribute, passing the name of the block they refer to. These methods will then have a button that can be clicked directly from Stacker. Your method needs to accept a single parameter of type RuriLib.Models.Blocks.BlockInstance and return void. You will then be able to access all the settings of the block and change them as you like.

Actions can be used for example to implement presets, so the user can click a single button and you will automatically set all parameters values as necessary from within the action itself.


Images can be loaded by users from their disk. You can access their value from actions, and you are also able to set their value (as a byte array of any supported type). These are used for example with blocks that process images, to give the user the ability to test the outcome of the block with a given set of parameters without having to manually run it.

To define images, simply decorate your existing blocks with one or more BlockImage attributes. Remember to give them a unique name so they can be accessed by actions!

Sample code

namespace OB2TestPlugin.Blocks.Images
    [BlockCategory("Images", "Blocks that allow to work with images", "#ffae42")]
    public static class Methods
        public static void SetString(RuriLib.Models.Blocks.BlockInstance block)
            block.Settings["str"].InputMode = SettingInputMode.Fixed;
            block.GetFixedSetting<StringSetting>("str").Value = "edited";

        public static void SetInteger(RuriLib.Models.Blocks.BlockInstance block)
            var imageSize = block.Descriptor.Images["myImage"].Value?.Length ?? 0;
            block.Settings["size"].InputMode = SettingInputMode.Fixed;
            block.GetFixedSetting<IntSetting>("size").Value = imageSize;
            (block as RuriLib.Models.Blocks.AutoBlockInstance).Safe = true;

        [Block("Image attribute test")]
        public static void ImageTest(BotData data, string str, int size)
            data.Logger.Log($"The string says: {str}", LogColors.YellowOrange);
            data.Logger.Log($"The image size is: {size}", LogColors.YellowOrange);

Remember to reference the latest RuriLib from your plugin to be able to access these new attributes, and to upgrade your plugin to .NET 6 by replacing net5.0 with net6.0 in your csproj file.

Stasy awesome,