Cinderella's Chores: Help with Understanding Tasks & NPC's

Hello, Everyone -

I’ve just started making a game with Inform7, I’m a novice and beginning to understand how to create objects and new commands, but I was hoping someone could give me some tips in creating this small puzzle. Here’s a sample scenerio:

I’d like an NPC to give the player an object, we’ll call it a ticket to the ball, after they’ve completed a chore around the house.

For the chore I’d like make them mop a floor. This involves a mop, a mop bucket, soap, and a dirty floor.

First they have to put/pour the soap in the mop bucket, then put the mop in the soapy water, then mop the floor. And after that some way set the chore to being ‘done’, and allow the NPC to give them the ballroom ticket when they see them next.

If I was just going to have the player mop the floor with a simple command, and set the floor to being ‘mopped’ I could implement it pretty easily. But I’m not quite sure how to go about fitting the adding of soap to the bucket, and putting the mop in the soapy water before mopping can be accomplished.

Any ideas? :stuck_out_tongue: Thanks…

You may want to take a look at this post. It pretty much does what you want. You can then add a “done/not done” truth state to record whether a task is completed.

Hope this helps.

Thank you this is great!

I needed a challenge, so I whipped this up. My code may have a bug or two, but I think it will do what you have in mind. BTW, this is not a simple puzzle at all to implement, as there are several objects that have to be in specific states. I didn’t add comments, but studying the code will probably give you a few insights.

[code]“Mopping” by Jim Aikin.

Include Plurality by Emily Short.

Use the serial comma.

The Scullery is a room. “Surprisingly, there are no skulls in the scullery. Protruding from the wall is a faucet, and a large cupboard stands in one corner. The floor is [if the floor is dirty]filthy[else]sparkling clean[end if].”

Section 1 - The Faucet and Water

The rusty iron faucet is scenery in the Scullery. The faucet can be flowing. “The faucet protrudes from the wall. [if flowing]Water is gushing from it, and flowing down the drain.” Understand “tap”, “spigot”, “spout”, and “pipe” as the faucet.

The drain is scenery in the Scullery. “The drain is conveniently positioned below the faucet. [if the faucet is flowing]Water is gushing from the faucet and flowing down the drain.”

Instead of switching on the faucet:
if the faucet is flowing:
say “Water is already coming out of the faucet.”;
else:
try turning the faucet.

Instead of switching off the faucet:
if the faucet is not flowing:
say “The faucet is already turned off.”;
else:
try turning the faucet.

Instead of turning the faucet:
if the faucet is flowing:
now the faucet is not flowing;
say “You twist the tap, and the flow of water halts.”;
now the gushing water is off-stage;
else:
now the faucet is flowing;
now the gushing water is in the Scullery;
say “You twist the tap, and water gushes from the faucet and flows down the drain.”

The gushing water is scenery. “The water is emerging from the faucet and flowing down the drain.” Understand “flowing” and “gushing” as the water.

Instead of taking the gushing water:
say “You dabble your hand in the water, but it simply flows on down the drain.”

Instead of switching off the gushing water:
try turning the faucet.

Section 2 - The Cupboard and Implements

The large cupboard is a closed openable scenery container in the Scullery. “You know the cupboard well, because you’re always being told to clean things.”

The old iron bucket is an open container in the cupboard. The description of the bucket is “The old iron bucket is your trusted friend. [bucket-contents]”. The bucket can be full or empty. The bucket is empty. Understand “full” as the bucket when the bucket is full. Understand “empty” as the bucket when the bucket is empty.

To say bucket-contents:
if the bucket-water is in the bucket:
say “In the bucket is a quantity of [if the bucket-water is soapy]sudsy[end if] water.”

The soap bottle is in the cupboard. The description of the soap bottle is “The handy plastic squeeze-bottle says ‘CLEANSER’ on the label.” Understand “handy”, “plastic”, “squeeze-bottle”, and “cleanser” as the soap bottle.

The mop is in the cupboard. The description of the mop is “The only weapon with which you’re entrusted by your wicked stepmother is the long-handled mop. [mop-state]”. Understand “long”, “handled”, and “long-handled” as the mop. The mop can be wet or dry. The mop is dry. The mop can be soapy. The mop is not soapy. Understand “wet” as the mop when the mop is wet. Understand “dry” as the mop when the mop is dry. Understand “soapy” as the mop when the mop is soapy.

To say mop-state:
if the mop is wet:
say “The mop is wet[if the mop is soapy] and soapy[end if].”

