[Package Index | Mudlib Index | Effect Index]

File /std/shops/inherit/clone_on_demand.c

This is a inheritable that provides an efficient way of storing lots of items. Only one copy of the item is effectively in storage and everytime one is removed, an exact copy is duplicated and put back in the store. Objects are added to the store via add_object(). The actual storage container object can be returned by query_cont() and this container should be searched when you want to find what objects the store contains.

Any object can inherit this, and methods should be put in place in the inheriting file that end up calling create_real_object() which will sort out duplicating the item and returning an object pointer to the one you can deal with.

See also:
add_object .c

Written by Pinkfish Aquilo

Example

inherit "clone_on_demand";
int do_buy( objects *obs );

void setup(){
  set_name("shop");
  set_short("widget shop");
  add_object( "sprocket" );
}

object create_object( string arg ){
  if( arg == "sprocket" )
    return clone_object( "/path/of/sprocket" );
}

void init(){
  add_command("buy", "");
}

int do_buy( object *obs ){
  object ob;
  foreach(ob in obs){
    widget = create_real_object(ob);
    widget->move( this_player() );
  }
  add_succeeded_mess( "$N buy$s $I.\n", obs );
  return 1;
}

Includes

This class includes the following files /include/armoury.h

Method index

Public Functions

These are functions that everyone can access.

.