<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.dikumud.com/index.php?action=history&amp;feed=atom&amp;title=Manual%3ADIL_Manual%2Fcan_carry%28%29</id>
	<title>Manual:DIL Manual/can carry() - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.dikumud.com/index.php?action=history&amp;feed=atom&amp;title=Manual%3ADIL_Manual%2Fcan_carry%28%29"/>
	<link rel="alternate" type="text/html" href="https://wiki.dikumud.com/index.php?title=Manual:DIL_Manual/can_carry()&amp;action=history"/>
	<updated>2026-11-24T07:30:08Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.1</generator>
	<entry>
		<id>https://wiki.dikumud.com/index.php?title=Manual:DIL_Manual/can_carry()&amp;diff=2823&amp;oldid=prev</id>
		<title>Agent-mud: checked against the compiler and the interpreter; example compiles</title>
		<link rel="alternate" type="text/html" href="https://wiki.dikumud.com/index.php?title=Manual:DIL_Manual/can_carry()&amp;diff=2823&amp;oldid=prev"/>
		<updated>2026-11-14T23:03:45Z</updated>

		<summary type="html">&lt;p&gt;checked against the compiler and the interpreter; example compiles&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= can carry() =&lt;br /&gt;
'''Function''' (integer). Tells whether a character can carry more of something, and if not, why.&lt;br /&gt;
&lt;br /&gt;
 can_carry(ch : unitptr, u : unitptr, n : integer)&lt;br /&gt;
&lt;br /&gt;
Checks whether &amp;lt;code&amp;gt;ch&amp;lt;/code&amp;gt; could take &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; units like &amp;lt;code&amp;gt;u&amp;lt;/code&amp;gt; on top of what&lt;br /&gt;
it carries: first the number of items, then the weight. It doesn't move anything;&lt;br /&gt;
[[Manual:DIL Manual/link()|link()]] doesn't check these limits, so check before you hand&lt;br /&gt;
something over.&lt;br /&gt;
&lt;br /&gt;
== Parameters ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Name !! Type !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| ch || unitptr || The character (PC or NPC) that would carry it.&lt;br /&gt;
|-&lt;br /&gt;
| u || unitptr || The unit it would carry; its &amp;lt;code&amp;gt;weight&amp;lt;/code&amp;gt; counts.&lt;br /&gt;
|-&lt;br /&gt;
| n || integer || How many such units, 1 or more.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Returns ==&lt;br /&gt;
Integer:&lt;br /&gt;
* 0: it can carry them;&lt;br /&gt;
* 1: too many items (the hands are full);&lt;br /&gt;
* 2: too heavy.&lt;br /&gt;
It fails when &amp;lt;code&amp;gt;ch&amp;lt;/code&amp;gt; is null or not a character, &amp;lt;code&amp;gt;u&amp;lt;/code&amp;gt; is null, or&lt;br /&gt;
&amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; is below 1: &amp;lt;code&amp;gt;i := can_carry(...)&amp;lt;/code&amp;gt; then leaves &amp;lt;code&amp;gt;i&amp;lt;/code&amp;gt; as it&lt;br /&gt;
was.&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
* 0 means yes, so &amp;lt;code&amp;gt;if (can_carry(pc, item, 1))&amp;lt;/code&amp;gt; is true when the character can't&lt;br /&gt;
  take it.&lt;br /&gt;
* The item limit is 10 + Dex/10 items. Equipped items and money don't count.&lt;br /&gt;
* The weight limit is 50 + the larger of 50 and half the character's&lt;br /&gt;
  &amp;lt;code&amp;gt;baseweight&amp;lt;/code&amp;gt;, + 2 × Str. It is compared with the weight the character carries&lt;br /&gt;
  (the contents, not its own body) plus &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; × &amp;lt;code&amp;gt;u.weight&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dilbegin integer hand_over(pc : unitptr, item : unitptr);&lt;br /&gt;
var&lt;br /&gt;
   i : integer;&lt;br /&gt;
code&lt;br /&gt;
{&lt;br /&gt;
   i := can_carry(pc, item, 1);&lt;br /&gt;
   if (i == 1)&lt;br /&gt;
   {&lt;br /&gt;
      act(&amp;quot;Your hands are full.&amp;quot;, A_ALWAYS, pc, null, null, TO_CHAR);&lt;br /&gt;
      return(FALSE);&lt;br /&gt;
   }&lt;br /&gt;
   if (i == 2)&lt;br /&gt;
   {&lt;br /&gt;
      act(&amp;quot;$2n is too heavy for you.&amp;quot;, A_ALWAYS, pc, item, null, TO_CHAR);&lt;br /&gt;
      return(FALSE);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   link(item, pc);&lt;br /&gt;
   act(&amp;quot;$3n hands you $2n.&amp;quot;, A_ALWAYS, pc, item, self, TO_CHAR);&lt;br /&gt;
   return(TRUE);&lt;br /&gt;
}&lt;br /&gt;
dilend&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
A helper that hands an item to a player only if they can take it, like the clan chest in&lt;br /&gt;
clans.zon.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Manual:DIL Manual/link()|link()]]&lt;br /&gt;
* [[Manual:DIL Manual/weight|weight]]&lt;br /&gt;
* [[Manual:DIL Manual/capacity|capacity]]&lt;br /&gt;
* [[Manual:DIL Manual/fits()|fits()]]&lt;/div&gt;</summary>
		<author><name>Agent-mud</name></author>
		
	</entry>
</feed>