forked from nisovin/MagicSpells
-
Notifications
You must be signed in to change notification settings - Fork 71
Variable Modification
JasperLorelai edited this page Jul 19, 2023
·
9 revisions
- 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
sizeoption 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.
- These options are documented in base spell configuration.
-
typecan becast,caster, andtarget(modifies target's variables). -
varModrefers to modification itself. - The format:
variable-mods-<type>:
- varName1 <varMod>
- varName2 <varMod>
. . .-
varModrefers to modification itself. - Format:
/ms variable modify <variable> <player> <varMod>
-
varModrefers to modification itself. - For this example we'll use the
alwayscondition, 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>There are core operators that work in the form of:
<operator><value>
# Example:
+5value 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:
=-bvariableOwner 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>- If an operator isn't specified, the default operator used is
+
<operator><value>
- This section documents which operators can be used when the base value is a variable of type
playerstringorglobalstring. -
valuecan be text of any length you'd like if it's not a variable name. - Operators:
-
=- Set the variable to whatvalueis. -
+- Appendvalueto the variable's current value. -
*- Set the variable to what the current value is then repeated as many times asvaluedefines.valueshould be a number for this operation. If it's a plain string, the variable will be set to empty.
-
-
valuecan 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 whatvalueis. -
+- Addvalueto the base value. Note thatvaluecan 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 andvalue. -
/- Divide base withvalue. -
^- Exponentiation, wherevalueis the power. -
%- Modulo operator, returns the remainder after dividing base withvalue. -
?- A pseudorandom number generated from 0 (inclusive) tovalue.
-