Difference between revisions of "Manual:DIL Manual/setweight()"

From DikuMUD Wiki
Jump to navigation Jump to search
(checked against the compiler and the interpreter; example compiles)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
−
= setweight( u : unitptr, i : integer ) =
+
= setweight() =
 +
'''Obsolete.''' <code>setweight()</code> was removed from DIL in 2020; vmc no longer knows the name.
  
−
''' Parameters '''
+
Two procedures replace it:
−
  u : the unit on which you wish to alter the weight.
+
* [[Manual:DIL Manual/set weight base|set_weight_base(u, w)]] sets the unit's own (empty) weight, and changes its total weight and the weight of whatever holds it by the same amount;
−
  i : the new total weight
+
* [[Manual:DIL Manual/set weight|set_weight(u, w)]] sets the unit's total weight, and changes the weight of whatever holds it to match.
−
 
+
To add or take liquid from a drink container, change its weight with <code>set_weight()</code>.
−
''' Description '''
 
−
Use this procedure on for example drink-containers if you wish to
 
−
remove or add some liquid. This function will ensure the base-weight
 
−
is unchanged, and that the weight of the unit is altered according to
 
−
the integer i (positive or negative). To ensure weight consistency this
 
−
procedure also adjusts the weight of all units outside the altered unit.
 
−
 
 
−
For example in this hierarchy
 
−
 
 
−
  room
 
−
    npc
 
−
    pc
 
−
      bottle (b:1)
 
−
 
 
−
Setting the bottle to 5 will add 4 liquid weight to the bottle and
 
−
keep the base weight at 1. The pc and the room as well (npc remains unchanged)
 
−
 
 
−
IMPORTANT: Code review needed here. It looks like its a mess and we need one
 
−
function to change the base weight, and one function to change the contents
 
−
weight (e.g. adding liquids to a bottle).
 

Latest revision as of 23:25, 14 November 2026

setweight()

Obsolete. setweight() was removed from DIL in 2020; vmc no longer knows the name.

Two procedures replace it:

  • set_weight_base(u, w) sets the unit's own (empty) weight, and changes its total weight and the weight of whatever holds it by the same amount;
  • set_weight(u, w) sets the unit's total weight, and changes the weight of whatever holds it to match.

To add or take liquid from a drink container, change its weight with set_weight().