Inline Implicit Library

Revised version of Jon Ingold’s Considerate Holdall, will compile in 6L38
Original code that has been changed has been commented out

[code]Version 9 of Considerate Holdall by Jon Ingold begins here.

[revised by Albert Minugh]

“Provides an improving stashing mechanism for the player’s holdall. Objects that haven’t been used in a long time will be stashed first. A rulebook is provided to contextualise the stashing process.”

A thing can be stashable or unstashable. A thing is usually stashable.

Use inline implicit library translates as (- Constant INLINE; -).

Section 1 - remembering handled items

Table of Recent Items
recent item time
a thing a time
with 15 blank rows

To decide if (item - a thing) is not a recently handled item:
if the item is not a recent item listed in the Table of Recent Items, decide yes;
decide no.

Definition: a thing is forgotten-about if it is not a recently handled item.

Before when the noun is a thing:
if the noun is not unstashable, note the noun.
Before when the second noun is a thing:
if the second noun is not unstashable, note the second noun.

To note (n - a thing):
if the n is a recent item listed in the Table of Recent Items begin;
now the[change] the time entry is[to] the time of day;
otherwise;
sort the Table of Recent Items in time order;
if the number of blank rows in the Table of Recent Items is zero, choose row 1 in the Table of Recent Items;
otherwise choose a blank row in the Table of Recent Items;
now[change] the recent item entry is[to] the n;
now the[change] the time entry is[to] the time of day;
sort the Table of Recent Items in time order;
end if;

The considerate player’s holdall rule is listed instead of the use player’s holdall to avoid exceeding carrying capacity rule in the check taking rules.

Section 2 - Rulebooks, one for each type

part 1 - Holdall rules

The holdall rules are an object-based rulebook. The holdall rules have outcomes allow stashing (success), no decision (no outcome - the default) and disallow stashing (failure).

Holdall rule for a thing not enclosed by the player: disallow stashing.

Holdall rule for a thing (called the item) when multi (this is the remove all from a holdall rule):
if taking something inside the item, disallow stashing;

Holdall rule for a closed player’s holdall (this is the require an open holdall rule):
if the inline implicit library option is not active,[if not using the inline implicit library option] disallow stashing;

A holdall rule for a thing (called the item) (this is the check the size of a holdall rule):
if item provides the property carrying capacity and the number of things in item is at least the carrying capacity of item, disallow stashing.

The last holdall rule: allow stashing.

A player’s holdall can be CHavailable or CHunavailable. A thing can be CHviable or CHunviable.

To decide if multi: (- (multiflag) -).

part 2 - Stashable object rules

The stashing rules are an object-based rulebook. The stashing rules have outcomes allow stashing (success), no decision (no outcome - the default) and disallow stashing (failure).

Definition: a thing is a body-part if it is a part of the player.

First stashing rule for thing (called the item): if the item is unstashable, disallow stashing;
Stashing rule for the considered holdall: disallow stashing.
Stashing rule for something enclosing the considered holdall: disallow stashing.
Stashing rule for a body-part thing: disallow stashing.
The last stashing rule: allow stashing.

section 3 - the main loop

The considered holdall is a thing that varies. The current stashable thing is a thing that varies.

This is the considerate player’s holdall rule:
[ if you’ve got too much in your hands…]
if the number of things carried by the player is at least the carrying capacity of the player begin;
now every player’s holdall is CHunavailable;
repeat with current holdall running through player’s holdalls enclosed by the player begin;
[ mark-up holdalls to see if they’re appropriate to use…]
follow the holdall rules for the current holdall;
if the outcome of the rulebook is the disallow stashing outcome, now the current holdall is CHunavailable;
if the outcome of the rulebook is the allow stashing outcome, now the current holdall is CHavailable;
end repeat;
repeat with current holdall running through CHavailable player’s holdalls begin;
[ try each holdall individually… hopefully we won’t actually have to try very many! ]
now[change] the considered holdall is[to] the current holdall;
repeat with item running through things carried by the player begin;
[ see if we can stash items in this particular holdalll… ]
follow the stashing rules for the item;
if the outcome of the rulebook is the disallow stashing outcome, now the item is CHunviable;
if the outcome of the rulebook is the allow stashing outcome, now the item is CHviable;
end repeat;
now[change] the current stashable thing is[to] a random forgotten-about CHviable thing held by the player;
[ is there anything you could stash which you’ve never used…? ]
if the current stashable thing is not a thing begin;
[ if not, find the oldest thing we can stash … ]
repeat through Table of Recent Items in time order begin;
if the recent item entry is CHviable and the recent item entry is carried by the player begin;
now[change] the current stashable thing is[to] the recent item entry;
[ we’re happy with this item .]
break;
end if;
end repeat;
end if;
if the current stashable thing is a thing begin;
[ we’re happy with the combination of stashable thing and holdall… ]
if the inline implicit library option is active begin;[if using the inline implicit library option begin]
[ this is an entry point for implicit libraries, such as Eric Eve’s, to use, to tidy up more complicated lines. ]
spit inline library message as appropriate for the current stashable thing into the considered holdall;
if the current stashable thing is not inside the considered holdall, stop the action;
otherwise;
[ try putting it away, and report if we managed to … ]
try silently inserting the current stashable thing into the considered holdall;
if the current stashable thing is not inside the considered holdall, stop the action;
spit library message as appropriate for the current stashable thing into the considered holdall;
end if;
continue the action;
end if;
end repeat;
[ we give up! ]
spit library message for failure of holdalls instead;
end if;

To spit library message for failure of holdalls:
say “You cannot put that in there.”[(-GL__M(##Take,12,);
-)]

To spit inline library message as appropriate for (n - a thing) into (s - a thing):
say “You succeed in stashing the object.”[(- SACK_OBJECT = {s}; #ifdef INLINE; __stash({n}); #endif;
-)]

To spit library message as appropriate for (n - a thing) into (s - a thing):
say “You succeed in stashing the object.”[(- SACK_OBJECT = {s}; GL__M(##Take,13,{n});
-)]

Include (- Constant CONSIDERATE_HOLDALL; -).

Considerate Holdall Revised ends here.
[/code]

1 Like