MUDBRINGER
Menu

Audience: New scripting users

Reference: Read the Scripting Basics and Wizards guide first for core syntax, wildcards, variables, procedures, and wizard navigation.

What Is a Variable?

A variable is a saved value you can name and reuse. Instead of typing the same name or number over and over, you store it once and refer to it by name anywhere in your commands.

In MudBringer, you create variables with /variable and read them by putting a $ before the name.

Setting and Using a Variable

Steps:

  1. Give your variable a short name.
  2. Set it to a value.
  3. Use $name anywhere in a command.

Example — store a target name:

/variable {target} {goblin}

Now use it in an alias:

/alias {att} {attack $target} {combat}

Type att and the client sends attack goblin. To see all your variables:

/variables

[TIP] Name variables for what they hold. $target, $home, $healer are much easier to remember than $x or $v1.

Changing a Variable

Set it again with the new value. The old value is replaced.

Example:

/variable {target} {orc}

Now $target is orc. Your att alias automatically sends attack orc without any other changes.

Using Variables in Actions

Variables combine naturally with actions. An action can store something it captures so your next command picks it up.

Example — remember who just attacked you:

/action {attacks you} {/variable {target} {%0}} {combat}

When the server sends a line containing “attacks you”, the client saves the matched name into $target automatically.

Seeing It in Action

Try this sequence from scratch:

/variable {target} {goblin}
/alias {att} {attack $target} {combat}
/alias {loot} {get all from corpse of $target} {combat}
/variables

Type att to attack, loot to collect. Both point to whatever is stored in $target. Change targets without editing the aliases:

/variable {target} {troll}

Both aliases now target troll. This is the core power of variables — write the command once, change the data separately.

Removing a Variable

When you no longer need a variable:

/unvariable {target}

Quick Reference

Variable commands:

  • /variable {name} {value} : Set or update a variable.
  • /variables : List all current variables.
  • /unvariable {name} : Delete a variable.

Reading a variable:

  • Use $name in any command to insert its value.

Version Notes

  • Part of Batch 1 documentation rollout.