[I7] List manipulation.


I am having a problem with adding lists to lists. In this particular instance, I want to only list the outermost layer of clothes for each section of the body. IE, if someone is wearing a jacket, you can’t see their shirt.

Let clothinglist be a list of clothing worn by the player;

This does not work for reasons I do not understand. Getting this to work would solve the problem, because I could remove hidden items. Clunky but functional.

My second attempt was to save the lists of clothing as indexed texts, but that has its own set of problems.

Let clothinglist be a list of indexed texts; Add the list of outerwear worn by the player to clothinglist; Add the list of innerwear worn by the player to clothinglist;

Obviously, there is extra code in this to conditionally add the list of innerwear, but I come up with this problem. If I am wearing a parka, snow pants, and snow boots, it lists the result as “parka and snow pants and snow boots”. It is treating them as two separate lists. Is there a simple way to get around this problem?

When you run into an error, it’s always helpful to post the error message, rather than just saying “this does not work”.

In this case, you’re running into one or two problems. First, “clothing” is not a term in the standard library. But maybe you’ve defined a “clothing” kind, in which case fine.

More important, the phrase to construct a list is “the list of…” rather than “a list of…”. I have no idea why it doesn’t accept both, but that’s the way it is.


let clothinglist be the list of things worn by the player;

You also might want to look at the Inform example What Not To Wear, which implements a system where jackets cover shirts etc., without lists. (It’s a pretty complex example, though.)

You wrote ‘Let clothinglist be the list of clothing worn by the player’ but descriptions used as values are not allowed to contain references to temporary variables defined by ‘let’ or by loops, because they may very well not exist any more when the description needs to be used, in another time and another place.

[rant=Apparently inaccurate; see zarf’s post below]Ah, that looks like the same problem that arose here (as it happens, in relation to the same “What not to wear” example that I cited). Inform treats “the player” as a temporary variable and won’t let you use it in that list description.

If your player object doesn’t change in the course of the game, you probably have an easy workaround – if you haven’t given the player an identity by a like like “The player is Jordan,” then “Let clothinglist be the list of clothing worn by yourself” should work.[/rant]

This surprises me, because I tested that and I didn’t run into that error.

Clothing is a kind of thing.
The sock is clothing. The hat is clothing.
The player wears the sock. The player wears the hat.

When play begins:
	let clothinglist be the list of clothing worn by the player;
	say "List: [clothinglist]."

I’m not sure what you’re doing differently.

EDIT-ADD: Note that “the player” is not a temporary variable, although “the actor” is.