Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Inform 7 Assembly / Part of Question

8 views
Skip to first unread message

Roland

unread,
Jan 4, 2010, 1:04:53 AM1/4/10
to
I am playing around with making complex objects with multiple parts,
and have come to a point where I find it necessary to be able to
access both the owner and other parts of the owner in order to
determine the proper response.

In the below, in theory the monitoring station has a temperature
sensor and a safety cover, and inside the safety cover there is a
safety display. In practice, for the sake of simplicity (and for the
sake of the cleanliness of Inform 7's output) I made the safety
display (which ought to more correctly be a part of the safety cover)
a part of the monitoring station as well.

I would like to be able to vary the description of the safety display
based on whether the safety cover is opened or closed, and based on
the temperature range value of the temperature monitor.

In other words, I need somehow to force Inform 7 to make decisions
(whether by [if] statements or more complicated means) to consider the
properties of other parts of its parent object.

Please do not offer work arounds that simplify the below... it may
work with this specific example, but like I said I am working on
numerous complex objects, in some of which such complexity is
unavoidable. If there is no way to reasonably access "sibling" parts
with Inform 7, I probably need to switch to TADS 3, a thought I do not
greatly relish.

The excerpted source code awaiting wise counsel is below:

The hall is a room.

A monitoring station is a kind of thing.

A safety cover is a kind of container.
A safety cover is openable.
A safety cover is usually closed.
A safety cover is part of every monitoring station.

A safety display is a kind of thing with the description "[The noun]
appears blank.".
A safety display is a part of every monitoring station.

A temperature range is a kind of value.
The temperature ranges are cold, warm, and hot.
The temperature range is usually warm.

A temperature sensor is a kind of thing.
A temperature sensor is a part of every monitoring station.
A temperature sensor has a temperature range.

The QZ1000 is a monitoring station in the hall.

---

Thanks!

- Roland

Jim Aikin

unread,
Jan 4, 2010, 2:01:02 AM1/4/10
to
On 1/3/2010 10:04 PM, Roland wrote:
> I am playing around with making complex objects with multiple parts,
> and have come to a point where I find it necessary to be able to
> access both the owner and other parts of the owner in order to
> determine the proper response.

TADS isn't as forbiddingly complex as you may think ... but in fact,
Inform will let you access sibling parts. Here's a quick test game. It
has nothing to do with your scenario, but if I'm understanding your
question, it demonstrates the syntax you need to use.

[code]
The Lab is a room.

The player wears a hat. The headband is part of the hat. The feather is
part of the hat. The crown is part of the hat. The brim is part of the hat.

Instead of taking something that is part of something (called the owner):
repeat with item running through things that are part of the owner:
if item is not the noun:
say "Do you mean taking [the item]?"

Test me with "take feather".
[end code]

First we identify the owner, and then we print out a list of the
siblings of the item that the player has tried to take. Does that help?

--JA

Mike Tarbert

unread,
Jan 4, 2010, 2:47:07 AM1/4/10
to

Most straightforward:

[code]
A safety display is a kind of thing with the description "[if the item
described is part of something incorporating an open safety cover][The
item described] reads [the temperature range of a random temperature
sensor incorporated by the holder of the item described].[otherwise]You
can't see [the item described] while it's safety cover is closed.".
[/code]

More flexible / easier to read / safer:

[code]
A safety display is a kind of thing with description "[display msg of
item described].".

To say display msg of (SD - a safety display):
let M be the holder of SD;
let TS be a random temperature sensor incorporated by M;
if M incorporates an open safety cover,
say "[The SD] reads [the temperature range of TS]";
otherwise say "You can't see [the SD] while it's safety cover is closed".

test me with "x display / open cover / x display".
[/code]

Note the use of "random temperature sensor incorporated by..." which is
an inelegant (and hopefully soon - to - be - gone) syntactical quirk of
I7. It also means if the monitor in question has more than one sensor
attached to it, this won't work. (Since this doesn't seem to be the case
based on your example, I didn't bother to get into how to go about
handling that situation.)

Also note that the sensor will read cold. That's because the default
value for a new kind of value is the first one listed. Your line "The
temperature range is usually warm" doesn't change this (and should
probably be rejected by the compiler). If you want to assign a default
temp range for the sensors, you need to add it to the definition of the
sensor kind, as in:

A temperature sensor has a temperature range. It is usually warm.

HTH,
Skinny Mike

Mike Tarbert

unread,
Jan 4, 2010, 4:17:52 AM1/4/10
to
Mike Tarbert wrote:
> ... while it's safety cover is closed.".

Of course that should be "its." :)

Skinny Mike

0 new messages