Roger Firth's IF pages

Home

InFancy -- using Inform objects

Email
Back up

Here's a quick roundup of some of the standard object property variables and attribute flags, and how you can use them at run-time.

Library properties and attributes

The Inform Library defines about 48 property variables (those marked "++" are additive, explained when we cover classes):

add_to_scope
after ++
article
articles

before ++

cant_go
capacity

d_to
daemon
describe ++
description
door_dir
door_to

e_to
each_turn ++

found_in

grammar

in_to
initial
inside_description
invent

life ++
list_together

n_to
name ++
ne_to
number
nw_to

orders
out_to

parse_name
plural

react_after
react_before

s_to
se_to
short_name
short_name_indef
sw_to

time_left
time_out

u_to

w_to
when_closed
when_off
when_on
when_open
with_key

The Library also defines about 31 attribute flags:

absent
animate

clothing
concealed
container

door

edible
enterable

female

general

light
lockable
locked

male
moved

neuter

on
open
openable

pluralname
proper

scenery
scored
static
supporter
switchable

talkable
transparent

visited

workflag
worn

These definitions are heavily inter-related with the actions and verbs supplied with the standard Library: for example, the verbs WEAR/DON and REMOVE/SHED/DISROBE/DOFF invoke the actions Wear and Disrobe respectively; these in turn use the object's clothing and worn attributes. But that doesn't stop you using Library attributes for your own purposes, if that makes logical sense, and it certainly doesn't prevent you from creating your own definitions.

Using properties and attributes

Compare and contrast:

A property variable ...

Whereas an attribute flag ...

is usually a single (16-bit) word, but can be an array of up to 32 such words

is always stored as a single bit

can contain anything: a number, an address of a dictionary word, a (pointer to a) string, a (pointer to a) routine

is either true (on, present, set) or false (off, absent, unset)

may either be a common property, pre-declared by the directive Property prop_name; (as are all of the standard 48), or an individual property. A common property applies to all objects whereas an individual property, which can be instantiated simply by using a new prop_name in the with segment of an object definition, applies only to that object. Only 62 common properties can be declared, but there is no effective limit on the number of individual properties (so those are what I recommend you to use)

are all common, pre-declared by the directive Attribute attr_name; (as are all of the standard 31). An attribute applies to all objects. Only 48 attributes can be declared

can be tested at run-time by if (iname provides prop_name) ...; and by statements like if (iname.prop_name == value) ...; (for an array, by statements like if (iname.&prop_name-->0 == value) ...; )

can be tested at run-time by if (iname has attr_name) ...; and if (iname hasnt attr_name) ...;

can be changed at run-time by iname.prop_name = value; (for an array, by iname.&prop_name-->0 = value;)

can be changed at run-time by give iname attr_name; and give iname ~attr_name;

the property variable number is defined by the Library but not used; it is freely available in every object for you to use for your own purposes

the attribute flag general is defined by the Library but not used; it is freely available in every object for you to use for your own purposes

Notes

  1. In all cases, you can use the keyword self in place of iname when an object is referring to its own properties and attributes.
  2. The statements about limits on the number of properties and attributes apply to the Inform compiler and the Z-machine; for the new Glulx compiler and Glulxe virtual machine the limits are much higher.
  3. Also, Glulx uses 32-bit words, which means that the construct iname.#prop_name returning the number of bytes occupied by the prop_name array should be treated with caution. Using Inform you must divide this value by two to derive the number of entries in the array, whereas using Glulx you must divide by four.

In the next pages, we'll talk about some of the more commonly-encountered properties and attributes, starting with those that control the object's name and the way that it's addressed.