New to Inform: A Few Key Scenarios

Hey all,

I’m new to writing with Inform 7. I’m a more traditional author with limited programming experience. I discovered it after playing a game and thought this might be a unique way to present some of my stories. Problem is… after nearly three weeks of going over the manuals and the Recipe Book, I’m still making remarkably little progress on some of the things I’m attempting.

I get the impression that these are simple things, which bothers me even more.

Still, I feel that if I can come to understand the mechanics behind these simple things, that the rest will fall into place. I appreciate any and all help toward that end.

In order to demo some of the features I’m trying to learn, I’m going to use a simple scenario of the player (a male) with three rooms. One room (the Ballroom) is empty and where the player starts. To either side are a Lounge and a Private Room, each with a different female NPC in them. Let’s call them Mary and Alice.

First Problem: I have been trying to set it up so that if I say ‘dance with Mary’ it will describe the dancing in one way, and if I say ‘dance with Alice’ it will describe the dancing in a completely different way. Say Mary dances the tango and Alice dances a waltz. When I attempt this, however, I7 will play the same description first, thus making both Mary and Alice do the tango. How can I set it up so that the ‘dancing’ action has completely different effects depending on who is targeted?

Second Problem: I have also wanted to set it up so that the clothes they are wearing adds a different description. For instance, they could wear either Street Clothes or a Dress. So in Street Clothes, it would be described in a more mechanical fashion, but when wearing a Dress, there would be more flowery descriptions to include details like the flaring of the skirts or shimmer of the candlelight. To a degree, I’ve been able to accomplish this… but again, it sees a Dress as a Dress, regardless of who’s wearing it. How can I set it so that the description changes based on what the NPC is wearing?

As a note, I can do this with look/examine, but not with actions.

Third Problem: There’s the question of confidence. I’d like to set it up so that ‘confidence’ is an attribute: Mary begins with it and Alice does not. After dancing successfully a few times, Alice gains ‘confidence’ and the description of her dancing changes accordingly. Further, is it possible to include something like that, and have Alice refuse to wear the Dress or go to the Ballroom until she has ‘confidence?’

Fourth Problem: This is something of the finale idea, but I’d like to be able to have the player call one of the NPCs into the Ballroom, and then have the actions described differently to account for the different setting. Is there a simple way to accomplish that?

I know, it’s a lot to ask for a first post. If anyone can even point me to the proper documentation that can decipher some of this, it would be greatly appreciated.

Thanks in advance for any replies.

The best way to do it is perhaps to write distinct instead rules for dancing with Mary and dancing with Alice.

Instead of dancing with Mary: say "The two of you fall into a steaming hot tango." Instead of dancing with Alice: say "The two of you swirl out into a feather-light Viennese waltz."
Especially since you want to customize the description of their dance further according to how the women are dressed. You do that with if-clauses inside or outside the double quotes.

[code]Instead of dancing with Mary: say “The two of you fall into a[if Mary wears the red dress] steaming hot[end if] tango.[run paragraph on][if Mary wears the red dress] Her skirt flares; the candlelight shimmer in her eyes …[end if][paragraph break]”.

Instead of dancing with Alice:
if Alice wears the blue dress:
say “The two of you swirl out into a feather-light Viennese waltz. The candlelight shimmers in hers eyes; her skirt flares.”;
otherwise:
say “The two of you waltz around a bit.”
[/code]
(The [run paragraph on] thing is to prevent a line break due to the full stop before the if-clause; the [paragraph break] to force a paragraph break after double quoted text that doesn’t end with a full stop (it ends with an [end if]).)

You can control the description in the same fashion with clauses like [if Mary has confidence] (or [if Mary is confident] or whatever will be the correct syntax).

Instead of dancing with Mary: say "The two of you fall into a[if Mary is not confident] stulting[otherwise if Mary wears the red dress] steaming hot[end if] tango[if Mary wears the red dress]. Her skirt flares; the candlelight shimmer in her eyes[end if]."
You can also specify distinct instead rules for Mary according to whether she is confident or not.

