Commands for requiring an object to enter a room

I’m a noob, but I’ve stumbled upon something that has literally fascinated me since I found inform7 a week ago when I decided to see if text games were available. To my surprise, they weren’t only available, but with inform 7, you could create them! I used to play these games on my grandma’s old Tandy, i’m 34 now, but I remember text games vividly. I’ve learnt so much by just using the manuals, but sometimes it just doesn’t seem to touch on certain commands and issues. But out of everything I’ve learned, my answer is probably simple and right under my nose, I feel. So I searched for Inform’s forum and i’m coming to you guys! I’ll probably become a regular member, can’t say for sure but I don’t plan on giving up inform. Anyways…

Here’s my issue. I have a well. I’ve made a room inside of it, you can enter it by simply pressing “D” for down. But I want to make an exception to where you can only enter this well if you have a “rope”. An object. I could go the more complicated route, in the Inform manual where it talks about how to tie off ropes among other things, but I’m a noob at this point so I don’t want to get too deep. I’m gonna take it slow. I was hoping to just “write around it”.

What do I need to type to make this happen? When I click “D” without a rope, I want it to be declined. Only when the player is “in possession of the rope” do I want the player to be allowed to enter this well. Just wondering what the commands would be.

I feel if I can get this down, some of the other problems i’m having would fall right in place. Hopefully. Thanks and cheers!

When the player types “d”, the action that will follow is “going down”. (You can check this by typing “actions on” in your game.) What you need to do is create a rule for going down that checks whether the player carries a rope.

Actions come with six types of rules: before, instead, check, carry out, report, after. In this case, we want a “check” rule, because we want to check whether the player carries a rope, and abort the action if she doesn’t.

So you’d need to write something like this:

Check going down: if the player carries the rope: say "You use the rope to descend."; otherwise: say "You'll need a rope for that." instead.
Notice the “instead” at the end: that tells Inform that after printing this text, the action should be aborted. If you don’t use “instead”, the action will just go on, which is what happens when the player carries a rope.

But we’ve probably made one mistake in that code, because it now applies to every going down action. Probably, you want to apply it only in a certain room. I don’t know how the room is called, but let’s say it is “Kitchen”. Then the code you want is:

Check going down in the Kitchen: if the player carries the rope: say "You use the rope to descend."; otherwise: say "You'll need a rope for that." instead.

Didn’t work for some reason. This is exactly how I put it, done a copy paste.

And here’s what it told me…

oh wait, let me try the vertical thing

ok I fixed one of the issues. Got it lined up but still got this.

When you past code from a forum like this, it will contain spaces where Inform 7 wants you to use tabs. So it might look right, but be wrong. You need to make sure that the second and fourth lines start with one tab, and the third and fifth lines start with two tabs. (And no spaces.)

Awesome it worked. Now I have a better understanding of how to type these things out. THis just opened up a lot of new possibilities for me, Thanks man.

It is actually usually possible to preserve tabs when you copy-paste from the forum, if you use this one weird trick:

Click the “quote” button on the lower-right corner of the post with the code you want.
The comment box will open up with the text of the original post inside it.
Find the code in the comment box and copy it.
Hit “cancel” on the comment (unless you actually do want to reply to it).

This will preserve the tabs on the original code if the original poster pasted it from the Inform IDE, and you won’t have to correct them by hand. When someone just types code into the comment box there won’t be any tabs to preserve, and you’ll have to fix them by hand, but usually code is pasted in from the IDE. (But I see that in this case Victor seems to have typed the code in by hand, so you had to fix the tabs by yourself anyway!)

This should probably go in the forum FAQ, if there is one, because it’s very not obvious!