Enterable supporters and reaching outside rules

I have a room with a number of enterable supporters, some of which can be accessed from a number of the others. What is a clear, concise and exhaustive way of writing a reaching outside rule, when there is access to a number of supporters from one of the other supporters?

One thing I did in one of my games (which is now in the Comp), which has a similar situation, is I had a separate routine, which was accessed when the player was on a supporter (these were movable supporters, which made it complicated)–it would gather up a list of objects (including other supporters which may be nearby) that were reachable, which included objects that were on/within other objects. Then, if any of the objects in the player’s command required touchability, and were not on that list, access was denied. But I don’t know if this is an efficient way to do it…??

Specifically, this is what I am using:

Oreach is a list of objects which varies. Oreach is {nothing}. To objectsreachable: if the holder of the player is: -- the swivel chair: now oreach is {the file cabinet, the small picture window, the iron desk}; repeat with n running through things which are on the iron desk: add n to oreach.[….]

A rule for reaching outside of the swivel chair: objectsreachable; if putting something on something: if the second noun is listed in oreach: allow access; otherwise: say "You will have to get off your lazy duff, first."; deny access; otherwise if inserting something into something: if the second noun is listed in oreach: allow access; otherwise: say "You will have to get off your lazy duff, first."; otherwise if the noun is listed in oreach: allow access; otherwise if throwing something at something: if the noun is listed in oreach: allow access; otherwise: say "You will have to get off your lazy duff, first."; deny access.

Is this a good form??

Thanks

As an aside, is there a better way to type out the code here so that it shows the indentations in the rules??

Use three backticks on a single line before and after.
01

Here's some code.
     Here's some indented code.
          Three backticks on a single line before and after.

Just realize if you’re typing in the code, you have to use the spacebar instead of the tab key. I think in I7, five spaces = tab.

1 Like

I’d use a relation here.

Mutual reachability relates things to each other.
The verb to be reachable from implies the mutual reachability relation.

To decide what object is the penultimate enclosure of (the item - a thing):
    let the current level be the item;
    while the current level is not a room:
        let the current level be the holder of the current level;
    decide on the current level.

Indirect reachability relates a thing (called X) to a thing (called Y) when the penultimate enclosure of X is reachable from the penultimate enclosure of Y.
The verb to be available to implies the indirect reachability relation.

Now you just have to establish the relationships:

The chair is reachable from the table.
[This automatically works in reverse, too! No need to specify the other direction.]

And then you can use them freely!

Rule for reaching inside a supporter (called the destination) when the player is enclosed by a supporter (called the source):
    if the destination is reachable from the source, allow access;
    deny access.

In your own rules, you also have a convenient shorthand now for “is this on a supporter reachable from the player’s supporter?”:

If the apple is available to the player:
1 Like

Thank you both so much!

I feel like I have barely touched all of the possible nuances of Inform7. It’s like I am always learning something new, which is great.

Draconis,

I take it that if I want a denial message for, say, an apple on a chair, when the player is standing on a desk, I can say –

A rule for reaching outside of the oak desk:
     if the noun is available to the player:
          allow access;
     otherwise:
          say "You'll need to get off the desk, first.";
          deny access.

Or do I need only the second clause (the denial) in a reaching outside rule for that specific supporter?

Whoops, that didn’t come out right, not sure how to type the backticks…??

Okay that got it.

Daniel,

What if you want one supporter to be accessible from another, but it’s only a one-way connection?

Then you’d want to change the “mutual reachability” relation to “…relates various things to various things” (which makes it non-reciprocal). Probably give the relation a different name, too, since it’s no longer mutual.

1 Like

Thanks–I figured that I could do that. I love how flexible Inform7 is!

Draconis,

I typically see an object that is on the floor of a room as unavailable to the player if the player is on a supporter–most of the time. With these relations, how do I ‘deny access’ if the holder of the object is the room?

Thank you for your patience!

That would be a “reaching outside” rule, since it’s about the player’s enclosure, not the target’s. You can make a new adjective (“tall” or such), then make a “rule for reaching outside a tall supporter” that denies access.

I think I may have a bit of a misunderstanding about ‘reaching outside’ rules, here. Is a reaching outside rule stopped when the rule gets to ‘allow access’ or ‘deny access’ (then goes no further with the remaining clauses)?

