Combining items puzzle in Inform7

Hello! I’m pretty new to inform7 and I’m trying to figure out how to make a puzzle. I’m trying to make a specific puzzle in Inform7. The game takes place in a hag’s hut and there’s a shelf that would have 6 potions on it. The cauldron can only hold 3 potions and needs 3 potions to do something. I want the player to be able to put the potions into a cauldron and have different results happen (like it says something different) depending on what you put in the cauldron. I also want the player to be able to “reset” the cauldron by pulling a lever to dump it out.

Example: There’s a red, blue, purple, pink, green, and yellow potion. You put the red, green, and blue potion into the cauldron. Something happens. then you dump the potion out (if it didn’t kill you.).

Does anyone know how this would work? I’ve been looking in the documentation and online to see if anyone has done a similar puzzle but I can’t find anything. Thank you in advance!

1 Like

I’ll try to scope it out. In the mean time you could try looking at 16.12 Listed In, the game called “Noisy Cricket”. This may start you along the right path.

1 Like

Make a table of the different values (a row for the result, and three rows for the potions you put in). Have a counter counting how many potions are in the cauldron, increasing each time you put one in (the putting it into action). When there are 3 potions in the cauldron (potion-counter is 3, consult the table to see what is created, then remove the 3 ingredients from play and add the resultant potion.

I’m not good enough with Inform 7 code to give you the exact syntax, but this should hopefully be what you’re looking for.

3 Likes
The Hut is a room.

A potion is a kind of thing. A red potion, a blue potion, a purple potion, a pink potion, a green potion, and a yellow potion are potions in the Hut.
Definition: a thing is non-potion if it is not a potion.

A potion can be used or unused. A potion is usually unused.

A cauldron is fixed in place in the Hut.
Definition: the cauldron is full if the number of used potions is at least three.

Instead of inserting a non-potion thing into the cauldron: say "The cauldron can only hold liquids, which [the noun] [are] not."
Instead of inserting a potion into the full cauldron: say "The cauldron is already full."
Instead of inserting a potion into the cauldron:
    now the noun is used;
    say "You pour some of [the noun] into the cauldron. It now contains some of [the list of used potions].".

A lever is fixed in place in the Hut.
Instead of pulling the lever:
    say "The cauldron flushes itself out.";
    now every potion is unused.
4 Likes

Hello! Thank you for the reply. I got multiple of the same errors for this solution such as “The sentence ‘A red potion, a blue potion, a purple potion, a pink potion, a green potion, and a yellow potion are potions in the Hut’ appears to say two things are the same - I am reading ‘red potion’ and ‘potions in the Hut’ as two different things, and therefore it makes no sense to say that one is the other.” (It was the same error for ‘A cauldron is fixed in place in the Hut’ and ‘A lever is fixed in place in the Hut’)

2 Likes

Did you make sure you told Inform that “the Hut is a room”? Those errors could indicate that it doesn’t know what you mean by “the hut”.

4 Likes

Ha! I did mess that up. But I have a different error here: “You wrote ‘Instead of inserting a potion into the full cauldron’, which seems to introduce a rule taking effect only if the action is ‘inserting a potion into the full cauldron’. But that did not make sense as a description of an action. I am unable to place this rule into any rulebook.” (Btw, I’m sorry if this is a little annoying and the answers are obvious. I’m really new to this program.)

Instead of inserting a potion into the cauldron when the cauldron is full:
1 Like

That worked! Thank you so much! Does anyone know specifically how to make it so that inform says specific things when you put together specific combinations of potions:

Example: You put the red, blue, and pink potion together and it then says “The potion lets out a weird fog.” vs You put the purple, blue and red potion together and then it says “The potion blows up.”

You’d probably want a rulebook for combining potions. I’d write a little bit about that here but I’m on my phone. If no one has tackled it, I’ll write something in a little while.

2 Likes

Okay! Thank you for your help so far! I really appreciate it.

This is a good idea. Which I’d already been writing up an example of. :smiley:

lab is a room.

The cauldron is a fixed in place container in the lab.
A color is a kind of value.
The colors are red, orange, yellow, green, blue, indigo, violet.
A potion is a kind of thing.
A potion has a color.
Colorizing relates one color to one potion.
The verb to colorize means the colorizing relation.
Every color colorizes a potion.
Every potion is in the lab.

Before searching the cauldron, instead try examining the cauldron.

Carry out examining the cauldron:
  if potion-mixture is not empty, say "The cauldron bubbles.";
  else say "The cauldron is empty.";
  now examine text printed is true.


After starting the virtual machine:
  repeat with c running through the colors begin;
    let p be the potion to which c relates by the colorizing relation;
    now the color of p is c;
  end repeat.

For printing room description details of the cauldron when potion-mixture is not empty: say "The cauldron bubbles."

The printed name of a potion is usually "[the color of the item described] potion".
understand the color property as describing a potion.

mixing is a list of colors based rulebook.

mixing { red, green, blue }: say "pouf".

mixing { orange, yellow, violet }: say "What a mess."

last mixing: say "Nothing happens.".
the mixing rules have default success.

the potion-mixture is a list of colors that varies.

check inserting something (called the payload) into the cauldron when the payload is not a potion: instead say "That would be silly."

last carry out inserting something into the cauldron:
  add the color to the potion-mixture;
  now the noun is nowhere;

first report inserting something into the cauldron when the number of entries in potion-mixture is three:
sort the potion-mixture;
follow the mixing rulebook for the potion-mixture;
truncate potion-mixture to 0 entries;
stop the action.

test me with "x cauldron / put blue potion in cauldron / x cauldron / put green in cauldron / put red in cauldron / x cauldron / put yellow in cauldron / put orange in cauldron / put violet in cauldron".
4 Likes

Wow, I never considered “list of colors based rulebook.” So I’m glad the asker asked this question … it’s a good question, and often other people had answers I never thought of that make total sense.

I would have created a table, the problem with which is that you’d have to do a lot of checking. Pseudocode would be:

table of potion mixings
p1 p2 p3 got got-text
red potion yellow potion blue potion primary potion "You concoct a primary potion."
orange potion green potion purple potion secondary potion "You concoct a secondary potion."

if number of things in potion-mixture < 3, continue the action;
repeat through table of potion mixings:
    if p1 entry is not in potion-mixture, continue the action;
    if p2 entry is not in potion-mixture, continue the action;
    if p3 entry is not in potion-mixture, continue the action;
    if there is a got entry, now player has got entry;
    say "[got-text entry][line break]";
    now potion-mixture is {};
    continue the action;
say "Ugh, nothing."

This feels a bit creaky, and I didn’t compile it – but hopefully the code is clear, more due to Inform than my own code writing capabilities.

Certainly Zed’s code is more general as you can dump any number of potions into the cauldron. But this seemed worth sharing as it can translate to general “mash 2 things together” code. (Removing p3, of course.)

2 Likes

It’s crazy how much I’m learning by studying these few lines of code.

2 Likes