Instead of dancing with Mary when Mary is not confident: say "'I'm sorry. I don't dance,' she says blushing."

Thanks a great deal. I think I understand some of it a bit better now… but I’m still having problems getting it to work.

This is what I have so far:

[code]“Dancing Demo” by Will414

Instead of examining player:
say “You have worn your favorite tuxedo, a slightly older but still refined suit. You have made sure the edges of the suit are crisp and neat. Your face is clean-shaven and your straight black hair is slicked back casually. With ice-blue eyes, you look around, hoping to find a beautiful young woman to dance with.”

A person can be confident or not confident.

Persuasion rule for asking a person to try doing something:
persuasion succeeds.

The Ballroom is a room. “This is the ballroom. There is a wide dance floor surrounded by tables draped with white cloth. Candlelight fills the dimly lit room.”

The Lounge is west of the Ballroom. “This is the lounge. There is a bar at one side and a number of small booths. One area of the floor is open and spacious, inviting some private dancing.”

A woman called Alice is here. Alice is confident. Alice is carrying a Red Dress. “A dark-haired beauty stands here, giving you a special smile when you look her way. She has on a miniskirt and a low-cut blouse, exposing the cleft of her perky cleavage. You remember her name is Alice.”

The description of Alice is “[if Alice is wearing Red Dress]With an eager smile, the dark-haired beauty twirls, lifting the hem of her short, adventurous carmine dress. The sleeveless affair hugs her body, accentuating her slim curves.[end if] Winking your direction, Alice beckons you over to the dance floor, hoping to have some more fun before the night is through.”

The Private Room is east of the Ballroom. “This spacious room has a large bed, fancy antique furniture, and a broad open living area. The glass-topped table has been slid to one side, making for even more open floor space.”

A woman called Mary is here. Mary is not confident. Mary is carrying a Blue Dress. “Smiling nervously from where she stands in the middle of the room, your friend Mary waves when you look her way. Her curly blond hair cascades down her shoulders and her green eyes sparkle like emeralds. She has on a pair of white slacks and a blue turtleneck sweater.”

The description of Mary is “[if Mary is wearing Blue Dress]The radiant young woman before you seems the picture of beauty in her elegant, royal blue dress. The hem of the dress reaches nearly to the floor, modestly covering her ample bosom.[end if] Smiling at you shyly, she holds out her hand, hoping for another chance to dance with you.”

Dancing is an action applying to one visible thing. Understand “dance [something]” or “tango [something]” or “dance with [something]” or “dancing with [something]” or “waltz [something]” or “waltz with [something]” or “tango with [something]” as dancing.

Check dancing:
if the noun is not a person, say “The girls might get jealous if you would rather dance with a [noun].” instead.

Instead of dancing with Mary when Mary is confident: say “[if Mary wears the Blue Dress]You can’t help but admire her innocent beauty as Mary walks up to you in that blue dress.[end if][run paragraph on] Taking Mary’s hands, you lead her out onto the floor, each of you smiling at each other as the music starts. Moving lightly and elegantly, the two of you stay in perfect rhythm, the soft beat of the music the only guidance you both need.”

Instead of dancing with Mary when Mary is not confident:
say “[if Mary wears the Blue Dress]You can’t help but admire her innocent beauty as Mary walks up to you in that blue dress.[end if] [run paragraph on]Taking Mary’s hand, you gently lead her out onto the floor, trying to calm her nerves as the slow beat of the music begins. It takes some time, but eventually, Mary’s smile becomes more natural and she begins to feel the rhythm of the music. The two of you press closer as her smile grows wider.”
now Mary is confident.

Instead of dancing with Alice: say “The two of you fall into a[if Alice wears the red dress] steaming hot[end if] tango.[run paragraph on][if Mary wears the red dress] Her skirt flares; the candlelight shimmer in her eyes.[end if] As the music picks up, you match each other stride for stride, both beginning to breathe heavily but grinning even more at each other. By the end of the fast-paced dance, you are both panting and flushed, staring into each other’s eyes.[paragraph break]”
[/code]

