Preparing your Game

This documentation outlines the requirements to setup a custom game and get your MUD game running with a little customization done to it

If you read through the first document regarding setting up the server, you should now be ready to begin building your own Game using the Mud Designer Engine. We will be spending our time inside the Scripts folder found in the save directory that your MudServer.exe is installed in. Go inside the scripts directory and create a new Text file, named MyGame.cs
Once it's created you can open the file and place the following code inside of it.
public class MyGame : Game
 public MyGame() : base()
     GameTitle = "My very own MUD!";

Now that you have finished with that, you can start your server. If everything went right and you have no errors, go ahead and open a Telnet client and attempt to enter the game. You should see your "My Very Own MUD!" printed in the client along with the prompt to enter your name. If you enter your name then the game will place you into the Abyss room due to no Environments being created yet.

Quick Run-down

The first thing you do in a script is give the class that your script file contains, a name.
public class MyGame() : base()

In this case we called it MyGame and used a colon to tell the script that we want to inherit from the internal engine class called Game. What's that do? It allows you to write a modified version of the existing game manager, or add onto it in what ever way you want. Your MyGame will contain all of the properties and methods that the parent class Game contains, along with your own content.
Important: In order for your MyGame to be used in place of the default engine Game manager, you MUST inherit from Game. If you do not inherit from Game then the engine will skip over your script, assuming that it's an object to be used within the game by another script at a later date.
If you're a .NET developer, you'll notice that this script does not reside within a namespace; that's because the engine automatically assigns a namespace to the class. The engine manages the scripts and assigns it to a default internal namespace that was choose for the scripts. If you attempt to place your class within a namespace manually, the compiling of the script will fail.

Next we have to build our Constructor which is always called every-time the script is instanced. It is here that we will modify the properties that the Game Type contains and allows us to make the game our own custom MUD.
public MyGame() : base()
    GameTitle = "My very own MUD!";

GameTitle is not the only property available within the Game Type that you can use, and I will break that down for you in a moment. The GameTitle sets the name of your MUD and will be displayed through-out your MUD game whenever the engine needs to display the title of the MUD.

Property breakdown

Below is a breakdown of all available properties that you can change within your constructor in order to make the game yours

Game Manager Setup
  • IsMultiplayer
    • Usage: IsMultiplayer = true;
    • Description: Allows you to enable or disable multiplayer support. If set to true then the Server will run in dedicated server mode. If set to false then the Server actually runs as an offline client in single player mode
  • IsRunning
    • Usage:
                  if (IsRunning)
  • Description: This property is ReadOnly and cannot be modified by a script. It allows a script to check if the engine is currently running. Most scripts won't need this, but any script inheriting from BaseCharacter or Game might use it. Characters can still exist for a short period of time during server shut down and checking IsRunning might be needed at times to prevent errors during server shut down.
  • DataPaths
    • Usage: DataPaths.Players = "SavedPlayers";
    • Usage: DataPaths.Environments = "GameWorld";
    • Description: DataPaths is a property that lets you set what folders you want to save various data content to. In the Usage example, we set the folder for saving players as SavedPlayers. The engine uses these values to determine where to save your MUD content. At this time only the DataPaths.Players field is supported. The Environment Field will be supported once saving of Environments is implemented.
  • ScriptEngine
    • Usage: ScriptEngine.Initialize();
    • Description: Can be called to re-initialize the scripts, once IsRunning is set to true by the engine however, it is recommended to not re-initialize the engine as the compiled scripts and libraries are held in memory and can not be overwrote.
    • Usage: ScriptEngine.Compile();
    • Description: This is used to re-compile all of the scripts found within ScriptEngine.ScriptPath folder. Again, don't use this once IsRunning is set to true.
    • Usage: ScriptEngine.ScriptPath = "Scripts";
    • Description: This sets the location of where your scripts are stored so the compiler can get access to them. The server loads this value from settings.ini though, it is best to modify the settings file if you want a different directory.
    • Note The Script Engine contains several other properties and methods and I will cover those in a later document.

Game Information Settings
  • CompanyName
    • Usage: CompanyName = "My Company!";
    • Description: Lets you set the name of your company for this game.
  • Website
    • Usage: Website = "";
    • Description: Lets you set the website of your game.
  • GameTitle
    • Usage: GameTitle = "My MUD Game!";
    • Description: Assigns the name of your MUD Game.
  • Version
    • Usage: Version = "1.0";
    • Description: Lets you assign the version of your MUD. This is displayed during client connections.
  • InitialRealm
    • Usage: InitialRealm = new Realm();
    • Description: Allows you to reference either a new Realm, or a pre-existing Realm created elsewhere in other scripts. The InitialRealm.InitialZone.InitialRoom will be a new players starting point.
  • RealmCollection
    • Usage:
      foreach (Realm r in RealmCollection)
          if (r.Name == "MyRealm")
  • Description: RealmCollection is a collection of all the Games Realms. You can search every Realm, every Zone within that Realm or every Room within a Zone contained within a Realm.
  • PlayerCollection
    • usage: PlayerCollection = new BaseCharacter[MaximumPlayers];
    • Description: Creates a new array of players with the array size being set to the servers MaximumPlayers value. Creating the array Must happen within the Constructor if you need to do so, however the BaseCharacter array is automatically created within the engine for you. The only time you will need to re-reference the array is if you want to use a Player script created by you instead of the engines BaseCharacter Type.
    • Usage: PlayerCollection = new MyPlayer[MaximumPlayers];
    • Allows you to use a user created script that inherits from BaseCharacter.
  • MaximumPlayers
    • Usage: MaximumPlayers = 1000;
    • Description: Sets the maximum number of players to a number that you choose to support on your server.

  • World.AddRealm
    • Usage: World.AddRealm(MyRealm);
    • Description: Adds a user created realm to the game world. Note: This replaces the Alpha 1.1 Game.AddRealm(), now use Game.World.AddRealm

Putting it all together

You can write your MyGame script to look like this and have a customized game at your fingertips!
public class MyGame : Game
    public MyGame()
        : base()
     GameTitle = "My very own MUD!";
     IsMultiplayer = true;

     CompanyName = "My Company!";
     Website = "Http://";
     Version = "1.0";
     MaximumPlayers = 5000;

     Realm myRealm = new Realm(this);


Just because we only showed how to modify the Game properties does not mean that you can't add your own! You can add your own properties and or methods to do what ever it is that you need done during the life of your game.

Note that creating Realms and other environments will be covered in a different document

That concludes this tutorial. Subscribe to it so that you can be informed of new additions to the property and method list as well as more information on building the Game class at a later date!

Last edited Aug 15, 2010 at 7:41 PM by Scionwest, version 12


No comments yet.