The bucket-water is scenery. The indefinite article of the bucket-water is “some”. The printed name of the bucket-water is “water in the bucket”. Understand “water” and “bucket water” as the bucket-water. The bucket-water can be soapy. The bucket-water is not soapy. Understand “soapy”, “suds”, and “sudsy” as the bucket-water when the bucket-water is soapy. The description of the bucket-water is “The [if soapy]soapy[end if] water is sloshing around in the bucket.”

Filling is an action applying to one thing. Understand “fill [something]” as filling.

Check filling something:
say “[The noun] [is-are] not something you can fill.”

Instead of filling the bucket:
if the bucket-water is in the bucket:
say “You have already filled the bucket.”;
else if the gushing water is not in the Scullery:
say “There’s nothing here to fill the bucket with.”;
else if the player does not carry the bucket:
say “You need to be holding the bucket in order to fill it.”;
else:
now the bucket-water is in the bucket;
now the bucket is full;
now the faucet is not flowing;
now the gushing water is off-stage;
say “You fill the bucket with water from the faucet, and turn off the faucet.”

Filling it with is an action applying to two things. Understand “fill [something] with [something]” as filling it with.

Check filling something with something:
say “There seems to be no compelling reason for you to do that.”

Instead of filling the bucket with the gushing water:
try filling the bucket.

Instead of inserting something into the bucket:
if the noun is the soap bottle:
if the bucket is empty:
say “The soap will do no good in a dry bucket.”;
else if the bucket-water is soapy:
say “You have already added soap to the water in the bucket.”;
else if the player does not carry the soap bottle:
say “You need to be holding the soap bottle in order to do that.”;
else:
now the bucket-water is soapy;
say “You squirt soap into the water in the bucket, producing a quantity of suds.”;
else if the noun is the bucket-water:
say “You already did that.”;
else if the noun is the gushing water:
try filling the bucket;
else if the noun is the mop:
if the bucket is empty:
say “There would be no point in doing that, as the bucket is empty.”;
else:
now the mop is wet;
if the bucket-water is soapy:
now the mop is soapy;
say “You dip the mop in the bucket.”;
else:
say “There would be no point in doing that.”

Instead of inserting something into the bucket-water:
try inserting the noun into the bucket.

Dipping it into is an action applying to two things. Understand “dip [something] in/into [something]” as dipping it into.

Check dipping it into:
say “There seems to be no compelling reason for you to do that.”

Instead of dipping the mop into the bucket-water:
try inserting the mop into the bucket.

Instead of dipping the mop into the bucket:
try inserting the mop into the bucket.

Section 3 - Carrying Out the Chore

The floor is a scenery supporter in the Scullery. The floor can be dirty. The floor is dirty. “The floor is [if dirty]filthy[else]sparkling clean[end if].” Understand “dirt” and “dirty” as the floor when the floor is dirty. Understand “sparkling” and “clean” as the floor when the floor is not dirty.

Mopping is an action applying to one thing. Understand “mop [something]”, “clean [something]”, and “scrub [something]” as mopping.

Check mopping:
if the player does not carry the mop:
say “To do that, you would need to be holding a mop.” instead;
else:
say “That is not one of the chores your wicked stepmother has ordered you to do.”

Instead of mopping the floor:
if the floor is not dirty:
say “You have already mopped the floor. It fairly sparkles!”;
else if the player does not carry the mop:
say “To do that, you would need to be holding a mop (preferably wet and soapy).”;
else if the mop is dry:
say “You push the dry mop around on the floor, accomplishing exactly nothing.”;
else if the mop is not soapy:
say “You push the wet mop around on the floor, turning some of the filth into mud but accomplishing very little.”;
else:
now the floor is not dirty;
say “You industriously mop the floor. In a few minutes it’s sparkling clean!”

Mopping it with is an action applying to two things. Understand “mop [something] with [something]”, “clean [something] with [something]”, and “scrub [something] with [something]” as mopping it with.

Check mopping it with:
if the second noun is not the mop:
say “A mop would be a better choice.” instead;
else:
say “[The noun] [is-are] not in need of a scrubbing.” instead.

Instead of mopping the floor with the mop:
try mopping the floor.

Section 4 - The Wicked Stepmother

The wicked stepmother is a person in the Scullery. “Your wicked stepmother is standing here, glaring at you.” The description of the wicked stepmother is “Your wicked stepmother is standing here, her arms folded as she scowls sternly at you.” The indefinite article of the stepmother is “your”. Understand “step”, “ma”, “mom”, and “mother” as the wicked stepmother.

