Code: Select all
Within Javascript based triggers and aliases, you can interact with the mud and the client using the gwc object.
gwc.connection.send(output, [resolve aliases])
Send command to Genesis. Supply true as the second argument to enable alias resolving.
gwc.output.color(foreground, background)
Changes the color of the last line received from the mud. You can omit the background color argument if you do not want to change it.
gwc.output.append(text)
Adds a new line to the output window with the specified text.
gwc.output.replace(searchvalue, newvalue. [use html])
Perform a string replace on the last output line of the mud. Replace uses a string replace on either the html or text value (depending on the third argument).
gwc.userdata
Object available to store information. All data contained is persisted to the server and will be available as soon as you login.
Note that the userdata object is persisted after the scripts have fired. If you adjust the contents of the userdata object outside of this (for instance by using a setTimeout), it will not be stored until a new trigger has fired.
gwc.gmcp.data
Object containing the stored GMCP information. This object is automatically updated as new information is received. However, in case of GMCP triggers the new data has not yet been applied (the newest data can be accessed through the 'args' variable.)
| data.character.statusvars | Mapping of variables to readable names | | data.character.status | Contains the latest values of the variables | | data.character.vitals | Contains the latest readings for your character's vitals | | data.room | Contains the information about your current room |
For more information about GMCP, see the documentation
Code: Select all
Generic Mud Communication Protocol
Genesis supports the Generic Mud Communication Protocol, or GMCP, to pass easily parsable information to your mudclient. It's an extension to the normal telnet protocol, and sends messages invisible to the user (even when running a client that do not support GMCP).
The primary purpose of GMCP is to improve the availability of information relevant to your game without providing players with a distinct advantage. As such, any information passed through the protocol will have the same precision / textual representation as through the normal text interface.
At the moment of writing, the Mudlet and CMud client (as of version 3.22) support the GMCP protocol. This only includes the handling of the messages and a variety of the core features that subscribe to the broad- casts provided by the mudlib. It is up to the player to add trigers and or other scripts to use the provided information.
GMCP Messages are formed of a package name, and an optional JSON payload separated by a space. Normally the mud client will handle the parsing and will provide the information in it's native format to the scripts. For exact details, you will need to look into the documentation of your mud- client.
Broadcasts are only sent when you are subscribed to the packages to which they belong. Packages names follow a parent -> child format, which each level separated by a dot. If you subscribe to the Core package, you will receive all broadcasts for packages that start with Core, if you were to subscribe to Core.Subpackage, you would only get those and it's children.
Package and message names are not case sensitive. JSON key names are case sensitive.
Core Broadcasts
---------------
Core.Goodbye
Send upon disconnect. Payload is a string detailing the reasons
for the disconnect.
Char Broadcasts
---------------
Char.StatusVars
Send upon subscription to the Char package, contains and object
as payload where each key value pair contains the technical key
(used in Char.Status) and a text value containing a more humanly
readable caption.
Example: { "level" : "Level", "race" : "Race" }
Char.Status
Upon subscription to the Char package, an initial set of status
variables is sent. After this initial broadcast, subsequent
broadcasts will only contain changed variables.
Example: { "level" : "myth", "name" : "Eowul", "race" : "elf" }
At the time of writing, the following status variables are
available:
name, level, gender, race, strength, constitution,
discipline, intelligence, dexterity or wisdom, alignment,
mail
Char.Vitals
Similar to the status broadcast, the initial broadcast will
contain all initial values, subsequent broadcasts include only
the updated values.
Example: { "health" : "very hurt", "mana" : "in full vigour" }
Currently the following information is included in the vitals
broadcast:
food, drink, fatigue, mana, health, intoxication
Client commands
---------------
Core.Hello
First message send after GMCP has been negotiated. Payload is an
object, containing the keys "client" and "version".
Example: { "client" : "GMC", "version" : "1.0.1" }
Core.Supports.Set
Core.Supports.Add
Core.Supports.Remove
Commands to subscribe to the various broadcasts offered by the
mudib (see supported packages), the payload is an array with
strings, containing the packages and versions.
Example: [ "Core 1", "Room 1" ]
If the version number is ommited, version 1 is assumed. The set
command replaces the previous list of subscribed packages. Add
adds the new packages to the existing list, overwriting the
version of existing modules with the new one supplied (even if
it is lower than the existing version).
You can unsubscribe from broadcasts using the Core.Supports.Remove
command. Version numbers are optional and will be ignored when
supplied.
Core.Ping
Check to see if the server is still responding. A Core.Ping
message will be sent in reply, containing no payload.
Char.Login
Only valid while no user is logged in. Contains an object as
payload with keys name and password. Upon successfull validation
of the credentials, the user is logged in.
Example: { "name" : "Eowul", "password" : "topsecret" }
Char.Skills.Get
Request an up to date skill-list for the logged in player. Data
is returned based on the parameters given.
When no parameters are supplied, a list of all known skill-
groups is returned using the Char.Skills.Groups package name and
containing an array of strings as the payload.
Example: [ "General", "Weapon" ]
In order to get the skills for a specific group (or using 'All'
to get all available skills regardless of group), supply an
object as the commmands payload, using 'group' as key and the
group name as value. This will return a list of skills and their
values through the Char.Skills.List package. The payload is an
object with the group name repeated with the 'group' key, and
the list of skills (another object) using the 'list' key.
Example: { "group" : "General",
"list" : { "appraise object" : 10,
"appraise value" : 15 }}
Unlike most other commands, the numerical value of the skill is
returned as there is a one to one mapping with it's textual
counterpart.
Should you only be interested in the values of a single skill,
you can supply an object as payload with both a group and a name
key, and the skill data will be returned using the
Char.Skills.Info packagename, with an object as payload, containing
the group, name, info and value keys.
Example: { "group" : "General", "name" : "appraise object",
"info" : "appraise object", "skill" : 15 }