ParseSpell - MomoPewpew/MagicSpells GitHub Wiki

Source Code

spell-class: ".targeted.ParseSpell"

Description:

This spell is used to edit a string variable.

Configuration options:

Option Description Default Value
operation Valid operations: translate (normal), difference, append, and regex (regexp) "normal"
parse-to-variable Variable to store the result in after the operation is complete.

Translate:

This mode changes the variable value to a new value if the expected-value matches the current value of variable-to-parse.

Option Description
variable-to-parse Variable to check.
expected-value A string, but "any" can be used as a wildcard.

Difference:

This mode checks the difference between two variables and stores the result.

Option Description
first-variable First variable to check against.
second-variable Second.

Append:

This mode first checks if the expected-value matches the current value of variable-to-parse. If it does, it appends parse-to onto the value of variable-to-parse, and stores this new value string.

Option Description
expected-value A string, but "any" can be used as a wildcard.
variable-to-parse Variable to check.
parse-to The value to append.

Regex:

This mode can store returned matched text or do text replacement.

Option Description
variable-to-parse Variable value to match or perform replacements on.
expected-value A regex object (in string format). Use this for help: https://regexr.com/
parse-to If this value is specified, it will be used as the replacement text for the first thing that is matched. If it's empty, the result will instead be all the matched text.

Example of the "normal" operation:

parse:
    spell-class: ".targeted.ParseSpell"
    target-self: true
    # operation - normal (default)
    variable-to-parse: Greeting
    expected-value:  Hello
    parse-to-variable: Greeting
    parse-to: Goodbye