|
Variables
|
|
|
|
-----------------
|
|
|
|
|
|
|
|
Variables are a system for storing information. Using the variables system, you can store and manipulate values that you can use in placeholders or conditions later. These values can be either permanent or temporary.
|
|
Variables are a system for storing information. Using the variables system, you can store and manipulate values that you can use in placeholders or conditions later. These values can be either permanent or temporary.
|
|
|
|
|
|
### Variable Types
|
|
[[_TOC_]]
|
|
|
|
|
|
|
|
# Variable Types
|
|
Variables can be one of several types, which is defined when the variable is initialized using the
|
|
Variables can be one of several types, which is defined when the variable is initialized using the
|
|
[setVariable](/skills/mechanics/setvariable) mechanic. Types are generally interchangeable and MythicMobs will do its best to apply certain variables to whatever situation is asked, however it will throw
|
|
[setVariable](/skills/mechanics/setvariable) mechanic. Types are generally interchangeable and MythicMobs will do its best to apply certain variables to whatever situation is asked, however it will throw
|
|
an error if you try to use a variable type for something that makes no sense.
|
|
an error if you try to use a variable type for something that makes no sense.
|
|
|
|
|
|
**Current Types**:
|
|
|
|
|
|
|
|
| **Type** | **Description** |
|
|
| **Type** | **Description** |
|
|
|----------|----------------------------------|
|
|
|----------|----------------------------------|
|
|
| INTEGER | A number with no decimal places. |
|
|
| INTEGER | A number with no decimal places. |
|
|
| FLOAT | A number with decimal places. |
|
|
| FLOAT | A number with decimal places. |
|
|
| STRING | A word or sentence. |
|
|
| STRING | A word or sentence. |
|
|
|
|
|
|
### Variable Scopes
|
|
|
|
|
|
|
|
|
|
# Variable Scopes
|
|
A variable's "scope" is **where** that variable exists. Not all scopes are applicable for all situations (e.g. a condition may not have a caster, rather the caster is the target of the condition).
|
|
A variable's "scope" is **where** that variable exists. Not all scopes are applicable for all situations (e.g. a condition may not have a caster, rather the caster is the target of the condition).
|
|
|
|
|
|
**Variable Scopes**:
|
|
| **Scope**| **Where the Variable Exists** |
|
|
|
|
|----------|---------------------------------------------------------------------------------------------|
|
|
| **Type** | **Where the Variable Exists** |
|
|
|
|
|----------|----------------------------------------------------------------------------------------------------|
|
|
|
|
| SKILL | On the current skill tree. Always temporary and will vanish when the current queue of skills ends. |
|
|
| SKILL | On the current skill tree. Always temporary and will vanish when the current queue of skills ends. |
|
|
| CASTER | On the casting mob. |
|
|
| CASTER | On the casting mob. |
|
|
| TARGET | On the target of the mechanic/condition. |
|
|
| TARGET | On the target of the mechanic/condition. |
|
... | @@ -32,16 +26,14 @@ A variable's "scope" is **where** that variable exists. Not all scopes are appli |
... | @@ -32,16 +26,14 @@ A variable's "scope" is **where** that variable exists. Not all scopes are appli |
|
| GLOBAL | The server. |
|
|
| GLOBAL | The server. |
|
|
|
|
|
|
|
|
|
|
### Usage
|
|
# Usage
|
|
|
|
All variable mechanics and conditions accept `var=` and `scope=` attributes to determine what variable you're wanting to work with and where. You can also shorthand the scope using `var=scope.variable_name`. The following examples would return the same thing:
|
|
All variable mechanics and conditions accept **var=** and **scope=** attributes to determine what variable you're wanting to work with and where. You can also shorthand the scope using *var=scope.variable\_name**. The following examples would return the same thing:
|
|
```yaml
|
|
```
|
|
- setvariable{var=target.somevariable; ...}
|
|
setvariable{var=target.somevariable; ...}
|
|
- setvariable{var=somevariable;scope=target; ...}
|
|
setvariable{var=somevariable;scope=target; ...}
|
|
|
|
```
|
|
```
|
|
|
|
|
|
### Variable Mechanics
|
|
## Variable Mechanics
|
|
|
|
|
|
Variable mechanics are special mechanics that utilize variables. They can target entities, locations, or nothing, but the target can affect the outcome depending on what scope you're using. For example, trying to get a target-scope'd variable will obviously fail if you're not targeting an entity.
|
|
Variable mechanics are special mechanics that utilize variables. They can target entities, locations, or nothing, but the target can affect the outcome depending on what scope you're using. For example, trying to get a target-scope'd variable will obviously fail if you're not targeting an entity.
|
|
|
|
|
|
| Mechanic | Description |
|
|
| Mechanic | Description |
|
... | @@ -53,27 +45,42 @@ Variable mechanics are special mechanics that utilize variables. They can target |
... | @@ -53,27 +45,42 @@ Variable mechanics are special mechanics that utilize variables. They can target |
|
| [VariableSubtract](/skills/mechanics/variablesubtract) | Subtracts from a numeric variable. |
|
|
| [VariableSubtract](/skills/mechanics/variablesubtract) | Subtracts from a numeric variable. |
|
|
| [VariableMath](/skills/mechanics/variablemath) | Lets you do calculations with numeric variables. |
|
|
| [VariableMath](/skills/mechanics/variablemath) | Lets you do calculations with numeric variables. |
|
|
|
|
|
|
### Variable Conditions
|
|
|
|
|
|
|
|
|
|
## Variable Conditions
|
|
| Condition | Description |
|
|
| Condition | Description |
|
|
|--------------------------------------------------|------------------------------------------------|
|
|
|--------------------------------------------------|------------------------------------------------|
|
|
| [Variable Equals](/skills/conditions/variableequals) | Checks if a variable equals a given value. |
|
|
| [Variable Equals](/skills/conditions/variableequals) | Checks if a variable equals a given value. |
|
|
| [Variable Is Set](/skills/conditions/variableisset) | Checks if a variable is set. |
|
|
| [Variable Is Set](/skills/conditions/variableisset) | Checks if a variable is set. |
|
|
| [Variable In Range](/skills/conditions/variableinrange) | Checks if a number variable is within a range. |
|
|
| [Variable In Range](/skills/conditions/variableinrange) | Checks if a number variable is within a range. |
|
|
|
|
|
|
### Variable Placeholders
|
|
# Variable Placeholders
|
|
|
|
Variables can be referenced in any MythicMobs mechanics or values that allow placeholders. This is usually done using the format `<scope.var.variable>`.
|
|
|
|
|
|
Variables can be referenced in any MythicMobs mechanics or values that allow placeholders. This is usually done using the format **<scope.var.\[variable\]>**.
|
|
# Variable Fallback
|
|
|
|
When using placeholder variables, you can also specify a "default" value that will be used if the variable is undefined by using the syntax `<scope.var.variable|default>`.
|
|
|
|
|
|
When using placeholder variables, you can also specify a "default" value that will be used if the variable is undefined by using the syntax **<scope.var.\[variable\]\|\[default\]>**.
|
|
```yaml
|
|
|
|
- message{m="Hello there, <target.var.title|wanderer>"} @trigger ~onInteract
|
|
message{m="Hello there, <target.var.title|wanderer>"} @trigger ~onInteract
|
|
```
|
|
|
|
|
|
In this example, the NPC would reply with "Hello there, wanderer" if
|
|
In this example, the NPC would reply with "Hello there, wanderer" if
|
|
right-clicked by somebody who had no "title" variable set on them.
|
|
right-clicked by somebody who had no "title" variable set on them.
|
|
However, if we did this:
|
|
However, if we did this:
|
|
|
|
|
|
setVariable{var=target.title;value="Sir"} @trigger ~onInteract
|
|
```yaml
|
|
|
|
- setVariable{var=target.title;value="Sir"} @trigger ~onInteract
|
|
|
|
```
|
|
|
|
|
|
...somewhere along the line, even with a different mob, the first mob
|
|
...somewhere along the line, even with a different mob, the first mob
|
|
would say "Hello there, Sir".
|
|
would say "Hello there, Sir".
|
|
|
|
|
|
|
|
# Nested Variable
|
|
|
|
Variables can also be nested indefinitely: if this is done, the innermost variable would be resolved first and, from there, each would be resolved from innermost to outermost
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
Skills:
|
|
|
|
- setvariable{var=caster.hello;type=STRING;val=example_name}
|
|
|
|
- setvariable{var=caster.example_name;type=STRING;val=Hello There!}
|
|
|
|
- message{m="<caster.var.<caster.var.hello>>"} @PIR{r=10}
|
|
|
|
```
|
|
|
|
> In this example, the message would spell "Hello there!" |
|
|
|
\ No newline at end of file |