Manual:DIL Manual/sact()

From DikuMUD Wiki
Jump to navigation Jump to search

sact()

Function (string). Gives the text an act() would show, instead of sending it.

sact(text : string, show : integer, a1 : unitptr or string, a2 : unitptr or string,
     a3 : unitptr or string, to : integer)

Takes the same arguments as act() and fills in the $1n, $2m, $3t... codes the same way, but returns the text as one character would see it, so that it can be built into a longer message. That character is the one the act() is about: a3 for TO_VICT, a1 for TO_CHAR and TO_ALL. The names come out as that character sees them ("someone" for what they can't see).

Parameters

Name Type Meaning
text string The text with its $ codes.
show integer A_SOMEONE, A_HIDEINV, A_ALWAYS or A_RAW, as in act().
a1 unitptr or string The actor, $1.
a2 unitptr or string $2, or null.
a3 unitptr or string $3, or null.
to integer TO_CHAR, TO_VICT or TO_ALL (vme/include/vme.h).

Returns

String: the text with the codes filled in and the first letter (after any leading HTML tags) made a capital. Unlike act() it adds no <br/>.

It is "" when the character would not get the act(): a string or a non-character in their place, asleep (with A_SOMEONE), or unable to see the actor (with A_HIDEINV). TO_ROOM, TO_REST and TO_NOTVICT leave that character out, so they always give "".

It fails when that character (a1, or a3 for TO_VICT) is null, or when to is not one of the TO_ values. An unset text gives "".

Notes

  • Text longer than about 12,000 characters is cut short.
  • act() used as an expression gives the same text with <br/> added, and
 "" instead of failing when nobody is there.

Example

dilbegin string light_note(viewer : unitptr, item : unitptr);
var
   s : string;
code
{
   s := "";
   if (item.bright > 0)
      s := sact("Light comes from $2m.", A_SOMEONE, viewer, item, null, TO_CHAR);
   else if (item.bright < 0)
      s := sact("Darkness comes from $2m.", A_SOMEONE, viewer, item, null, TO_CHAR);
   return (s);
}
dilend

Builds a line about a light source as the viewer sees it, for a longer description, as baselook.zon does.

See also