Every turn:
if a random chance of 1 in 4 succeeds:
say “Your wicked stepmother [one of]says, ‘Lazy girl!’[or]growls at you.[or]snorts contemptuously.[or]chuckles nastily.[or]says, ‘Well? What are you waiting for?’[or]picks her teeth with a hatpin.[at random]”.

The stepmother carries a ticket. The description of the ticket is “The ticket is a large rectangle of cardboard on which is printed ‘ADMIT ONE TO THE BALL.’” Understand “large”, “rectangle”, “cardboard”, and “ball” as the ticket. The printed name of the ticket is “ticket to the ball”.

Instead of asking the stepmother for the ticket:
if the floor is dirty:
say “‘Not until you’ve finished your chores, lazy girl!’ your stepmother snaps.”;
else:
now the player carries the ticket;
say “Your stepmother inspects the floor with great care, as if searching in vain for a speck of dirt. ‘Very well,’ she concedes at last, reluctantly handing you the ticket. As your heart bumps for joy, she adds nastily, ‘Not that anyone at the ball will want to dance with you. You reek of onions!’”

Instead of kissing the stepmother:
say “You’d rather kiss a toad.”[/code]

Here’s what I’m working with, but I still can’t get the game to understand “mopping [something]”

[code]Mopping is an action applying to one visible thing.

Understand “mop [something]” as mopping it.

Instead of mopping something, say “Try specifying what you want to mop.”

Check mopping something: if the noun is not dirty, say “[The noun] does not need to be mopped.” instead; if the player is not carrying the mop, say “You would need a mop to do that.” instead.

Carry out mopping something:
The noun is now clean.[/code]

Wow, thank you Jim, I was just trying to work this out and looking at your manual when I noticed your post here–I’ll get on this right away!

I’m wondering if I’m doing something wrong with copy/paste - when I try to run this I get colon/indentation syntax errors–is there some special way I should copy and paste code?


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

In Section 1 - The Faucet and Water:

Problem. The phrase or rule definition ‘Instead of switching on the faucet’ is written using the ‘colon and indentation’ syntax for its 'if’s, 'repeat’s and 'while’s, where blocks of phrases grouped together are indented one tab step inward from the ‘if …:’ or similar phrase to which they belong. But the phrase ‘if the faucet is flowing’ , which ought to begin a block, is immediately followed by ‘say “Water is already coming out of the faucet.”’ at the same or a lower indentation, so the block seems to be empty - this must mean there has been a mistake in indenting the phrases.

Yes, if you try straight copy-paste the tab stops will get converted into spaces, which Inform doesn’t recognize as indentations. Here’s how to copy code from the forum and preserve the tab stops:

Hit “reply” to the post containing the code you want to copy.
In the box for typing your reply comment, the original post will appear.
Copy the code from the post as it appears in the box for typing your reply comment.
Hit “cancel” so you don’t actually post a reply (unless you want to).

This will preserve tab stops as the original poster had them; if they copied their code from the Inform IDE, the tab stops should be correct. If they just typed code into the forum, then the tabs will be spaces and you’ll have to convert them – but usually with code of any complexity, people have tried it out in the Inform IDE, so the tabs should be there.

As for the problem you posted above, I think the issue is in the line

Understand "mop [something]" as mopping it.

As I understand it, you only need to use “it” in this way when you have an action that applies to two things; if you leave out “it” maybe this will work.

Thanks, I figured there was some trick to it, but probably would’ve never guessed without your help! Jim’s mopping code works seamlessly btw as far as I can tell.

You shouldn’t use “one visible thing” in this case. That’s only for actions that work at a distance, where you don’t need physical access to the noun. Since you can’t mop a floor unless the floor is at hand,use the normal “one thing” instead.

Very nice.

I did spot a couple of (possible) bugs as I read it. For example, when filling the bucket, you should probably also check that the player is in the scullery (or just check that “the gushing water is in the location”) so they can’t fill the bucket from another room (if you had any, which you don’t seem to, but presumably a more complete story would have some). Also, I didn’t notice anything that would prevent the player from just taking the bucket-water from the bucket and carrying it in her hands. (That said, I didn’t actually test the story, so I might’ve missed something.)

It might also be nicer to understand filling as “fill [something preferably held]” (and so on), so that the player would automatically try to pick up the bucket before filling it if it’s not already carried.

Also, the kissing rule is a nice touch, but for an actual story I’d like to see more custom responses to attempts to interact with the stepmother. For instance, I’d be very much tempted to try somehow dumping the bucket of water on top of her just to see what happens.

The bucket-water is scenery, so it can’t be taken, but the default response (“That’s hardly portable”) is silly, and would need to be changed. It’s these edge cases that start to breed like rabbits whenever you implement a complex puzzle like this.