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

Using ofclass with PlaceInScope [INFORM, newbiesque]

0 views
Skip to first unread message

there...@yahoo.com

unread,
Mar 26, 2006, 8:36:19 AM3/26/06
to
As an exercise, I'm coding a simple map of my apartment. There are two
walk-in closets, with the light switches on the outside. For now, if
the doors are open, there is light in the walk-ins (eventually, that
will only be true if the relevant bedroom light is on -- although the
'darkened' bedroom won't actually be thedark). I know how to Place In
Scope individual items (from IBG's "Captain Fate"), but since there are
two very similar closets with similar doors, I figure the rules should
be the same and I shouldn't duplicate similar code. Especially since I
aspire to make a dungeon crawl with lots and lots of doors, keys, and
darkness! Kidding. Anyway, I figured on using classes:

Class HomeDoor
with description "Perfectly ordinary, off-white door.",
has door scenery openable;

Class WalkIn
with description "Come on out.";

Now, I know my doors work properly, because originally I didn't take
away the closet light at all. I could use them from either end. So,
in my entry point routines (after Initialise and DeathMessage):

[ InScope person item;
if (person == player && location == thedark && real_location == (item
ofclass WalkIn))
{ PlaceInScope(item in parent(player) (ofclass HomeDoor));
}
return false;
];

That's the version that compiles without errors, but just doesn't work.
I also tried:

if (person == player && location == thedark && real_location ==
(ofclass WalkIn))

and:

if (person == player && location == thedark && real_location ==
ofclass WalkIn)

and got the following errors:

Title.inf(366): Error: Brackets mandatory to clarify order of: "=="
> if (person == player && location == thedark && real_location == ofc ...etc
Title.inf(366): Error: Missing operand for "&&"
> if (person == player && location == thedark && real_location == ofc ...etc

Naturally, I feel pretty stupid, because this error message is being
pretty clear with me, and I still don't get it. I've been looking
through the archives here, the DM4, and the IBG. Maybe I'm not so good
at searching, but I'm not finding an answer. Like I said, I know how
to do it the repetitive way, but I'm trying to be efficient.

Eric Eve

unread,
Mar 26, 2006, 9:35:00 AM3/26/06
to
<there...@yahoo.com> wrote in message
news:1143380179.4...@v46g2000cwv.googlegroups.com...

> That's the version that compiles without errors, but just doesn't
> work.
> I also tried:
>
> if (person == player && location == thedark && real_location ==
> (ofclass WalkIn))

I don't claim to be any kind of Inform expert, but shouldn't that
be:

if (person == player && location == thedark && real_location

ofclass WalkIn)

In other words, ofclass is already a logical operator, it doesn't
need to be (and can't meaningfully be) combined with the equality
operator (==).

-- Eric


there...@yahoo.com

unread,
Mar 26, 2006, 10:33:59 AM3/26/06
to
Thanks. I know you're right about ofclass being an operator, and it
compiles without errors, but this is what happens:

The Bedroom
Description . . . There is a closet to the northeast, and . . . .

>open closet door
You open the door to the closet.

>ne

Bedroom Closet
Description . . . The exit is west.

>close door
You close the door to the bedroom.

Ooh, darkness.

>[ANY NEXT MOVE]

Both WinFrotz and Frotz 2002 just crash. Winfrotz says "Fatal:
Illegal opcode", and Frotz just says "Fatal".

To try and sort this out, I compromised on what I want, and altered the
line to this:

if (person == player && location == thedark && real_location ofclass
WalkIn)

{ PlaceInScope(item in parent(player));
}

. . . I gather this should place everything in the room in scope.
Instead of crashing, the above gameplay ended like this:

>open door

[** Programming error: tried to test "in" or "notin" of nothing **]

[** Programming error: nothing (object number 0) has no property
parse_name to read **]

[** Programming error: tried to test "in" or "notin" of nothing **]

[** Programming error: nothing (object number 0) has no property
parse_name to read **]
You can't see any such thing.

. . . and any other move generated similar errors, or more.

This is getting important, because there's also the bathrooms, and all
the light switches. For the sake of moving on, I'm doing a
repetitive-code version, but I'll never get around to an interesting
story-game at this rate!

Paul E Collins

unread,
Mar 26, 2006, 10:47:00 AM3/26/06
to
there...@yahoo.com wrote:

> PlaceInScope(item in parent(player));

I think "item in parent(player)" will give a true or false value, and
then you'll be trying to place the resulting (numeric) value in scope
instead of an object, hence lots of errors. Do you just mean "item"?

Eq.


Eric Eve

unread,
Mar 26, 2006, 10:48:11 AM3/26/06
to
<there...@yahoo.com> wrote in message
news:1143387239.0...@v46g2000cwv.googlegroups.com...

Well, the following line looks highly suspect to me:

{ PlaceInScope(item in parent(player) (ofclass HomeDoor));

The argument to PlaceInScope should be an object. Perhaps what
you're trying to do is something like:

[ InScope person item;


if (person == player && location == thedark && real_location
ofclass WalkIn)

objectloop(item in parent(player))
if (item ofclass HomeDoor)
PlaceInScope (item);

return false;
];

-- Eric


signwriter

unread,
Mar 26, 2006, 11:27:03 AM3/26/06
to
there...@yahoo.com wrote:

> if (person == player && location == thedark && real_location ofclass
> WalkIn)
> { PlaceInScope(item in parent(player));
> }
>
> . . . I gather this should place everything in the room in scope.
> Instead of crashing, the above gameplay ended like this:
>
>
>>open door
>
>
> [** Programming error: tried to test "in" or "notin" of nothing **]

It's a while since I touched any code myself, and my already pitiful
skills have gone rusty; but that "item in parent(player)" doesn't feel
right to me.

Perhaps you could try something like:

if (person == player && location == thedark && real_location ofclass WalkIn)
{

objectloop(item in parent(player)) PlaceInScope(item);
}

Perhaps this won't work, or doesn't do quite what I think it does; like
I said, it's been a while. Let us know how it goes?

there...@yahoo.com

unread,
Mar 26, 2006, 1:07:28 PM3/26/06
to
Worked like a charm, it did. Thanks, Eric!

Apparently I didn't understand objectloop as well as I thought.

there...@yahoo.com

unread,
Mar 26, 2006, 1:17:15 PM3/26/06
to
That would be the correct way to do the compromise I tried, yes. It
would make any object in the room available in darkness. Again, I
failed to understand the purpose of objectloop. All's well now, I
think. Thanks.

there...@yahoo.com

unread,
Mar 26, 2006, 1:31:19 PM3/26/06
to
Yep. Basically I'm imitating code without understanding the actual
operations, and guessing at shortcuts or how to enhance working code.
If I understood what I read in the DM4 better, I probably would have
already known about the true-false/numeric nature of "item in
parent(player)".

So, between the three of you that have answered so far, I've got it
working.

Now I need to decide exactly how I'm giving these closets light.
Currently, I'm giving them light in an After routine for opening the
door, but then, if the door was open at the beginning of the game,
there's no light! I can figure this out, but I'm not sure what's the
most logical way. Suggestions welcome.

0 new messages