# Hello World + carrying capacity rules

First Post!
I played most of the Infocom text games back in the 80s, and got the itch to try something myself.

I wanted to implement a more robust carrying capacity rule to have a fairly simple way of preventing larger items from fitting into smaller containers. But I’m stumped on a point. When I try to change the can’t drop if this exceeds carrying capacity rule, I get a problem - in the line “let the receptacle be the holder of the actor;”, Inform says it does not know the term “actor”. Which is weird since I copied it verbatim from the standard rules. There’s a bunch of other error messages, but I think they all link back to that. Using build 6M62.

Here’s the full example:

[spoiler]“Container and Supporter Encumbrance System” by RedShirtNo5

Everything has a number called an encumbrance. The verb to encumber means the encumbrance property. A thing usually encumbers 1.

This is the new can’t drop if this exceeds carrying capacity rule:
let the receptacle be the holder of the actor;
if the receptacle is a room, continue the action; [room floors have infinite capacity]
if the receptacle provides the property carrying capacity:
if the receptacle is a supporter:
if the total encumbrance of things on the receptacle plus the encumbrance of the noun is greater than the carrying capacity of the receptacle:
if the actor is the player:
now the prior named object is nothing;
say “[There] [are] no more room on [the receptacle].” (A);
stop the action;
otherwise if the receptacle is a container:
if the total encumbrance of things in the receptacle plus the encumbrance of the noun is greater than the carrying capacity of the receptacle:
if the actor is the player:
now the prior named object is nothing;
say “[There] [are] no more room in [the receptacle].” (B);
stop the action.

The new can’t drop if this exceeds carrying capacity rule substitutes for the can’t drop if this exceeds carrying capacity rule.

This is the new can’t insert if this exceeds carrying capacity rule:
if the second noun provides the property carrying capacity:
if the total encumbrance of things in the second noun plus the encumbrance of the noun is greater than the carrying capacity of the second noun:
say “There isn’t room for the [noun] in the [second noun].”;
stop the action [with library message inserting it into action number 7 for the second noun;].

The new can’t insert if this exceeds carrying capacity rule substitutes for the can’t insert if this exceeds carrying capacity rule.

This is the new can’t put if this exceeds carrying capacity rule:
if the second noun provides the property carrying capacity:
if the total encumbrance of things on the second noun plus the encumbrance of the noun is greater than the carrying capacity of the second noun:
say “The [second noun] doesn’t have enough room for the [noun].”;
stop the action [with library message putting it on action number 6 for the second noun].

The new can’t put if this exceeds carrying capacity rule substitutes for the can’t put if this exceeds carrying capacity rule.

Test Room is a room.

The player is in the Test Room. [The carrying capacity of the player is 3.]

A table is in the Test Room. The table is a supporter. The carrying capacity of the table is 4.

A book is in the Test Room. The book encumbers 1.

The barbells are in the Test Room. The barbells encumber 3.

A telephone is in the Test Room. The telephone encumbers 1.

A computer screen is in the Test Room. The computer screen encumbers 2.[/spoiler]

The new can’t insert if this exceeds carrying capacity rule and new can’t put if this exceeds carrying capacity rule seem to work fine.
Any suggestions would be appreciated.

“The actor” is a bit of a strange beast. It’s a local variable to the main action rulebooks, but at the time when your new rule is being declared, Inform doesn’t know which rulebook you want it to go in. The easiest solution is to refer to “the person asked” instead, which points to the same memory but is global.

Thanks! That did the trick. I also modified the can’t enter if this exceeds carrying capacity rule. I had to fiddle a bit with the phrasing; apparently the parser got confused by my trying to have all the values in one phrase.

Here the result for anyone interested.

This is the new can’t enter if this exceeds carrying capacity rule: [note not testing for things worn on basis that the they stay close to the body]
if the noun provides the property carrying capacity:
if the noun is a supporter:
let x be the total encumbrance of things on the noun;
let y be the total encumbrance of things carried by the person asked;
let z be the encumbrance of the person asked;
if x + y + z is greater than the carrying capacity of the noun:
if the person asked is the player:
now the prior named object is nothing;
say “[There] [are] not enough room on [the noun].” (A);
stop the action;
otherwise if the noun is a container:
let x be the total encumbrance of things in the noun;
let y be the total encumbrance of things carried by the person asked;
let z be the encumbrance of the person asked;
if x + y + z is greater than the carrying capacity of the noun:
if the person asked is the player:
now the prior named object is nothing;
say “[There] [are] not enough room in [the noun].” (B);
stop the action.