Re: Inform: How to tell diff. between a room & an item?


Tue, 12 Sep 1995 12:24:33 -0500

gdr11@cl.cam.ac.uk (Gareth Rees) writes:
>"Sam Hulick" <shulick@guava.ucs.indiana.edu> wrote:
>> How can one tell if an object 'o' is a room or an item?
>
>There is no way in Inform to do this. Items and rooms are the same
>kinds of data. You could even use a room as an item or an item as a
>room, as long as you were careful with the various aliased properties.
>
>Perhaps if you explained why you need to know whether an object is a
>room or not, then I could suggest a sensible work-round.
>

For my "missed" meta verb. Right now I check for a room if parent(o) ==
zero and o.&name = 0. But recently, I've found that I might want to use
the name property on rooms.. so now what?

[ MissedSub o sc;
print "Items are ", OBJECT_SCORE, " points, rooms are ", ROOM_SCORE, ".^";
for (o = selfobj+1: o <= top_object: o++)
{
if (o has scored && o hasnt visited && o hasnt moved)
{
print "You missed "; PrintShortName(o);
if (parent(o) == 0 && o.&name == 0) { print " (room)"; sc = sc + ROOM_SCORE; }
else { print " (item)"; sc = sc + OBJECT_SCORE; }
print ".^";
}
}
print "This accounts for a total of ", sc, " points.^";
];

-- 
--- Sam Hulick ------------- shulick@indiana.edu ---------------------
Systems Consultant        | Homepage:
Indiana College Placement |    http://copper.ucs.indiana.edu/~shulick/
  and Assessment Center   | PGP public key available on request