Temp vs long-term variables

I have two rules: The collection rule is an action that prepares a list for the stripping rule, which is an action for selecting from the list L in the collection rule. It seems that the stripping rule does not have access to the list L in the collection rule. I usually put a variable above both, like

Flag is text that varies. Flag is "TRUE".

which works fine, but that does not work for statements like

L is a list of objects.

How do I make a list that is useable by both rules?
Note that the statement say "[L]" works in the collection rule but not in the stripping rule.

Stripping is an action applying to nothing.
Understand "strip" as stripping.

After looking the first time:
	follow the collecting rule;

Carry out stripping:
	say "stripping...";
	say "[L]";
[	say "[L][paragraph break]";
	say "[entry 1 in L] is about the be stripped.";
	if [entry 1 in L] is:
		-- pair of dice: say "Your two dice bounce across the room. They come up snake-eyes.";
		-- otherwise:
			say "not in collection";
]

This is the collecting rule:
	let L be a list of objects;
	add list of things carried by player to L;
	add list of things worn by player to L;
	say "Strippable list contains [number of entries in L] entries:[line break]";
	say "[L][paragraph break]";
	remove uniform from L;
	remove sword from L;
	remove candle from L;
	sort L in random order;
	say "Now strippable list in random order contains [number of entries in L] entries:[line break]";
	say "[L][paragraph break]";
	say "[entry 1 in L] is post-collective.";

Before someone suggests putting the stripping rule within the collection rule, I do not want the collection part of be run everytime the stripping rule is executed.

1 Like

You should be able to say L is a list of objects that varies. at the top of the code; that’s the equivalent version of the ‘flag is text that varies’ for lists.

2 Likes

Yeah - “let X be blah” is Inform’s equivalent of creating a local variable (it only works within rules), if that’s a helpful way to think about it.

1 Like

Oh, were everything so simple! :wink:

1 Like

That’s something I have to look up every time I do it: the difference between a list as temporary variable and a list as permanent variable. Some things just don’t stick in my brain.