How To Destroy a Crumbly Wall

Hello all! I’m a bit of a newbie to inform 7 and I would like to know how to set up a wall which disappears after it has been hit with a hammer five times. I’ve had a lot of trouble with this and its an important part of the game. Below is the code:

Attacking it with is an action applying to two things and requiring light. Understand “attack
[something] with [something]” and “hit [something] with [something]” as attacking it with.
[smithy]
The Smithy is a room. “The soot of the forge still hangs about the place. Beside the forge is an anvil with a hammer on it. The south wall is old and crumbly.” The smithy is southeast of the city square.

The wall is scenery in the smithy. The wall can be broken or unbroken. The wall is unbroken.

Check examining wall:
if wall is unbroken:
say “A wall with a sturdy door stands here. The door is locked, and looks impassible, but the wall looks a little crumbled.”;
now the printed name of the wall is “crumbly stone wall”;
if wall is broken:
say “The remains of the stone wall lies here.”;
now the printed name of the wall is “pile of rubble”.

Check going south:
if player is in the smithy:
if wall is unbroken:
say “The intermolecular bonds of the crumbly stone wall stops you from passing through matter. You bump your nose, feeling quite foolish.” instead;
if wall is broken:
continue the action;
if player is not holding second noun:
say “You strike the wall with your hand, bruising your knuckles. That must feel silly.”;
continue the action.

The wall has a number called crumble. The crumble is 1. The things can be hit with the hammer.

The hammer is an object. The hammer is on the anvil. The bulk of the hammer is 15. Things can be hit with the hammer.

Check attacking the wall with:
if second noun is the hammer:
if crumble is 1:
say “There is a resounding crack. Some dust falls down and a couple small stones come loose.”;
now the crumble is 2;
if crumble is 2:
say “A few small cracks run across the wall.”;
now the crumble is 3;
if crumble is 3:
say “The wall seems to teeter slightly.”;
now the crumble is 4;
if crumble is 4:
say “The wall shakes for a moment, and then falls apart. Rocks of all sizes fall to the ground, and the wall completely collapses, revealing the room behind the door!”;
now the crumble is 5;
now the wall is broken;
if crumble is 5:
say “You’ve already knocked the wall down; must you add insult to injury?”;
otherwise:
say “You strike the wall, but to no avail.”.

The anvil is an object. The anvil is in the smithy.
Check taking anvil:
say “You’ve discovered a ruined city, and now you want to lug an anvil around all day? I mean really now, that’s weird.”
The anvil is a supporter.

[The Backroom]

The backroom is a room. The printed name is “The Backroom”. The broken stone wall is scenery in the backroom. The description is “The remains of the stone wall lies here.”
The sword is an object. The sword is in the backroom. The description is “Though now showing flecks of rust, it is still a masterpiece.” The damage-value of the sword is 34. The backroom is south of the smithy.

This seems to me like a bit of a complicated problem, but maybe it’s not. Feedback would be greatly appreciated.

Thanks,
–Kadric

1 Like

The basic structure seems to be working. Will it not compile? If so, there might be some indentation problems with your code. Like Python, white space is meaningful in Inform 7. (It’s hard to tell what your indentation is in your code excerpt. FYI, you can use the </> icon to mark code, and it will be displayed in a way that preserves indentation.)

Here’s a quick adjustment, with some references to further reading in Writing With Inform (the built-in documentation).

"Crumbling Wall"

Attacking it with is an action applying to two things and requiring light. Understand “attack
[something] with [something]” and “hit [something] with [something]” as attacking it with.

[smithy]

The Smithy is a room. “The soot of the forge still hangs about the place. Beside the forge is an anvil with a hammer on it. The south wall is old and crumbly.” The smithy is southeast of the city square.

The wall is scenery in the smithy. The wall can be broken or unbroken. The wall is unbroken.

