[Package Index | Mudlib Index | Effect Index]
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
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;
}
.
varargs int add_object(string name,
int max_per_reset,
string display_as)
This method is used to add an item to the storage.
When this method is called, create_object() is called
(with the object name as an arg) in the inheriting file.
If no object is returned by that function,
the name is cloned with clone_object(), and failing that
request_item() is called in the armoury against the name.
This method makes add_weapon() and add_armour() obsolete.
add_object( "frog", 1 + random( 3 ) ); // This will try and create an object called frog, in the order mentioned // above
add_object( "/obj/food/apple.food", 0 ); // Add unlimited numbers of apples.
object query_cont()This method returns the container which is used to keep one copy of each items in storage.
int * query_items_left(string * names)This function can be used to check the quantity left of an array of items. It returns a parallel array of integers. In other words the array it returns contains the numbers of stock in array positions corresponding to the array positions of the objects it was passed.
query_items_left( ({ "banana" , "melon" }) )
would return ({ 12 , 6 }) if there were 12 bananas and 6 melons left.
int query_num_items_left(object ob)Returns how more times object ob can be duplicated
int query_number_left(string name)This function returns the quantity of particular object available to be cloned on demand. In matching which object is the one in question it uses the short name of the object, which is passed as an argument to the function.
string query_object_domain()This method returns the domain the objects will be created from.
void set_object_domain(string domain)This method sets the domain the objects will be created from. The default objects will always be matched as well. So setting this will allow objects from the default of the specified armoury domain.
set_object_domain("cwc");
object create_real_object(object thing)The main point of entry. 'thing' should be an object already placed in the clone_on_demand store container via 'add_object'. This method then duplicates that object, replaces the original copy in the container with this new one, and returns the original which can be delt with as normal.