Newbie Question. Throw

Simple Question…not so simple task (for me )

How does one throw a held object (in inventory) at another object in the room?

Thanks Wizards!

If it’s about Inform 7: Throwing it at is an action that Inform 7 already knows. So this should work:

The World is a room.
The tree is a thing in the World.
The stone is a thing in the World.
The player is carrying a book.
Instead of throwing the book at something:
	if the second noun is the tree:
		say "You throw the book at the tree.";
		now the book is in the location of the player;
	otherwise:
		say "Why throw a book at [the second noun]?"

(If the player isn’t carrying the book, they will try to pick it up. You might want to “continue the action”, too, depending.)

1 Like

Thanks! That helps alot.

As a fellow Inform 7 newbie, I wanted to pass along a couple of tips that helped me a bunch, and might make diagnosing and solving problems like the above a little easier.

First, when you’re testing your game in the IDE, you can type ACTIONS to display how your commands are being interpreted – so this would tell you when you try THROW STONE AT TREE that Inform understands the command. This is also useful because some commands are understood in ways that can seem non-obvious (the one that most tripped me up is that SAY FOO TO BAR is actually understood as ANSWER BAR THAT FOO). (This is talked through in Chapter 24 of Writing with Inform, all of which is worth looking over, in fact – it comes close to the end of the book, but it’s worth jumping ahead even if you’re trying to work your way through from front to back).

Second, you can use the Index tab to find the Actions -> Command listing, which displays every command your game currently understands, including both the standard set and anything you’ve added. This can be very helpful for figuring out whether to build something new, or replace or modify an already-existing command.

Hope this is helpful!

6 Likes