msgs_from_attr

Settable:
no
Arguments:
(1) character, string
(2) character, string, character
(3) character, string, object
(4) character, string, character, object
Return Value:
none

This function sends text strings to the specified character(s) and other players within the same room. It is similar to calling msg_character() and msg_room() together.

The arguments passed in are used as follows:

  1. First Character: The mobile performing the action (the Actor). This is also the mobile which has the message attributes specified in argument #2 below.
  2. Attribute Root Name String: The root name of the attributes to be used as format strings for the action messages. This function appends ".Actor" and ".Room" to the root name to determine the attribute values to display to the characters. If a second character (the victim) is specified, this function also looks for an attribute with ".Victim" appended to the root name. For a list of format codes that can be used in the attribute values, see msg_character.
  3. Second Character (optional): The second character serves as the the victim in the messages.
  4. Object (optional): An object used by the actor in the action.
An example script can be seen below:

    set_attr(%c, 'Action1.Actor',  'You slap $N with $p.'),
    set_attr(%c, 'Action1.Room',   '$n slaps $N with $p.'),
    set_attr(%c, 'Action1.Victim', '$n slaps you with $p.'),

    ...

    msgs_from_attr(%c, 'Action1', char_in_room(%c, 'Example'),
                    obj_in_inventory(%c, 'food'))

Assuming a mobile "a monkey" has this script and "a banana" in its inventory and that there is a character named "Example" in the room, the actor mobile sees:

    You slap Example with a banana.

The victim Example sees:

    A monkey slaps you with a banana.

The rest of the room sees:

    A monkey slaps Example with a banana.

The code can be made even more powerful when combining it with the random() function. The following script defines multiple actions and uses random() to choose one to perform.

    set_attr(%c, 'Action1.Actor',  'You slap $N with $p.'),
    set_attr(%c, 'Action1.Room',   '$n slaps $N with $p.'),
    set_attr(%c, 'Action1.Victim', '$n slaps you with $p.'),
    set_attr(%c, 'Action2.Actor',  'You poke $N with $p.'),
    set_attr(%c, 'Action2.Room',   '$n pokes $N with $p.'),
    set_attr(%c, 'Action2.Victim', '$n pokes you with $p.'),
    set_attr(%c, 'Action3.Actor',  'You pretend to give $p to $N.'),
    set_attr(%c, 'Action3.Room',   '$n pretends to give $p to $N.'),
    set_attr(%c, 'Action3.Victim', '$n pretends to give you $p.'),

    ...

    msgs_from_attr(%c, 'Action' + random(1, 3), char_in_room(%c, 'Example'),
                    obj_in_inventory(%c, 'food'))