Custom Effects

Jun 2, 2018
Custom Effects
  • Custom Effects
    What are custom effects?
    Custom effects are effects that are not hard coded into the plugin. You can make them yourself and use them as you would use other effects such as <glow> or anything else.

    Are they as powerful?
    Custom effects can use Javascript that allows you to create them as powerful as the existing effects. In fact, over time I might move to custom effects instead of hard coded ones.

    Are they as efficient?
    Effects are cached upon startup, meaning that if your effect does not contain placeholders (that will change) it will not reevaluate the Javascript again.




    Creating a custom effect(top)


    Creation(top)


    1. Create a new YML file in the "effects" directory of the animation plugin
      By default, the name of the YML will also be the name of the tag you will use
      to call your effect. A file called "example1.yml" will be used like <example1>....</example1>
      However you can manually change this later inside the file.
    2. Open the newly created YML file

    Editing(top)

    The effects file consists of three main parts:

    1. Settings: These are the settings for the effect including the possible arguments
    2. Script: This is a javascript code that will be ran when the effect is first loaded
    3. Frames: These are the frames the animation/effect outputs

    Settings(top)

    The settings is a configuration section like:
    Code (Text):
    settings:
        tag: "scramble"
        force-update: false
     
    tag: Allows you to change the tag that is used to call the effect (<scramble>)
    force-update: As mentioned above, the effect will be cached when it does not contain any placeholders. If you do not want this (for example when your javascript has things that change over time) you need to set this to true.

    [Optional] Arguments(top)
    Arguments are things a user can change concerning the animation. If you are familiar with other hard coded effects such as "glow" they can change colors and things like that.

    In order to set the default arguments:
    Code (Text):
    settings:
      force-update: false
      arguments:
        message-color: 'c'
        warning-color: 'e'
    You can use them in your "Frames" like normal placeholders {message-color}, {warning-color}

    [Optional] Script(top)

    Script is a string that contains javascript. You can load third party javascript files, create functions
    that you can later use inside your frames and so on...

    An example can be found in the example3.yml that is created by default.

    Scripts have two global variables that they can use:
    effectsDirectory: This is the directory of the effects. Useful when you are sideloading javascript files
    effectConfigFile: This is the file of the effect.

    Frames(top)

    Code (Text):
    frames:
    - 'H'
    - 'He'
    - 'Hel'
    - 'Hell'
    - 'Hello'
    Frames is a list of strings that will be returned as the effect/animation. It can also be 1 line

    You can execute a script by encapsulating it in <% ...%>
    Example:
    Code (Text):
    frames:
    - '<% 1+2 %>'
    (it will return 3)
    The script engine is linked with the script you created earlier in the "script" section - meaning you an also use it to invoke a function.

    If a function returns an array of strings it will output an animation, if it returns a single string - it will just replace the <% ... %> with that string.

  • Loading...
  • Loading...