Information and ‘Pulse’ From Prompts

Getting data from the mud prompt

The regular prompts of a mud like Nukefire provide both information and a notice that some event has happened or command is being responded to.

As a minimum, the typical D&D values of current hitpoints, mana, and movement points are included. The fact of a prompt being issued also signals completion of delivery of a package of information (lines), so it provides a convenient time to look at all information currently available and make a decision about what to do next. Unlike some other examples, this is a very basic trigger which uses no features particular to CMUD other than flagging the trigger so that it will fire on a prompt (line with no carriage return on the end). Clients such as Tintin fire in that situation by default.

The basic parts of the prompt can be captured with the following regex pattern while leaving room for the additional data later:

^< ([-]{0,1}[0-9]+)H ([-]{0,1}[0-9]+)M ([-]{0,1}[0-9]+)V .*>

To simply store the hp, mana, and mv values we could use a trigger such as:

#TRIGGER {^< ([-]{0,1}[0-9]+)H ([-]{0,1}[0-9]+)M ([-]{0,1}[0-9]+)V .*>} {#VAR hp %1;#VAR mana %2;#VAR move %3} "" "regex|prompt"

In practice, to trigger processing we also want to call an alias which will let the bot decide if there’s an action which must be taken. This tutorial only covers the initial creation; later examples will demonstrate using this opportunity to take actions such as healing or special attacks.

For now, we’ll leave the alias dopulse empty as a placeholder:

#TRIGGER {^< ([-]{0,1}[0-9]+)H ([-]{0,1}[0-9]+)M ([-]{0,1}[0-9]+)V .*>} {#VAR hp %1;#VAR mana %2;#VAR move %3;dopulse} "" "regex|prompt"
#ALIAS dopulse {}

Discover more from OutGamer

Subscribe now to keep reading and get access to the full archive.

Continue reading