These are the errors I receive:

[code]This is the report produced by Inform 7 (build 6G60) on its most recent run through:

Problem. You wrote ‘Instead of dancing with Mary when Mary is confident’ , which seems to introduce a rule taking effect only if the action is ‘dancing with Mary when Mary is confident’. The part after ‘when’ (or ‘while’) was fine, but the earlier words did not make sense as a description of an action. I am unable to place this rule into any rulebook.

See the manual: 7.1 > Actions


Problem. You wrote ‘Instead of dancing with Mary when Mary is not confident’ , which seems to introduce a rule taking effect only if the action is ‘dancing with Mary when Mary is not confident’. The part after ‘when’ (or ‘while’) was fine, but the earlier words did not make sense as a description of an action. I am unable to place this rule into any rulebook.


Problem. You wrote ‘Instead of dancing with Alice’ , which seems to introduce a rule taking effect only if the action is ‘dancing with Alice’. But that did not make sense as a description of an action. I am unable to place this rule into any rulebook.

[/code]

The problem is that you have given the action the name “dancing” whereas in the instead rules you call it “dancing with”.
Changing “Instead of dancing with Mary” to “Instead of dancing Mary” (and so on) or, alternatively, changing “dancing” to “dancing with” in a couple of places, will solve the issue.

(I also noted you’ve forgotten a semicolon after the say phrase in one of the instead rules, before the “now Mary is confident”.)

And one more thing that trips everybody up at first.
Defining actions as applying to one visible thing—rather than simply one thing—doesn’t do what one would expect it to.
You define actions as applying to a visible thing when you want it to apply to things that are not “in scope”—i.e. not in the same room as the player, i.e. usually NOT visible to the player. (I guess the idea is that things you may wish to interact with may be visible from afar, even though they are not in the same room as the player. But still, what “visible” does in this context is to make the action apply also to things not present in the location, whether visible from that location or not.)
Moreover, to make that useful to the player, commands for such an action have to be defined with [any thing] (two words) rather than [something], or the player won’t have access to any elsewhere things anyway.

Aha, that did the trick (changing it to “dancing with” in the original rule). Thanks again.

Now there’s one final problem. I already–

Scratch that, I figured out the solution right before I clicked post. “can be worn” is not the same as “is wearable.” Easy fix.

Your explanation for visible came at just the right time. In order to get calling them to the Ballroom to work, I had to specify visible. Although technically they wouldn’t be visible… but I don’t have to tell Inform that.

Thanks a ton. I think with this, I can move on to the actual game/IF that I was hoping to make.

Here’s the end result of the demo:

[code]“Dancing Demo” by Will414

Instead of examining player:
say “You have worn your favorite tuxedo, a slightly older but still refined suit. You have made sure the edges of the suit are crisp and neat. Your face is clean-shaven and your straight black hair is slicked back casually. With ice-blue eyes, you look around, hoping to find a beautiful young woman to dance with.”

A person can be confident or not confident.

Persuasion rule for asking a person to try doing something:
persuasion succeeds.

Red Dress is a thing. Red Dress is wearable. Blue Dress is a thing. Blue Dress is wearable.

The Ballroom is a room. “This is the ballroom. There is a wide dance floor surrounded by tables draped with white cloth. Candlelight fills the dimly lit room.”

Calling is an action applying to one visible thing. Understand “call [any thing]” as calling.

Instead of calling Alice: say “Alice enters the ballroom with a demure smile on her face, looking incredibly alluring in her red dress and the soft candlelight.”;
now Alice is wearing Red Dress;
move Alice to Ballroom

Instead of calling Mary when Mary is not confident:
say “There is a gasp from behind the door and a decisive, ‘No! I can’t!’ Your pleading falls on deaf ears.”

