Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
MythicMobs MythicMobs
  • Project overview
    • Project overview
    • Details
    • Activity
  • Issues 138
    • Issues 138
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Operations
    • Operations
    • Incidents
  • Analytics
    • Analytics
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Members
    • Members
  • Activity
  • Create a new issue
  • Issue Boards
Collapse sidebar
  • MythicCraft
  • MythicMobsMythicMobs
  • Wiki
    • Skills
  • Variables

Last edited by Lxlp Oct 22, 2024
Page history

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.

  • Variable Types
  • Variable Scopes
  • Usage
    • Variable Mechanics
    • Variable Conditions
  • Variable Placeholders
  • Variable Fallback
  • Nested Variable
  • Mob Variables

Variable Types

Variables can be one of several types, which is defined when the variable is initialized using the 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.

Type Description
INTEGER A number with no decimal places.
FLOAT A number with decimal places.
DOUBLE A number with decimal places. Can represent much larger numbers than a FLOAT
STRING A word or sentence.

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).

Scope Where the Variable Exists
SKILL On the current skill tree. Always temporary and will vanish when the current queue of skills ends.
CASTER On the casting mob.
TARGET On the target of the mechanic/condition.
WORLD The current world.
GLOBAL The server.

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:

    - setvariable{var=target.somevariable; ...}
    - setvariable{var=somevariable;scope=target; ...}

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.

Mechanic Description
SetVariable Initializes and sets a variable.
SetVariableLocation Sets a variable, whose value depends on the target location.
VariableUnset Unsets the variable.
VariableAdd Adds to a numeric variable.
VariableSubtract Subtracts from a numeric variable.
VariableMath Lets you do calculations with numeric variables.

Variable Conditions

Condition Description
Variable Equals Checks if a variable equals a given value.
Variable Is Set Checks if a variable is set.
Variable In Range Checks if a number variable is within a range.

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>.

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>.

    - message{m="Hello there, <target.var.title|wanderer>"} @trigger ~onInteract

In this example, the NPC would reply with "Hello there, wanderer" if right-clicked by somebody who had no "title" variable set on them. However, if we did this:

    - setVariable{var=target.title;value="Sir"} @trigger ~onInteract

...somewhere along the line, even with a different mob, the first mob 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

  Skills:
    - setvariable{var=caster.hello;type=STRING;val=example_name} @self
    - setvariable{var=caster.example_name;type=STRING;val=Hello There!} @self
    - message{m="<caster.var.<caster.var.hello>>"} @PIR{r=10}

In this example, the message would spell "Hello there!"

Mob Variables

Mobs can have some variable be already set once they spawn thanks to the Mob Variables field.

VariableZombie:
     Type: ZOMBIE
     Variables:
       SomeVariable: something
       AnIntVariable: int/2
       AFloatVariable: float/420.69
Clone repository
Home
Changelogs
Premium Features
Commands and Permissions
Mythic Add-ons
Compatible Plugins
API Information
Config Files

Guides
  • Troubleshooting
  • FAQ / Common Issues
  • Examples
Packs

MythicScribe MythicScribe - VSCode Extension

Mobs
  • Mob Options
    • Display Options
  • Mob Levels
  • Mob Factions
  • Power Scaling
  • Damage Modifiers
  • Equipment
  • BossBar
  • Custom AI
  • Custom Kill Messages
  • Threat Tables
  • Immunity Tables
  • Templates
  • Vanilla Overrides
  • Extra: Disguises
  • Extra: ModelEngine

Skills
  • Mechanics
    • Mechanics by Tag
  • Targeters
    • Filters
  • Triggers
  • Conditions
    • In-line conditions
  • Metaskills
  • Placeholders
  • Variables

Items
  • Options
  • Attributes
  • Enchantments
  • Potions
  • Banner Layers
  • Firework

Drops & DropTables
  • Drops
  • DropTables
  • FancyDrops

Spawning
  • Spawners
  • Random Spawns

Stats
  • Custom Stat Options
  • Modifiers
  • Built in Stats

Other
  • Particles Types
  • Audience
  • Equipment Slots
  • Pins
Technical
  • Math
  • Item Matcher
  • Operations
    • Attribute Operations
    • Stats Modifiers
  • SkillTree
  • Advanced User Guides and Techniques