Check examining wall:
	if wall is unbroken:
		say “A wall with a sturdy door stands here. The door is locked, and looks impassible, but the wall looks a little crumbled.”;
		now the printed name of the wall is “crumbly stone wall”;
	if wall is broken:
		say “The remains of the stone wall lies here.”;
		now the printed name of the wall is “pile of rubble”.

Check going south:
	if player is in the smithy:
		if wall is unbroken:
			say “The intermolecular bonds of the crumbly stone wall stops you from passing through matter. You bump your nose, feeling quite foolish.” instead;
		if wall is broken:
			continue the action;
		if player is not holding second noun: [??? - not sure what you want to do here]
			say “You strike the wall with your hand, bruising your knuckles. That must feel silly.”;
	continue the action.

The wall has a number called crumble. The things can be hit with the hammer.

The hammer is an object. The hammer is on the anvil. [The bulk of the hammer is 15.] Things can be hit with the hammer.

After attacking the wall with the hammer: [see WWI 7.5 After rules]
	increment the crumble of the wall;
	if crumble of the wall is: [see WWI 11.8 Otherwise]
		-- 1:
			say “There is a resounding crack. Some dust falls down and a couple small stones come loose.”;
		-- 2:
			say “A few small cracks run across the wall.”;
		-- 3:
			say “The wall seems to teeter slightly.”;
		-- 4:
			say “The wall shakes for a moment, and then falls apart. Rocks of all sizes fall to the ground, and the wall completely collapses, revealing the room behind the door!”;
			now the wall is broken;
		-- otherwise:
			say “You’ve already knocked the wall down; must you add insult to injury?”

After attacking the wall: [see WWI 19.6 Sorting and indexing of rules, WWI 19.7 The preamble of a rule]
	say “You strike the wall, but to no avail.”


The anvil is an object. The anvil is in the smithy.

Check taking anvil:
	say “You’ve discovered a ruined city, and now you want to lug an anvil around all day? I mean really now, that’s weird.”

The anvil is a supporter.

[The Backroom]

The backroom is a room. The printed name is “The Backroom”. The broken stone wall is scenery in the backroom. The description is “The remains of the stone wall lies here.”

The sword is an object. The sword is in the backroom. The description is “Though now showing flecks of rust, it is still a masterpiece.” [The damage-value of the sword is 34.] The backroom is south of the smithy.

This yields:

>S
The intermolecular bonds of the crumbly stone wall stops you from passing through matter. You bump your nose, feeling quite foolish.

>HIT WALL WITH HAMMER
There is a resounding crack. Some dust falls down and a couple small stones come loose.

>G
A few small cracks run across the wall.

>G
The wall seems to teeter slightly.

>G
The wall shakes for a moment, and then falls apart. Rocks of all sizes fall to the ground, and the wall completely collapses, revealing the room behind the door!

>G
You've already knocked the wall down; must you add insult to injury?

>S

The Backroom
You can see a sword here.
1 Like

Hi Kadric – welcome! One quick tip on posting code to the forums – you can use the preformatted text tool (the little </> icon in the toolbar) to post it in a way to preserves spacing and is usually a bit easier to read and debug. Anyway, here are some thoughts, hope they’re helpful!

First, I think that your Check examining wall rule is a little odd for a couple of reasons. Check rules should really be for catching whether the player can perform the action. For code that does something when the player successfully does the action, you usually want a Carry Out rule, and to report the outcome, you want a (logically enough) Report rule. The downside of doing things the way you’ve currently got them is that you’ll get the “A wall with a sturdy door stands here…” line, then “You see nothing special about the crumbly stone wall.” when the default examining action completes. The easiest way to do this is just to add a description to the wall, like so:

The description of the wall is "[if the wall is unbroken]A wall with a sturdy door stands here. The door is locked, and looks impassible, but the wall looks a little crumbled.[otherwise]The remains of the stone wall lies here.”

(Since the wall is scenery, you shouldn’t need to change the printed name).

Second, your check going south rule seems like it’s got some code that should go in a Check attacking it with rule instead (the “if player is not holding the second noun” bit).

