PUT ALL IN BREAD: questions about coding it well/better

So I have some code that equates

> PUT ALL ON SANDWICH

to

> PUT X ON SANDWICH
> PUT Y ON SANDWICH
> PUT Z ON SANDWICH
> PUT W ON SANDWICH

It works, but I’m wondering if I’m missing something native to Inform, though. Here is the code.

rule for deciding whether all includes an ingredient: [x y z and w are ingredients]
	if current action is putting something on or current action is inserting into:
		if second noun is bread:
			if noun is part of the bread, the rule fails;
			the rule succeeds;

check putting something on the bread (this is the bread-onto rule):
	if bread is in done-items-room. do nothing instead;
	if noun is an ingredient:
		bread-add noun;
		the rule succeeds;

to bread-add (x - a thing):
	if x is part of the bread:
		say "You've already put [the x] in the bread.";
		the rule succeeds;
	now x is part of the bread;
	increment ingredients-in-bread;
	say "<progress text here>.";
	if ingredients-in-bread is 4:
		set the pronoun it to the sandwich;
		now player has the sandwich;
		move bread to done-items-room;
		alter the multiple object list to {};

This works, but I’m wondering:

  1. “alter the multiple object list” feels like using a sledgehammer to kill a fly. “stop the action” doesn’t work, but I’m wondering if I’m missing some useful syntax here.
  2. why doesn’t the “if bread is in done-items-room” command statement stop Inform from saying “You can’t reach into done-items-room”, for instance, if I have a non-ingredient called V that is part of “all?”

Thanks!

Regarding #2, I believe that the reachability check is done prior to the evaluation of check rulebooks – it happens immediately after before rulebooks, if I’m not mistaken.

Regarding #1, what exactly are you trying to get for an effect here? Can you provide the ideal transcript of the interaction that you want?

1 Like

Is there a reason not to just make the sandwich a supporter?

1 Like

@Draconis the puzzle in question is making anagrams from the completed sandwich (name obfuscated to avoid spoilers), so it’s easier just to change the name and say “the sandwich is what you can flip” and “the bread is what you cannot.” The sandwich isn’t actually for eating, and I want to make it clear both while you’re building it and after it’s built.

Also, making something a supporter requires all sorts of other testing. It’s like Jim Aikin’s topic where he asks about making an elevator and replaces doors with scenery. There’s a lot of Inform overhead that 's easier not to deal with, and standard verbs and actions I want to block out, to say: the important thing is to build the sandwich!

s what matters here.

@otistdog–what I need is this. PUT ALL ON BREAD will go through the following commands, assuming X/Y/Z/W/V1/V2 are all in the room and encompassed by “all,” and XYZW are desirable to put on the bread, but V1 and V2 aren’t. The order is arbitrary, but I want to account for all test cases below.

(implicit >PUT X ON BREAD)
(added)
(implicit >PUT Y ON BREAD)
(added)
(implicit >PUT V1 ON BREAD)
(message saying you can't, because it's not an ingredient)
(implicit >PUT Z ON BREAD)
(added)
(implicit >PUT W ON BREAD)
(added and note the sandwich is complete)
(cut off the PUT ALL ON BREAD command if possible, though)
(implicit >PUT V2 ON BREAD should not be run)

stop the action means “end this rule in failure”. You can’t use it in a To-phrase, it has to be in a rule.

I think this does what you want. It’s not all that short, but I think it’s fairly straightforward.