|
Variables (v4.6+)
|
|
Variables
|
|
-----------------
|
|
-----------------
|
|
|
|
|
|
Variables are a new system for storing information added in v4.6. Using
|
|
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.
|
|
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
|
|
### Variable Types
|
|
|
|
|
|
Variables can be one of several types, which is defined when the
|
|
Variables can be one of several types, which is defined when the variable is initialized using 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
|
|
an error if you try to use a variable type for something that makes no sense.
|
|
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.
|
|
|
|
|
|
|
|
**Current Types**:
|
|
**Current Types**:
|
|
|
|
|
... | @@ -26,13 +19,11 @@ sense. |
... | @@ -26,13 +19,11 @@ sense. |
|
|
|
|
|
### Variable Scopes
|
|
### Variable Scopes
|
|
|
|
|
|
A variable's "scope" is **where** that variable exists. Not all 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).
|
|
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**:
|
|
**Variable Scopes**:
|
|
|
|
|
|
| **Type** | **Where It Goes** |
|
|
| **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. |
|
... | @@ -42,22 +33,15 @@ caster, rather the caster is the target of the condition). |
... | @@ -42,22 +33,15 @@ caster, rather the caster is the target of the condition). |
|
|
|
|
|
### Usage
|
|
### Usage
|
|
|
|
|
|
All variable mechanics and conditions accept **var=** and **scope=**
|
|
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:
|
|
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:
|
|
|
|
|
|
|
|
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
|
|
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.
|
|
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 |
|
|
|--------------------------------------------------------|--------------------------------------------------|
|
|
|--------------------------------------------------------|--------------------------------------------------|
|
... | @@ -76,13 +60,9 @@ targeting an entity. |
... | @@ -76,13 +60,9 @@ targeting an entity. |
|
|
|
|
|
### Variable Placeholders
|
|
### Variable Placeholders
|
|
|
|
|
|
Variables can be referenced in any MythicMobs mechanics or values that
|
|
Variables can be referenced in any MythicMobs mechanics or values that allow placeholders. This is usually done using the format **<scope.var.\[variable\]>**.
|
|
allow placeholders. This is usually done using the format
|
|
|
|
**<scope.var.\[variable\]>**.
|
|
|
|
|
|
|
|
When using placeholder variables, you can also specify a "default" value
|
|
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\]>**.
|
|
that will be used if the variable is undefined by using the syntax
|
|
|
|
**<scope.var.\[variable\]\|\[default\]>**.
|
|
|
|
|
|
|
|
message{m="Hello there, <target.var.title|wanderer>"} @trigger ~onInteract
|
|
message{m="Hello there, <target.var.title|wanderer>"} @trigger ~onInteract
|
|
|
|
|
... | | ... | |