BYOND Developer Wiki
Register
Advertisement
DM Reference Entry This page contains an entry from the official DM Reference.

Format[]

New(loc)
(supports named arguments)

When[]

Called when the object is created.

Args[]

loc: The initial location.

Default action[]

None.

Description[]

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 arguments[]

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.

Example[]

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().

Example[]

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 also[]

  • New proc (datum)
  • new proc


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