Third, there are two issues with your attacking the wall with rule. First, you need to specify that you’re checking, and modifying, the crumble of the noun/wall. Second, the way you’ve got the conditions set, it looks like they’ll all fire in sequence, when I think the intent is that you need to hit the wall multiple times. If you flip the order of the conditionals (running from crumble 5 to 1) that should fix things.

Hope this is useful!

1 Like

This is how I’d do that instead:

Attacking it with is an action applying to two things and requiring light.
Understand "attack [something] with [something preferably held]" and "hit [something] with [something preferably held]" as attacking it with.

Check attacking it with:
	if the second noun is not carried, carry out the implicitly taking activity with the second noun;
	if the second noun is not carried, stop the action.

[smithy]

The Smithy is a room. "The soot of the forge still hangs about the place. Beside the forge is an anvil with a hammer on it. The south wall is old and crumbly."
The smithy is southeast of the city square.

The anvil is a supporter in the smithy.
Instead of taking anvil, say "You’ve discovered a ruined city, and now you want to lug an anvil around all day? I mean really now, that’s weird."

The wall is a closed and unopenable door.  It is south of the Smithy and north of the Backroom.
"[if closed]A wall with a sturdy door stands here. The door is locked, and looks impassible, but the wall looks a little crumbled.[otherwise]The remains of the stone wall lies here."

Instead of going through the closed wall:
	say "The intermolecular bonds of the crumbly stone wall stops you from passing through matter. You bump your nose, feeling quite foolish."

Instead of attacking the wall:
	say "You strike the wall with your hand, bruising your knuckles. That must feel silly."

The hammer is a thing on the anvil.  The description is "A sturdy metal hammer."

After attacking the wall with the hammer for the first time:
	say "There is a resounding crack. Some dust falls down and a couple small stones come loose."
	
After attacking the wall with the hammer for the second time:
	say "A few small cracks run across the wall."
	
After attacking the wall with the hammer for the third time:
	say "The wall seems to teeter slightly."
	
After attacking the wall with the hammer for the fourth time:
	say "The wall shakes for a moment, and then falls apart. Rocks of all sizes fall to the ground, and the wall completely collapses, revealing the room behind the door!";
	now the wall is open.
	
After attacking the wall with the hammer:
	say "You’ve already knocked the wall down; must you add insult to injury?"

[The Backroom]

The Backroom is a room.

The sword is a thing in the backroom. The description is "Though now showing flecks of rust, it is still a masterpiece."

It leverages the fact that doors already behave pretty much exactly as you want anyway, plus makes use of Inform’s built-in action counting. (Though you might need to use a self-counted value instead if e.g. you want the description of the wall to change depending on how many times it has been it.)

1 Like

Thank you for your help. I was really frustrated with this. This is great!

Thanks for the advice. This is really useful. I did not expect such a quick response.

Thank you. I didn’t know there was a built in action counter. Looks like I have several options.

@mirality – I thought of changing to “[something preferably held]”, too, but it didn’t seem to trigger an implicit take when I tried it out. Perhaps because it’s the second noun in the grammar line? (Or perhaps I just did something wrong?)

I agree that using the built-in action tracking is preferable, but I already had three citations for further reading! (@Kadric – mirality’s point is worthwhile. For your reference, see WWI 7.16 Repeated actions, but also see 7.17 Actions on consecutive turns. Glad to help.)

Ah, the action definition must specify a “carried thing” for the preferably held noun. It is mentioned parenthetically in WWI 17.4:

(If the action is one which positively requires that its noun be something carried, a command matching this token against something not carried will generate an automatic attempt to take it.)

So:

Attacking it with is an action applying to one thing and one carried thing and requiring light.

That’s why I added the extra Check rule.

That’s probably a better way to do it, yes. (Unless perhaps your story is going to allow the player to hit things with not-carried things like a wrecking ball…) I knew there was another way to do it but it escaped me at the time.