Instead of calling Mary when Mary is confident:
say “Still shy, Mary’s cheeks flush a rosy color as she steps out onto the ballroom floor. Still, she smiles as she walks up to you wearing her blue dress and gratefully takes your offered hand.”;
now Mary is wearing Blue Dress;
move Mary to Ballroom

The Lounge is west of the Ballroom. “This is the lounge. There is a bar at one side and a number of small booths. One area of the floor is open and spacious, inviting some private dancing.”

A woman called Alice is here. Alice is confident. Alice is carrying a Red Dress. “[if Alice is wearing Red Dress]Alice has an exotic beauty about her as she looks your way. Her red dress hugs her hips and curves. Every movement of her lithe body is distractingly apparent.[end if][if Alice is not wearing Red Dress]A dark-haired beauty stands here, giving you a special smile when you look her way. She has on a miniskirt and a low-cut blouse, exposing the cleft of her perky cleavage. You remember her name is Alice.[end if]”

The description of Alice is “[if Alice is wearing Red Dress]With an eager smile, the dark-haired beauty twirls, lifting the hem of her short, adventurous carmine dress. The sleeveless affair hugs her body, accentuating her slim curves.[end if] Winking your direction, Alice beckons you over to the dance floor, hoping to have some more fun before the night is through.”

The Private Room is east of the Ballroom. “This spacious room has a large bed, fancy antique furniture, and a broad open living area. The glass-topped table has been slid to one side, making for even more open floor space.”

A woman called Mary is here. Mary is not confident. Mary is carrying a Blue Dress. “[if Mary is wearing the Blue Dress]Wearing her long blue dress, the innocent blonde smiles shyly, hands clasped in front of herself. Mary’s green eyes sparkle as her curly blonde hair cascades down her back.[end if][if Mary is not wearing the Blue Dress]Smiling nervously from where she stands in the middle of the room, your friend Mary waves when you look her way. Her curly blond hair cascades down her shoulders and her green eyes sparkle like emeralds. She has on a pair of white slacks and a blue turtleneck sweater.[end if]”

The description of Mary is “[if Mary is wearing Blue Dress]The radiant young woman before you seems the picture of beauty in her elegant, royal blue dress. The hem of the dress reaches nearly to the floor, modestly covering her ample bosom.[end if] Smiling at you shyly, she holds out her hand, hoping for another chance to dance with you.”

Dancing with is an action applying to one thing. Understand “dance [something]” or “tango [something]” or “dance with [something]” or “dancing with [something]” or “waltz [something]” or “waltz with [something]” or “tango with [something]” as dancing with.

Check dancing with:
if the noun is not a person, say “The girls might get jealous if you would rather dance with a [noun].” instead.

Instead of dancing with Mary when Mary is in the Ballroom:
say “There is soft applause as the music begins, gently dying away as the dance begins. From the surrounding tables, people watch with smiles on their faces, making Mary blush even more. You can’t help but admire her innocent beauty as Mary moves with you, her blue dress almost sparkling in the candlelight. The onlookers, too, seem rapt with her beauty. Holding Mary’s hands tightly, you lead the way through each beat, your movements becoming more natural as you move through the candlelight, each of you smiling at each other as the music starts. Moving lightly and elegantly, the two of you stay in perfect rhythm, the soft beat of the music the only guidance you both need. As the music comes to a finish, you are both smiling warmly at each other. Applause rises up again, louder than before. [paragraph break]Mary laughs and breaks away, quickly returning to her room.”;
move Mary to the Private Room

Instead of dancing with Mary when Mary is confident: say “[if Mary wears the Blue Dress]You can’t help but admire her innocent beauty as Mary walks up to you in that blue dress.[end if] Taking Mary’s hands, you lead her out onto the floor, each of you smiling at each other as the music starts. Moving lightly and elegantly, the two of you stay in perfect rhythm, the soft beat of the music the only guidance you both need.”

