NAME
	add_weight - add to local weight of an object or living

SYNOPSIS
	int add_weight(int weight);

LOCATION
	/obj/living.c, /std/simple_container et al.

RETURN VALUE
	Non-zero value means that weight has been added to the object's
	total local weight.  A return value of 0 means that the object
        is 'full' or at its 'carrying capacity'.  

DESCRIPTION
	add_weight is generally called when an object is going to be
	given to a monster or player, or inserted into a container.
	It is used both to test if the player or container can 
	carry more, and if so to add the weight of the given object
	to the player or container's total weight.

NOTES
	If you use move_object(E) to move an object to a container or
	especially to a player, be sure to call add_weight() or else
	their total carried weight will be flubbed up.  Likewise, if
	add_weight() returns 0, do not move the object to the container
	or player.

	An alternative to the move_object / add_weight combination is
	the efun transfer(E) which automatically calls add_weight.
  
EXAMPLES
	The following example is from an imaginary shop:

	torch = clone_object("/obj/torch");
        if ( !this_player()->add_weight(torch->query_weight()) ) {
	    write("The shopkeeper says: You can't carry anymore!\n"+
	          "He lays it on the ground in front of you.\n");
	    move_object(torch, this_object());
	} else {
	    write("The shopkeeper hands you the torch.\n");
	    move_object(torch, this_player());
	}

SEE ALSO
	transfer(E), query_weight(L), can_put_and_get(L)

Help topics available:
add_hook add_weight can_put_and_get clean_up drop
extra_look get heart_beat id init
init_arg is_armour is_money is_weapon long
query_auto_load query_hook query_long query_name query_prevent_move_from_statue
remove_hook reset set_long set_name set_short
short

[START|BACK ]




[ NannyMuds main page | FAQ | Contact us ]

You are guest number 176 since November 2019.
This file was last modified: June 2000.