# Summing weights à la § 15.17. Totals in the Inform 7 documentation

Sorry to just come here to beg for help, but…

I want to sum the massess of everything in a room. I’ve read section 15.17 of the Inform 7 documentation, but I run into an error when I use the [total mass of things in [location]] line, even though that’s directly lifted from the documentation. Here is the entirety of my code:

Mass is a kind of value. A thing has mass. 1.0kg specifies a mass.

The mass of the player is 70kg.

House is a room.
The hunk of lead and bag of feathers are in the house.
The mass of the hunk of lead is 10kg.
The mass of the bag of feathers is 0.5kg.
The gauge is in the house.
The mass of the gauge is 0.25kg.
The description of gauge is
“Current mass of everything in the house, summed inefficently: [mass of player + mass of hunk of lead + mass of bag of feathers + mass of gauge]
[line break]
Current mass of everything in the house, summed efficently: [total mass of things in the house].
[line break]
List of things in the house: [list of things in the house].”

The player is in the house.

Here is what it outputs:

House
You can see a hunk of lead, bag of feathers and a gauge here.

>look at gauge
Current mass of everything in the house, summed inefficently: 80.75kg
Current mass of everything in the house, summed efficently: 3.15914 × 10^-38kg.
List of things in the house: yourself, hunk of lead, bag of feathers and gauge.

Does anyone have an idea of why the sum is correct when I list the items in the house individually, and why it reads as basically zero when I use the “total mass of things in the house” line?

I’ve made it output a list of all the things in the house so I know that there’s nothing unsuspecting that’s getting added.

Thanks.

1 Like

Maybe a bug in the older Inform7 version? When I copy paste your code in borogove.app with 6M62 I get:

``````>x gauge
Current mass of everything in the house, summed inefficently: 80.75kg
Current mass of everything in the house, summed efficently: 3.15914 × 10^-38kg.
List of things in the house: yourself, hunk of lead, bag of feathers and gauge.
``````

But when I use version 10.1.0 I get:

``````>x gauge
Current mass of everything in the house, summed inefficently: 80.75kg
Current mass of everything in the house, summed efficently: 80.75kg.
List of things in the house: yourself, hunk of lead, bag of feathers and gauge.
``````
2 Likes

Yes, it was fixed in 10.x.

https://inform7.atlassian.net/jira/software/c/projects/I7/issues/I7-1899

3 Likes

Well, goodness. That’s what I get for coming back to IF writing after years of doing nothing. Tomrrow, and tomorrow, and tomorrow, time creeps in this petty pace from day to day until the last syllable of recorded time, amirite?

Thanks.

3 Likes

A workaround for 6M62:

``````To decide which K is (O - object) prop (A - arithmetic value of kind K valued property):
(- GProperty(OBJECT_TY, {O}, {A}) -).

To decide which K is total (AVP - arithmetic value of kind K valued property) of (D - description of objects):
let T be default value of K;
let L be the list of D;
repeat with X running through L:
increase T by X prop AVP;
decide on T.
``````
5 Likes