Project

Profile

Help

Alias » History » Sprint/Milestone 3

Vincent Le Goff, 11/22/2016 02:44 AM

1 1 Vincent Le Goff
h1. Aliases in CocoMUD
2 1 Vincent Le Goff
3 1 Vincent Le Goff
Aliases are a special feature of MUD clients that can be used to shorten commands.  An alias is itself a command, but instead of being sent to the server as is, it is first analyzed by the client, modified and extended if necessary.  Some aliases don't leave the client at all.
4 1 Vincent Le Goff
5 1 Vincent Le Goff
This document will introduce the concept of aliases and explain how to create and manage them.
6 1 Vincent Le Goff
7 2 Vincent Le Goff
{{toc}}
8 2 Vincent Le Goff
9 1 Vincent Le Goff
h2. Adding an alias
10 1 Vincent Le Goff
11 1 Vincent Le Goff
You can create an alias using the interface or through the [[#SharpScript-syntax|SharpScript syntax]].  The interface being easier at first glance, it will be explained in first.
12 1 Vincent Le Goff
13 1 Vincent Le Goff
h3. Through the dialog box
14 1 Vincent Le Goff
15 1 Vincent Le Goff
In the menu bar, select Game -> Aliases.  You will find yourself in a dialog listing the current aliases for this world.  Note that aliases are usually created in a world, being shared by characters.  This will change in future versions.
16 1 Vincent Le Goff
17 1 Vincent Le Goff
In this dialog, you can add, edit or remove aliases.  By default, the list of alias will most likely be empty, so you can select *Add* to add one.
18 1 Vincent Le Goff
19 1 Vincent Le Goff
You will then have to choose an alias name.  This is the command you want to create, basically.  In this example, we're going to create a "tts" alias that enables/disables the text-to-speech in the client.
20 1 Vincent Le Goff
21 1 Vincent Le Goff
Enter "tts" in this field.  When you press Tab, you will be presented with a list of actions to be performed when you type this command.  For instance, you may want the "rs" alias to send two commands at the MUD server:  "reload" and "shoot".  In this case, you would select the action named "send one or more commands to the server".
22 1 Vincent Le Goff
23 1 Vincent Le Goff
In our example, we'll select "Enable/Disable TTS", since that's what we want to do when we type "tts" in the client.  Tab again and click the *Add action* button.
24 1 Vincent Le Goff
25 1 Vincent Le Goff
You will be prompted with a dialog asking you to review parameters to this action.  For this action, there is none, so you can press "OK" to add the action.
26 1 Vincent Le Goff
27 1 Vincent Le Goff
The new action has been added.  The cursor will be put in the list of current actions linked to this alias.  You can link an alias with several actions (even with the same action several times, to play several sounds, for instance, although it might not be very useful).
28 1 Vincent Le Goff
29 1 Vincent Le Goff
To summarize the dialog when you add or edit an alias, you will find:
30 1 Vincent Le Goff
31 1 Vincent Le Goff
* The alias' name.
32 1 Vincent Le Goff
* A list of actions that can be linked.
33 1 Vincent Le Goff
* The button to add this action.
34 1 Vincent Le Goff
* A list of actions that are currently linked with this alias.
35 1 Vincent Le Goff
* A button to edit the selected line of action.
36 1 Vincent Le Goff
* A button to remove this line of action from the alias.
37 1 Vincent Le Goff
38 1 Vincent Le Goff
You should get accustomed to this dialog, as it will be present for most configuration involving SharpScript.  It is, in fact, the SharpScript editor that do not ask you to edit the configuration file by hand.  You will find more examples in the rest of the documentation.
39 1 Vincent Le Goff
40 1 Vincent Le Goff
To save the alias, don't forget to select "OK" several times, until the dialog box is closed.
41 1 Vincent Le Goff
42 1 Vincent Le Goff
If you then type "tts" in the client, you should see (and hear):
43 1 Vincent Le Goff
44 1 Vincent Le Goff
<pre>
45 1 Vincent Le Goff
TTS off.
46 1 Vincent Le Goff
</pre>
47 1 Vincent Le Goff
48 1 Vincent Le Goff
Type it again to switch it on.  The text-to-speech will be disabled or enabled using this alias.
49 1 Vincent Le Goff
50 1 Vincent Le Goff
h3. SharpScript syntax
51 1 Vincent Le Goff
52 1 Vincent Le Goff
You can also add an alias by editing your configuration file and adding it there.  This solution might be preferred by some.
53 1 Vincent Le Goff
54 1 Vincent Le Goff
Open your configuration file for this world.  You will find it in the "worlds" directory.  Select the directory containing your world, then the "config.set" file.  You can open it with a small editor like notepad.
55 1 Vincent Le Goff
56 1 Vincent Le Goff
To add an alias, use the @#alias@ action with two parameters:
57 1 Vincent Le Goff
58 1 Vincent Le Goff
* The alias' name.
59 1 Vincent Le Goff
* The alias' actions to be performed.
60 1 Vincent Le Goff
61 1 Vincent Le Goff
If you want to create a "tts" alias that will enable or disable the text-to-speech, add in your file the following line:
62 1 Vincent Le Goff
63 1 Vincent Le Goff
<pre>
64 1 Vincent Le Goff
#alias tts #tts
65 1 Vincent Le Goff
</pre>
66 1 Vincent Le Goff
67 1 Vincent Le Goff
If you have several actions, don't hesitate to describe the alias on several lines:
68 1 Vincent Le Goff
69 1 Vincent Le Goff
<pre>
70 1 Vincent Le Goff
#alias go {
71 1 Vincent Le Goff
    #play sounds/go.wav
72 1 Vincent Le Goff
    #say {Here we go!}
73 1 Vincent Le Goff
}
74 1 Vincent Le Goff
</pre>
75 1 Vincent Le Goff
76 1 Vincent Le Goff
For an explanation of the SharpScript syntax, refer to [[SharpScript|the section describing SharpScript]].
77 1 Vincent Le Goff
78 1 Vincent Le Goff
h2. Editing an alias
79 1 Vincent Le Goff
80 1 Vincent Le Goff
At any time, whether you have created the alias in the dialog box or in the configuration file, you can edit it.  If you have created it in the configuration file, you can modify it through the interface, and vice versa.
81 1 Vincent Le Goff
82 1 Vincent Le Goff
Remember that the configuration is loaded when you select the world, which will most likely happen when you open the software.  If you modify the configuration file, restart the software to take it into account.
83 1 Vincent Le Goff
84 1 Vincent Le Goff
h2. Removing an alias
85 1 Vincent Le Goff
86 1 Vincent Le Goff
You can remove an alias through the dialog box or by editing the configuration file.  If you do it through the dialog box, remember the changes will be lost if you close the dialog but do not use the "OK" button.