FANDOM


BYOND Environment This page contains an entry from the official DM Reference.

FormatEdit

New(loc)
(supports named arguments)

WhenEdit

Called when the object is created.

ArgsEdit

loc: The initial location.

Default actionEdit

None.

DescriptionEdit

By the time New() is called, the object has already been created at the specified location and all of its variables have been initialized. You can perform additional initialization by overriding this procedure.

loc in named argumentsEdit

Since the initial location parameter passed to new() is applied before New() is even called, there is some special handling of the loc variable when using named arguments in a call. Normally, if a procedure is overridden, named arguments in a call are matched against those in the the overridden definition. In this case, however, the loc parameter name is hard-coded. Regardless of what you call the first argument in your definition of New(), the initial location will be taken from the first positional argument, or from the argument named loc if there are no positional arguments.

ExampleEdit

The following example does some extra initialization that is not possible in the variable definition section, because it requires a runtime evaluation. This is a common reason to use New().

ExampleEdit

mob
   var
      birthdate //time stamp
   New()
      birthdate = world.realtime
      return ..()
   verb/look()
      set src in view()
      usr << "[src] was born on [time2text(birthdate,"DD-MMM-YYYY")]."

See alsoEdit


Pager envelope This page is a snippet. You can help by adding more sections with relevant information.