I take it I will need to write separate reaching outside rules for each of my supporters, to deal with objects that are not on a supporter. I guess the question I have with this is, will the interpreter run through the reaching inside rules (the ones you showed me), first, before checking the reaching outside rules? The reason I ask is that I may have clauses in my reaching outside rules (for the individual supporters) that may stop the process. Example–there are several other objects in the room (with the supporters) that are not reachable from any of those supporters (I don’t want actions possible with these objects while the player is on one of the supporters). Can I write a rule like this –

The comfy chair is reachable from the oak desk.
Rule for reaching outside of the comfy chair:
     say "You'll have to get off your lazy duff, first.";
     deny access.

Will this allow the player to sit in the comfy chair, put objects on the desk, take them off, etc, and still prevent the player from fiddling with the portrait on the wall, or the rug on the floor?

Thanks for your time.

“Reaching inside” rules determine if you’re allowed to touch things that are on a particular supporter (*). “Reaching outside” rules determine if you’re allowed to touch things while you’re on a particular supporter (*). If either one denies access, the action will fail; they both need to allow it.

(*) Not just supporters, technically, but also containers, vehicles, even rooms!

2 Likes

Okay Daniel, one more question and I will leave you alone.

I am still struggling with this. Here is what I have so far (along with the reaching inside rules mentioned above–

An officesupp is a kind of supporter.  The oak desk, John's chair, the straight-backed chair and the comfortable chair are officesupps.

The oak desk is reachable from John's chair.
The oak desk is reachable from the straight-backed chair.
The oak desk is reachable from the comfortable chair.
A rule for reaching outside of the oak desk:
     if putting something on something:
          if the second noun is available to the player and the noun is available to the player:
               allow access;
          if the second noun is an officesupp and the noun is available to the player:
               allow access;
          if the second noun is available to the player or the second noun is an officesupp:
                if the noun is enclosed by the player:
                    allow access;
         say "[The second noun] is out of reach from your position on John's desk.";
         deny access;
     if inserting something into something:
          if the second noun is available to the player and the noun is available to the player:
               allow access;
          if the second noun is an officesupp and the noun is available to the player:
               allow access;
          if the second noun is available to the player or the second noun is an officesupp:
               if the noun is enclosed by the player:
                    allow access;
          say "[The second noun] is out of reach from your position on John's desk.";
		deny access;
          if the noun is an officesupp:
               allow access;	
          if the noun is available to the player:
               allow access;
          if the noun is not available to the player:
               say "[The noun] is out of reach from your position on John's desk.";
               deny access.

With this, so far, I have only been able to put things on the office (John’s) chair, but not take them off, if I am on the desk. I keep getting the message '[the noun] is out of reach from your position on the desk." Even though the noun is available, because the oak desk is reachable from John’s chair. I just can’t figure out what I am doing wrong…? is there some point where I have to outright say that the stuff on the chair is available to the player, when the player is on the desk?

Thanks

I guess my final question is do I have to state outright whether something is available to the player or not??

Disregard the code I have above, I have changed it completely. Now what I have works, all except about ‘to be available to the player’. For some reason, when I put an object on a supporter, while standing on another supporter (both of which are reachable from each other) that object is not being marked as ‘available to the player’. While I have pasted your code into my project exactly, and made the office chair reachable from the oak desk, and I can put an object on the chair while standing on the desk, I cannot take the object back. I put some code into the reaching outside rule for the desk like so–

say "[The noun] cannot be reached from your position on the desk,[if the noun is available to the player] though it was available[otherwise]  because it's unavailable[end if].";
deny access.

I am getting ‘…because it’s unavailable.’ Is there something missing??

Looking over this again, I might actually disentangle it from Reaching Inside/Reaching Outside in order to keep things cleaner. Or rather, I’d hook it in at the end of the rulebook, but do all the processing separately.

Last reaching outside:
    if the action requires a touchable noun and the noun is not available to the player:
        say "[The noun] [are] out of reach.";
        deny access;
    if the action requires a touchable second noun and the second noun is not available to the player:
        say "[The second noun] [are] out of reach.";
        deny access.

This depends on “available” working, so I’ll see about debugging that later. But this way you don’t need a new reaching rule for every action.