Creating a Server-Side Slash Command

From Multiverse

Jump to: navigation, search

Contents

Overview

Slash commands are commands that can be executed by the user inside the chat window. Slash commands are given this name due to the fact they all begin with a "/". For example "/Fly". Slash commands can invoke 1) a client-side or 2) a server-side. This example will show how to create a server-side slash commnd.

This tutorial is meant to be part of a series of tutorials which allow a user to drop an item to the ground. In this tutorial, we will create the slash command to allow a user to drop an item.

For the purposes of this tutorial, all instructions are based upon the default installation of the Multiverse Server on a remote LinuxCentOS server and the default MultiverseClient installation on a Windows Vista PC. The asset repository is a remote Microsoft server.


Stop the Server

  • Connect to your server: I used the Putty tool to create an SSH connection from my computer to the remote Multiverse server.
  • Stop the server: Once connected, I logged in as a super user and changed to the /usr/multiverse/bin directory. Then executed the ./multiverse.sh stop command to stop the server.

Image:StoppingServer.png

Create the slash command

  • Change to the world config directory:
    • For sampleworld which was installed by default enter cd ../config/sampleworld
  • Find the file holding the slash commands:
    • Take a look at the directory contents by entering ls.
    • In this drectory you will find the extensions_proxy.py file. This file holds the slash commands for your world.
  • Backup the file:
    • First let's make a backup of the file by typing cp extensions_proxy.py extensions_proxy.backup .
  • Edit the File:
    • Edit the 'extensions_proxy.py' file. I use nano to do this, so enter nano extensions_proxy.py to start the nano editor.

Image:ChangeToConfigDirectory.png

Image:BackingUpFile.png

    • Now nano may not be the best program for doing file editing, but as I am new to Linux, this is all I know. If anyone has any recommendations, please PM LuckyWolf19. With nano you can scroll through the file with the up and down arrow keys (also could page via ctrl-Y and ctrl-V). Scroll to the very bottom and you will see a list of proxyPlugin.registerCommand lines of code. At the bottom of this list, add your new slash command and a reference to class uing this logic:

..proxyPlugin.registerCommand("/YourSlashName", YourSlashNameEventHandler())

    • So for this tutorial we need a slash command to allow a user to drop an item so I have added the line:

..proxyPlugin.registerCommand("/itemdrop", ItemDropCommand())

    • Keep the file in edit mode as we need it in the next section.

Image:RegisterSlashCommand.png

Create Event Handler for Slash Command

  • Add Event Handler
    • Add a class to handle slash command event after it is fired by the user. You should still be in edit mode of the extensions_proxy.py file from the previous section. Scroll toward the end of the file and you will notice that their are class names that match the registered slash command names. For example, scroll until you see the class shrug line. As we need to create an event to handle the registered slash command, let's copy the one from class shrug. Place this new class under the class shrug and give he class the name you used in the above section. For our example, this should be class ItemDropCommand.
    • NOTE:When copying the shrug class, ensure that you duplicated exactly everything. Even the case of the text matters here. Now you may be asking "why are we copying another class exactly?". Testing silly.
    • To save the file, hit ctrl-x, then Y to save, do not change the file name, hit enter key.

Image:CreateSlashCommandEventHandler1.png

Image:CreateSlashCommandEventHandler2.png

Image:CreateSlashCommandEventHandler3.png

Side Note: It seems that I fat finger a lot and the development environment and debuggers are not as robust as Microsoft Visual Studios, so I have to create a lot of test points. I noticed that I failed to use the correct case in one command. When starting the server, it appeared to load correctly, but when logging in with the client, the client crashed after selection of a character and entering into the world. A quick look at the client trace log shows that the server disconnected the client.

Start the Multiverse Server

  • Type cd /usr/multiverse/bin
  • Type ./multiverse.sh -v start
  • Wait for the confirmation that the server started or not. This can take as long as 120 seconds. If the server did not start, validate the file edits were correct. I had to do this a few times due to fat fingering commands. Note that just because the server started correctly, it does not imply the slash command was entered correctly.

Image:ConfirmServerStarted.png

Test the slash command on the client

Now start your client and connect to your world. If the client crashes or just disappears then most likely your slash commands are not working correct. Review the above sections. If your world starts, type in a known good slash command such as /shrug and your PC should do a shrug animation. If this worked, next do a /itemdrop slash command and again your PC should do the shrug animation(Note: This may not work with the human female character). If neither of these worked, then you have an issue with the above sections.

Image:TestingSlashCommand.png

Personal tools