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:
You are guest number 176 since November 2019.
This file was last modified: June 2000.