Inform 7 [Custom action STRAIGHTEN PICTURE - "applying to nothing/one thing..."]

Instead of straightening the picture:
Say “As you straighten the picture, a ring falls out from behind it and lands on the floor.”;
if the ring is undiscovered:
now the ring is discovered.
now the ring is in the Closet.
otherwise: say “The picture is straight, there is now need to adjust it.”

sorry new at this but can’t figure this out. I want to straighten a picture and have something drop from behind. I used ring as an example.

First, here’s a tip when you’re quoting your code on this forum. You can post it with the indentations preserved, which people will need in order to help. To do this, first paste the code in the message window, then highlight all the code and click the button that looks like this at the top of the message: </>

This turns it into ‘preformatted code’. The result looks like this:

Instead of straightening the picture:
	say “As you straighten the picture, a ring falls out from behind it and lands on the floor.”;
	if the ring is undiscovered:
		now the ring is discovered;
		now the ring is in the Closet;
		say “The picture is straight, there is now need to adjust it.”;

About what’s not working – it usually helps to quote the exact message Inform prints about what went wrong to the forum.

However, first, let’s get your indentation and line endings right.

You’ll see in my pasted version, every line of code either ends with a semicolon or a colon. You had a couple of periods where you need semicolons. A so-called code block never has a line ending with a period in the middle of it. End the whole block with a semicolon, too (i.e. after adjust it.") Incorrect formatting can sink a whole compilation with cryptic messages, because formatting by its nature stops lines and sentences running into each other and forming lines that are, to Inform, nonsense.

Now if you take this correctly formatted code and paste it back in your game, does it work in the context of your game? Or do you still get an error message? If you do, what is it?



thank you for responding.
I think it has something to do with this.
Straightening is an action applying to nothing. Understand “straighten” as straightening.

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

if i use examine instead of Straightening it works fine, however i want the player to adjust a crooked picture.

Right, so you need to change the definition of straightening.

When you say ‘applying to nothing’, that means the player can’t type STRAIGHTEN (THING). You’ve defined the grammar as “straighten” means straightening. As is, the player can type STRAIGHTEN to perform the straightening action, but can’t target nouns with it.


straightening is an action applying to one thing. Understand "straighten [something]" as straightening.



Also, anticipating the consequence of creating a new action that works, the straightening action will need at least one line of code to create a default response for when the player tries it on something you’ve written no specific code for.

After adding the new straightening definition, the outcome of straightening other random items in your game will be that Inform simply prints nothing in response and goes straight to the next command prompt.

You can add the following to create a default response:

Report straightening something:
	say "You don't need to straighten [the noun].";

This response is working on the assumption that straightening will be an infrequently used action in the game, processed by Instead rules like the one you wrote for the picture. However if the whole mechanic of the game was about straightening pictures, you’d invert this logic and make the Report rule a positive outcome (“You straighten [the noun].”) and write some Carry Out code about straightening stuff, and block attempts to straighten non-straightenable stuff with Check rules. But that’s the approach for when the action is expected to work the majority of the time.



Thank you so much, I am truly grateful. works perfect.

1 Like