Duplicating objects for a Resource Management Game

so I’m fairly new to inform and I’m working on a prototype for a management game. I want to have a system where, say, you have a tomato plant in your garden, and every so often a tomato grows that you can harvest. (this would extend to other things, such as trees dropping branches that you could gather, etc)

  • how would I make the tomato plant grow tomatoes?

  • how would I stack multiple of the same items? (I’m new to this and inform may handle this automatically)

  • is there a way to have, for example, a house inventory that stores all the resources gathered (wood, tomatoes, etc) that the player could access instead of carrying it all in their inventory?

  • are there any tips for making resource management systems that aren’t listed here?

Congrats on getting into Inform! This is all fairly simple to do out of the box:

  • You can make a tomato plant grow tomatoes by setting a quality on the plant that determines whether or not it’s got a tomato, and then using an “Every Turn” rule to make a tomato-less plant tomato-full (an Every Turn rule is a rule that, unsurprisingly, runs every turn, and one of the things it’s good for is incrementing a counter or timer, which sounds like exactly what you’re looking for!) See below for a specific example of how this would work.

  • Inform does indeed handle this automatically – all you need to do is tell it that “tomato” is a kind of thing, and then any tomato the player picks up will stack exactly the way you think it should.

  • This is also easy – you can just create a room called the house that the player can go into and drop stuff off in willy-nilly. Or you could create a container that they could similarly insert stuff into and take stuff out of. You can get fancy and add size or carrying limits to containers (or rooms for that matter), too.

  • I don’t think I’ve got too many tips on design for resource management games since I haven’t played that many, but there are a couple of things that I can see coming up in implementation. First is that if you’re not careful, it seems like it’d be easy for the player to wind up in disambiguation hell – like, in this example there’ll be tomato plants and tomatoes, and maybe ultimately there’ll be like tomato seeds as well. So you might want to think carefully about how to use action definitions, Understand commands, and Does the Player Mean statements to help the parser guide ambiguous input towards the most logical outcome. The corollary to this – and a good rule for all IF, really – is that you should have folks other than you test the game and keep a transcript so you can see how they play, since however good a job you do thinking this stuff through, you’ll still learn more from five minutes of beta testing than five hours of testing on your own.

Anyway, as mentioned I whipped together a tiny sample demonstrating how some of these pieces could work together – I’m sure there are a ton of ways to improve it but at least it shows a minimal implementation. The idea is that you have resource generators, which are implemented as the kind “plant”, with an adjustable time it takes for the plant to create one of its resource (this is the “ripeness” quality).

Since Inform isn’t good about dynamic item creation, I just created an inaccessible room to hold a large quantity of tomatoes – you’d create similar rooms for other products (adjusting the “product-hopper” quality of the plant accordingly). Note that this just creates a single tomato plant, but you could implement those as a kind instead, making it easy to get multiple stacks of tomato plants (you’d need to do some work to make these distinguishable, though – this example might be helpful).

Anyway, here’s the code – if anything doesn’t make sense just flag it and I’m happy to explain further or point you to the right bit of documentation!

A plant is a kind of thing.  A plant is either fruitful or bare.  A plant is usually bare.  A plant has a number called the ripeness.  The ripeness of a plant is usually 5.  A plant has a number called the counter.  The counter of a plant is usually 0.  A plant has a room called the product-hopper.  A plant has some text called the product.

The farm is a room.  The silo is a container in the farm.

A tomato is a kind of thing. The tomato-bin is a room.  There are 100 tomatoes in the tomato-bin.

Picking is an action applying to one thing.  Understand "pick [plant]" as picking.  Instead of taking a plant, try picking the noun.

The tomato-plant is a plant in the farm.  The printed name is "tomato plant".  Understand "tomato/plant" as the tomato-plant.  Understand "tomato plant" as the tomato-plant.  The description is "This tomato plant [if the tomato-plant is bare]is completely bare[otherwise]has a single plump tomato at the end of a vine[end if]."  The product-hopper of the tomato-plant is the tomato-bin.  The product of the tomato-plant is "tomato".

Check picking:
	If the noun is bare, say "The [noun] isn't ripe yet." instead;
	Say "You pluck a [product of the noun] from [the noun].";
	Now the noun is bare;
	Let foo be a random object in the product-hopper of the noun;
	Move foo to the player.

Every turn:
	Repeat with foo running through plants:
		If foo is bare:
			Increment counter of the foo;
			If counter of the foo is ripeness of the foo:
				Now the foo is fruitful;
				Now the counter of the foo is 0.

My comments are about the game design aspects rather than the technical ones, as you already got a great answer about that. What’s fun is subjective, of course, but there is a risk a game like this might not be regarded as fun by many if it places too much focus on resource management - it could feel like being a command line sysadmin, which is usually regarded as more a job than a past-time. I don’t want to discourage you though because I think it’s possible to include resource management as one aspect of a narrative game in a way in which the overall whole is very entertaining. The Fallen London series of games by Failbetter games comes to mind.

I’ve been thinking about how to make dealing with collections of objects more interesting, as I might include an element of that in my own project. I was thinking it might be entertaining if occasional produced objects (drops) were different and better to the standard ones in interesting ways. This kind of mechanic is of course used very widely these days in all sorts of games because it does appeal to some aspects of basic psychology.

If you have lots of an item (like 50 tomatoes) you might want to represent that with a variable rather than 50 discreet objects.

i plan on using a time system. where would I learn more about that, and how would I go about implementing that into the plant system?

I’m guessing Chapter 9 of Writing with Inform, which is all about time, is going to be the best part of the documentation to look over, especially 9.5 through 9.11. There are some good examples in there, as well as in 4.1 of the recipe book.

It’s hard to say more without a bit of additional detail about what you’re looking for the system to do, though – the quickie code I pulled together above shows how you can have a per-plant timer giving you the ability to make different ones ripen at regular intervals, but what other functionality are you looking to add?

1 Like

Inform 7 and most parser systems do not incorporate “real time” as in a ticking clock. In most cases you’d want to go turn-based.

The sort-of-agreed-upon default is each turn is a minute of “time” and if you set the time of day in your game and check it, you’ll find one minute ticks with each “in world” turn. “Out of world” actions like saving and loading do not tick the clock.

There are extensions in the library where you can fiddle with what amount of “time” actions take.

Chapters about time begin in the documentation, also check the subsequent chapters: 9.6. The time of day
Recipe book examples regarding time: 4.1. The Passage Of Time

Variable Time Control extension: Variable Time Control by Eric Eve - The Inform 7 Extensions Library

1 Like

If you really want to use real time, you can use Real Date and Time by Ron Newcomb.