Hi, I’m new here. This got huge, so here’s a tl;dr:
- Is there a data structure similar to a tuple in Inform?
- Is there a way to model a kind to have a property that is a dynamic list, as opposed to a single value?
- Stack Overflow says creating dynamic objects is not well-supported by Inform and is heavily discouraged, and that it usually means you’re doing something wrong. Why is that?
- There’s a Dynamic Objects extension by Jesse McGrew but it was last updated in 2015, and isn’t listed in the extensions library. Is it a bad idea to try and use it?
Ok, now that that’s over with…here’s all the context.
Hi all! I decided to try learning Inform 7, and as part of my learning experiments I’m trying to make a game where you bake a simple loaf of bread. In this experiment, I want quantities, bake time, heat, etc. to matter - and I want it to be possible for the player to mess up. For example, if they add too much salt, it shouldn’t rise properly.
Here’s what it might look like:
> fill 1-tsp with active dry yeast
> pour 1-tsp into mixing bowl
> x mixing bowl
The bowl holds some active dry yeast.
> fill 1-cup with water
> pour 1-cup into mixing bowl
> fill 1-cup with water
> pour 1-cup into mixing bowl
> x mixing bowl
The bowl holds a mixture of active dry yeast and water.
> fill 1-tsp with white sugar
> pour 1-tsp into mixing bowl
> x mixing bowl
The mixing bowl holds a mixture of active dry yeast, water, and white sugar.
> beat mixing bowl
You beat the mixture in the mixing bowl until combined.
> x mixing bowl
The mixing bowl holds a foamy yeast mixture.
I’m having trouble modeling ingredients, however. Essentially, I need to be able to track what ingredients and how much are in a mixing bowl. I also need to be able to appropriately subdivide ingredients, such that you can scoop 1/2 cup of flour out of the flour tub into a small mixing bowl, and 1 cup of flour into a big mixing bowl.
My first thought was I could use Emily Short’s Measured Liquids to do this, modeling each ingredient as a liquid, but after some further investigation it turns out that Measured Liquids only allows one type of liquid per container. It does have various mixing rules, but as far as I can tell overriding the mixing rules is designed around changing what the result of the one liquid is after mixing, and not around allowing multiple liquids. Okay, I thought, is it possible to either modify or selectively reimplement Measured Liquids to make it have multiple liquids?
Here’s how Measured Liquids appears to model a “fluid container”, in pseudocode:
a kind of container called "fluid container" has:
- <a kind of value called volume> "fluid capacity"
- <a kind of value called volume> "fluid content"
- <an entry in table of liquids> "liquid"
Essentially, each fluid container has 3 values, how much it can store, how much it has, and what liquid is stored.
What I’d want is something like this:
a tuple of "ingredient-and-volume" has:
- <an entry in the table of liquids> "liquid"
- <a kind of value called volume> "ingredient volume"
a kind of ingredient container called "ingredient container" has:
- <a list of "ingredient-and-volume"> ingredients-and-volumes
- <a kind of value called volume> "ingredient capacity"
Here, instead of having a single liquid and a single volume, I’d have a list of ingredients and a list of volumes. I tried looking up how to create tuple and list data structures, but I found information on how to have lists of concrete objects (http://inform7.com/book/WI_21_6.html) and that lead me to suspect that I was totally barking up the wrong tree, or was thinking with a completely different mental model. Possibly this is my normal programming knowledge crashing headfirst into Inform and getting a concussion. My question is, is the model above possible in Inform, or, like, is my brain just not on the wavelength entirely?
My second try was to model each ingredient as an object with a volume. So, you’d start with a “flour” object with volume “7 cups” in the flour tub, and when you scoop 1/2 cup of flour it creates a new “flour” object with volume “1/2 cup” in the measuring cup and changes the flour in the flour tub to “6 1/2 cups”. However, Stack Overflow (https://stackoverflow.com/questions/5386306/need-help-creating-new-objects-in-inform7/5672312) tells me that Inform doesn’t handle dynamic object creation well and I shouldn’t do this, though it doesn’t really say why I shouldn’t do this. Is there a more fleshed-out explanation for why it’d be bad, and if it is bad what would be a better way?
Also, I did find a Dynamic Objects extension (new users can only put 2 links in a post, so, uh, Google it if curious?) but it doesn’t seem to be listed in the Extensions Library (Google Inform 7 Extensions Library 'cuz I can only put 2 links in a post, RIP) and the last commit is 2015, which leads me to believe that it might be abandoned, is that accurate?
Sorry for the gigantic question post, if it’d be better to split this up into multiple, more specific posts I can do that too. Thanks for reading.