Instead of dancing with Mary when Mary is not confident:
say “[if Mary wears the Blue Dress]You can’t help but admire her innocent beauty as Mary walks up to you in that blue dress.[end if] Taking Mary’s hand, you gently lead her out onto the floor, trying to calm her nerves as the slow beat of the music begins. It takes some time, but eventually, Mary’s smile becomes more natural and she begins to feel the rhythm of the music. The two of you press closer as her smile grows wider.”;
now Mary is confident.

Instead of dancing with Alice when Alice is in the Ballroom:
say “The crowd begins murmuring approval as the two of you move out onto the dance floor. Once the music kicks off, there is an awed silence. You and Alice dance magnificently, your spicy hot tango catching the eyes of everyone around. The hem of her red dress flies up, catching the candlelight, constantly teasing without ever revealing. Her grin becomes more predatory as the dance moves on and your breathing gets heavier. As the song grinds to a halt, you are both left panting, staring into each other’s eyes. The onlookers clap loudly, cheering on your performance.[paragraph break]Alice slips away, sauntering back toward the lounge, beckoning you with a look over her shoulder.”;
move Alice to the Lounge

Instead of dancing with Alice: say “The two of you fall into a[if Alice wears the red dress] steaming hot[end if] tango.[run paragraph on][if Mary wears the red dress] Her skirt flares; the candlelight shimmer in her eyes.[end if] As the music picks up, you match each other stride for stride, both beginning to breathe heavily but grinning even more at each other. By the end of the fast-paced dance, you are both panting and flushed, staring into each others’ eyes.[paragraph break]”
[/code]

Oh! One last thing that is giving me a bit of trouble, but seems like it should be simple.

How can I get it so that if the player types ‘help’ it will show a list of possible commands? I know I would need to type in the list, but it keeps giving me errors.

A primitive but working implementation, I guess, would be just defining helping as an action applying to nothing or perhaps preferably as ‘an action out of world’, understanding “help” as helping, and writing a report helping rule to say “You can try any of these commands: DANCE, SING, EXAMINE, etc…”.

However, there are several extensions on the Inform 7 site that are useful to this and similar ends, and you may well want to have a look at them (or on Emily Short’s built-in Basic Help Menu extension): http://inform7.com/extensions/out-of-world/#Helping_and_Hinting.

A quick answer: Understand “help” or “hint” as a mistake (“The useful commands are foo, bar, lorem, and ipsom.”).

I’d suggest actually implementing a help function – something like this:

[code]Helping is a command out of world applying to nothing. Understand “help” and “hint” as helping.

Carry out helping:
say “Complete instructions on how to play the game go here. You could, for instance, UNTIE PRETZEL and observe the results.”[/code]

Hi, Will! A couple of issues that you might want to think about: Some of the descriptions tend to assume you’re in a room, but they can be printed even when you aren’t in the room. For instance, if you go into the Private Room and try “call mary/dance with mary/call mary/dance with mary” the results look kind of strange – the descriptions assume you’re in the ballroom. This seems like an issue to watch out for (I mean, I’ve never written anything with more than one room, so I’m not one to talk, but it seems like an easy trap to fall into).

Another small point is that the “dance with Alice” rule contains “if Mary wears the red dress,” which I think should be Alice.

A prose issue or two: I would think that cleavage couldn’t be perky, but only what’s on either side of it. And when the hem of a dress is modestly covering someone’s bosom, I fear that either a modifying clause or something else is dangling.

Seriously, it’s impressive to code something up that makes any sense at all – just that it’s always worth poking your code to see if it behaves oddly somehow.

Thanks Jim, Ron, and Felix (again) – those did the trick!

Oh trust me, there’ll be a lot of poking going on. I’ve only had about an hour a day to fiddle with this since that first post of mine. Like half an hour before work and half an hour after. Once I get a day off, I’m sure I’ll find a lot of things that need refining or outright fixing.

Also, I did notice the ‘perky’ thing during a test run earlier, but the hem/bosom one I didn’t catch. That… is a rather amusing image.