How to handle a collective

I have four sails on my boat. Each is named with its own property. However, I want to allow the player to examine all sails by inputting ‘x sails’. Of course Inform is returning:

>x sails
You can't use multiple objects with that verb.

How do I handle ‘x sails’? I have a condition running on each sail so I am trying to return:

Instead of examining the sails:
	say "The Head is [state of the Head in words]. The Stay is [state of the Stay in words]. The Main is [state of the Main in words]. The Mizzen is [state of the Mizzen in words]."
1 Like

There are two basic options: one, define a new multi-examining actions (that you probably want to define via “examine [sails]” rather than “examine [things]” to avoid opening too many cans of worms); docs for that are here. Two,you can fake it by just creating a dummy “sails” scenery object in the boat and block every action other than examining.

I’m excited to see how this progresses for you - I implemented a little sailing section in my last game and thought it was a fun mechanic for IF!

2 Likes

Hi @DeusIrae. I tried creating ‘sails’ as scenery but it doesn’t like it, because I have defined a ‘sail’ already. I tried

Understand "examine [things]" as examining. 

It worked to a degree but was a bit wonky, perhaps because it was trying to print the state of the sail in words. I’ll experiment a little.

What I have been able to do is set a state of sail and plot its value against a weather value, so if there aren’t enough sails out when there is a ‘light breeze’, you are prompted to get more sail out. And vice versa if the weather state changes to a gale. I haven’t worked out what the penalty is for not setting the correct sail yet though! There’s a narrative I want to push so I could print my narrative instead.

Early days, I just wanted to get my sailing mechanism working first, and that included the ability to look at the state of all sails in one go instead of each individually, which could be a pain as there are four.

OK, so what I have in my code so far is:

To decide which text is the state of (s - sail) in words:
	if the state of s is 0:
		decide on "furled";
	if the state of s is 1:
		decide on "reefed";
	otherwise:
		decide on "completely unfurled".

Instead of examining the Head:
	let state-text be the state of the noun in words;
	say "The head is [state-text]."

Instead of examining the Stay:
	let state-text be the state of the noun in words;
	say "The stay is [state-text]."

Instead of examining the Main:
	let state-text be the state of the noun in words;
	say "The main is [state-text]."

Instead of examining the Mizzen:
	let state-text be the state of the noun in words;
	say "The mizzen is [state-text]."

Understand "examine [things]" as examining. 

Instead of examining sails:
	say "here is the description of all sails.".

When I x an individual sail, it gives the correct state. When I ‘x sails’, it does print something but not what I want it to:

>unfurl head
You have unfurled the Head. It's now completely unfurled.

>x sails
Head: The head is completely unfurled.
Stay: The stay is completely unfurled.
Main: The main is reefed.
Mizzen: The mizzen is furled.

I mean, examining all sails at once is giving the correct state of sails, but it’s taking it from my individual sails and not allowing me to customise it.

Hmm, just realised that it is ignoring my examining of individual sails too. However, if I remove the instead ofs for individual sails, then it just returns the instead of for all sails!

>x stay
here is the description of all sails.

The collective-sails are scenery in the Deck. Understand "sails" as the collective-sails.

The problem is, “sails” is still tagged as a plural word. There’s only one easy way to fix this:

The plural of sail is asdfasdf.

This will still let you talk about “sails” in your source code, but will no longer flag the word as plural for the parser.

1 Like

The main problem is that you’ve defined “sail” as a kind of thing. Inform automatically recognizes “sails” as the plural of your kind of thing.
This seems to work:

The Sailboat is a room. "You're in a sailboat. It has sails."

A sailsheet is a kind of thing. A sailsheet has a number called state.

The sails-collective is scenery in sailboat. The printed name is "sails". The description is "Sails! Sails! All you see are sails!" Understand "sails" as the sails-collective.

The head-sail is a sailsheet. It is part of the sails-collective. The printed name is "head". The description is "It's the head sail." The state is 0. Understand "head sail/--" or "sail" as the head-sail.

The stay-sail is a sailsheet. It is part of the sails-collective. The printed name is "stay". The description is "It's the say sail." The state is 1. Understand "stay sail/--" or "sail" as the stay-sail.

The main-sail is a sailsheet. It is part of the sails-collective. The printed name is "main". The description is "It's the main sail." The state is 2. Understand "main sail/--" or "sail" as the main-sail.

The mizzen-sail is a sailsheet. It is part of the sails-collective. The printed name is "mizzen". The description is "It's the mizzen sail." The state is 2. Understand "mizzen sail/--" or "sail" as the mizzen-sail.

To decide which text is the state of (s - a sailsheet) in words:
	if the state of s is 0:
		decide on "furled";
	if the state of s is 1:
		decide on "reefed";
	otherwise:
		decide on "completely unfurled".

Instead of examining a sailsheet:
	let state-text be the state of the noun in words;
	say "[The noun] is [state-text]."

Instead of examining the sails-collective:
	let sheets be the list of things that are part of the sails-collective;
	repeat with s running through sheets:
		let state-text be the state of s in words;
		say "[The s] is [state-text]. [run paragraph on]";
	say paragraph break.

Test sailing with "x sail / mizzen / x head / x main / x stay sail / x sails".

Note: I made the individual sails part of the collective sails just because that’s how I visualize the concept. They don’t have to be.

1 Like

This isn’t directly related, but I’d like to point out that instead of A sailsheet has a number called state it would probably be easier to write A sailsheet can be furled, reefed, or completely unfurled (this is its state property).

Then you don’t even need your To decide which text is the state of (s - sail) in words phrase. You can just write state of the sail and it’ll print out the correct name. And your code becomes more readable too.

4 Likes

Yes, that makes more sense @Celtic_Minstrel. Thank you.