MUD Command Language - wwestlake/Labyrinth GitHub Wiki
MUD Command Language
This MUD command language allows you to interact with the game environment, access user properties, and evaluate expressions. Below are the key elements and examples to help you use this language effectively.
1. Basic Syntax and Structure
Commands follow this structure:
- command [target] [arguments] [options]
Example
- attack @target with @weapon
This command initiates an attack on the specified target using the specified weapon.
Note: The /
at the start of the commands is not part of the language but is used only by the chat system to distinguish commands from chat messages. When placed in a command file (or storage object), commands do not have /
at the start.
2. Accessing User Properties
You can access various properties of the user or other entities using special tokens:
@user.health
β The user's current health.@target.name
β The target's name.@user.inventory
β The user's inventory list.
Example
- give @target @item if @user.health > 50
This command gives an item to the target if the user's health is above 50.
3. Expressions and Conditional Logic
You can evaluate expressions and use conditional logic in your commands:
- if (@user.health < 20) { say "You are low on health!" }
This command will make the user say "You are low on health!" if their health drops below 20.
4. Variables and Assignments
You can create variables to store values from the game environment:
- let currentHealth = @user.health
- let weapon = @user.weapon
- attack @target with @weapon if currentHealth > 50
This stores the user's current health and weapon in variables, and then attacks the target if the user's health is above 50.
5. Looping and Iteration
Looping constructs allow you to perform repeated actions:
- for each @enemy in @room.enemies { attack @enemy with @user.weapon }
This command attacks each enemy in the room using the user's weapon.
6. Built-in Functions
Built-in functions provide common tasks and can be used within commands:
@user.getClosestEnemy()
@room.getItems()
@user.heal(amount)
Example
- heal @user by @user.getItem("healingPotion").power
This heals the user by the power of the healing potion in their inventory.
7. Command Examples
Attack Command
- attack @enemy with @user.weapon if @enemy.distance < 10
This command attacks the enemy if they are within a distance of 10 units.
Item Transfer
- give @target @item if @user.inventory.has(@item)
This command gives an item to the target if the item is present in the user's inventory.
Broadcast Message
- broadcast "Server is restarting in 10 minutes!" if @server.time == "10:00 PM"
This command broadcasts a server-wide message if the server time is 10:00 PM.
Check and Act
- let health = @user.health
- if (health < 20) { say "You are low on health!" }
This command checks the user's health and makes them say a warning if their health is below 20.
Conclusion
This Markdown document outlines the structure and usage of the MUD command language, including syntax, user property access, conditional logic, looping, built-in functions, and various command examples. Itβs formatted for easy copy-pasting into your documentation.