but this isn't a thing, a kind of thing or a kind of value

Hello,

I’m struggeling (once again) with the syntax and probably the problem, that Inform seems more intelligent than it really is ^^

"ReachPos" by HtF

Every thing has a number called ReachPos. The ReachPos of something is usually 2.

Testroom is a room.

Wardrobe is a supporter in Testroom.
The candle is on the Wardrobe.

Definition: The ReachPos of something is 3 if it is supported by the Wardrobe.

What I want to do:

Things have a ReachPos that is usually 2. Now, there are special circumstances in which that is not so - like things high up on a supporter. I thought the above bit of code would do the trick but Inform won’t be fooled. Is there some way to achieve what I want other than hardcoding it for every concrete item (which would mean I’d have to abandon the concept because it’d be way too onerous)?

[code]A thing can be tall.

Check taking:
if the noun is supported by a tall thing:
if the player is not on a supporter:
say “Your arms aren’t long enough to reach that.” instead.

After putting something on a tall thing:
say “You toss [the noun] onto [the second noun]. It’s up there, but good luck getting it down.”

Testroom is a room.

Wardrobe is a tall supporter in Testroom.
The candle is on the Wardrobe.

a coffee table is an enterable supporter. It is in testroom.
a teapot is a container. It is on coffee table.
[/code]

Thanks for the reply - I see I have shortened the example a bit too much - your post is what I started with and found it to become unmanageable. So … let me try to provide additional detail and thus clarify my initial question:

I am working with body positions - like lieing down, sitting, kneeling, standing. Depending on the position a person can reach things at a different height.

Let us assume we have a nightstand with 2 drawers and something on top.

The player - if he is lieing on the floor - could open bowth drawers, rummage through the content of the lower drawer but could not do so with the content of the upper drawer nor could he interact with an object on the nightstand.

If the player was kneeling or sitting, he could open, take and interact with anything in or on the nightstand.

If we had a 3 drawer wardrobe, however, he could open all three drawers, only access things in the lower and middle drawer and not interact with anything inside the top drawer or something on top of the wardrobe.

To have a quick means of checking I thought about 2 variables:

position of the player, reach of the player
position of the object

If the object was at a height within (player position - reach of the player ) to (player position + reach of the player) the player can interact with it (open, take, push, switch on, etc.) and if it was outside of that boundary he couldn’t.

So I wanted something like say the height of the upper drawer would be, say, 3 but the content in the drawer would be 4. And if the player placed something onto the wardrobe its height would be set to 4 as well. I might try to code that within the drop statements but if possible something like my failed definition in the example would be way easier to handle.

Since the player can drop things and put things into containers and there’s quite a bit of random placement involved as well I am looking for a numerical approach like I sketeched out in my example but which, alas, doesn’t compile.

Hi Harald,

You’re trying to create something called ReachPos which is both a variable (to be set) and a calculated value (calculated by a phrase or definition). Basically, Inform won’t let you do that. (Well, it’s not usually supposed to.) Try something like this:

[code]Testroom is a room.

Wardrobe is a supporter in Testroom.
The candle is on the Wardrobe.

A supporter has a number called height. The height of a supporter is usually 3.

To decide what number is the ReachPos of --/a/the (T - a thing):
if T is on a supporter (called S):
let H be the height of S;
decide on H;
otherwise:
decide on 2.

Before taking:
say “[The noun] is currently at a height of [ReachPos of the noun].”

test me with “get candle / drop it / get it”.[/code]

HTH

Ah … that does look promising, indeed.

Is there a way to check if things are “on the floor”? Can’t test at the moment but if an item is inside of a container which is in a room … does the room enclose the item (since it encloses the container) or not? Stuff on the floor does play a certain role so it’s important to decide if something is on the floor or not.

Here we go … ok, as I though the room encloses everything … but unless I missed something:

To decide what number is the ReachPos of --/a/the (T - a thing):
	if T is on a supporter (called S):
		let H be the height of S;
		decide on H;
	otherwise if T is enclosed by a container (called C):
		Let H be the height of C;
		decide on H + 1;
	otherwise:
		[item must be on the floor unless I missed something?]
		decide on 0.

So if it is not ON a supporter or IN a container it must be on the floor, right … or did I miss a check?

Yes, if A encloses B and B encloses C, then A encloses C.

Yes, I thought so … it’s kinda logical ^^

The question is … when is a thing to be considered “on the floor”?

Is “it is not on a supporter and it is not in a container” sufficient as a check?

You can check “the holder of” something, which will be the thing immediately containing it. If the holder of something is a room, it’s on the floor. (It could also be a container, supporter, or person.)

Thanks for the info - I’ll update my statement above to additionally check for that and use an “otherwise” to see if there’s something I’m still missing. I assume items carried by NPCs or somesuch might still not be covered - I’ll see if that “otherwise” fires to show unanticipated things happening. :slight_smile:

The thing is, you’re going to need a more robust decide phrase to deal with combinations of stuff. (A candle on a stand on a wardrobe, etc.) Something like:

[code]Testroom is a room.

the Wardrobe is a supporter in Testroom. The description of the wardrobe is “It’s got a drawer.”
The candle is on the Wardrobe.
The top drawer is a container that is part of the wardrobe.
The top drawer is openable and closed.
A stand is a portable supporter in the top drawer. The height of the stand is 1.

A supporter has a number called height. The height of a supporter is usually 3.
A container has a number called height. The height of a container is usually 1.
A person has a number called height. The height of a person is usually 1.

To decide what number is the ReachPos of --/a/the (T - a thing):
let Holder be the holder of T;
let H be 0;
while Holder is not a room:
now H is H plus the height of Holder;
now Holder is the holder of Holder;
decide on H.

After examining:
say “[The noun] is currently at a reach of [ReachPos of the noun].”; continue the action.

test me with “x wardrobe / x candle / get candle / x it / drop it / x it / get it / put it on wardrobe / x drawer / open drawer / x stand / get it / put it on wardrobe / x it /get candle / x it / put it on stand / x candle”.[/code]

Honestly though, I would make a new rulebook for deciding ReachPos. You’re going to want to play with lots of different things – especially if you’re going to be adding the player’s posture to the mix. Having a super-convoluted phrase will grow into a nightmare – trust me.