Skip to content

Variable Modification

JasperLorelai edited this page Jul 19, 2023 · 9 revisions

Description:

  • In most cases throughout the plugin the same variable is used as a base value for modification and for where the value is stored after modification. But there are some other cases where the base value is something completely different, but this method is supported for its modification.
  • Like in the SlimeSizeSpell, the size option supports this method, while the base value is the targeted slime's current size.
# Multiply size by 2
size: "*2"
  • That spell, however, is the only exception at the moment. So, in the rest of this page, we'll only cover formats where the same variable is the base and storage location.

Formats:

variable-mods-<type>

variable-mods-<type>:
    - varName1 <varMod>
    - varName2 <varMod>
    . . .

/ms variable modify

  • varMod refers to modification itself.
  • Format: /ms variable modify <variable> <player> <varMod>

variable Modifier Action

  • varMod refers to modification itself.
  • For this example we'll use the always condition, which passes always because in this case, we don't need a condition.
# The following two are the same because the default variable owner is "caster".
modifiers:
    - always variable varName;<varMod>
    - always variable caster:varName;<varMod>

# This supports "target" variable owner. Note that target modifiers only work on targeted spells.
target-modifiers:
    - always variable target:varName;<varMod>
    - always variable caster:varName;<varMod>

varMod:

There are core operators that work in the form of:

<operator><value>
# Example:
+5

value can be:

  • Some value you want to modify the base value with using the operator specified, string for string variables, or a number for others.
  • It can also be another variable. In that case, the base value is modified by the value of that variable. You can add a - before the variable too.
<operator><variableOwner><varName>
# Example:
=-b

variableOwner can be caster or target (only in targeted spells). Note that variableOwner is caster by default. So if you want it to be the caster's value, you don't need to specify it.

<operator><varName>

Operators:

  • If an operator isn't specified, the default operator used is +
<operator><value>

String variable:

  • This section documents which operators can be used when the base value is a variable of type playerstring or globalstring.
  • value can be text of any length you'd like if it's not a variable name.
  • Operators:
    • = - Set the variable to what value is.
    • + - Append value to the variable's current value.
    • * - Set the variable to what the current value is then repeated as many times as value defines. value should be a number for this operation. If it's a plain string, the variable will be set to empty.

Other operators:

  • value can be a double value, meaning with or without decimals - when it's not a variable name. You can add - in front to make it a negative number.
  • Operators:
    • = - Set the base to what value is.
    • + - Add value to the base value. Note that value can have - in front. Since + is the default operator, you can subtract values from the base by using the varMod -value, because it's the same as +-value, even if there is no - operator.
    • * - Multiply base and value.
    • / - Divide base with value.
    • ^ - Exponentiation, where value is the power.
    • % - Modulo operator, returns the remainder after dividing base with value.
    • ? - A pseudorandom number generated from 0 (inclusive) to value.

Clone this wiki locally