When you specify a Class which supports creation of objects at run-time,
the compiler actually pre-allocates the objects -- including one spare to support recreate() --
as children of the Class itself.
This parentage leads to problems with IndirectlyContains().
For example, this code: causes this run-time error: This is the coding of IndirectlyContains: and the fix adds an additional test: An alternative (and arguably better) solution would be to
fix objectloop so that it omits the pre-allocated objects (which, after all,
don't yet exist in any real sense).
A game which really did want to loop through them
could use something like:
About Patches
Issue L61032
IndirectlyContains() fails with dynamic objects
Submitted by: Roger Firth
Appeared in: Library 6/10 or before
Fixed in: Library 6/11
Problem
Class Thing(3);
...
objectloop (x ofclass Thing && IndirectlyContains(location,x))
print (name) x, "^";
[** Programming error: tried to find the "parent" of Thing **]
[** Programming error: tried to find the "parent" of Thing **]
[** Programming error: tried to find the "parent" of Thing **]
[** Programming error: tried to find the "parent" of Thing **]
Solution
[ IndirectlyContains o1 o2;
while (o2~=0)
{ if (o1==o2) rtrue;
o2=parent(o2);
}
rfalse;
];
[ IndirectlyContains o1 o2;
while (o2~=0)
{ if (o1==o2) rtrue; if(o2 ofclass Class) rfalse;
o2=parent(o2);
}
rfalse;
];
objectloop (x in Thing) ...
Last updated 17 April 2013.
This site is no longer supported; information may be out of date.
Maintained as a historical archive by the Interactive Fiction Technology Foundation.
Copyright 1993-2018 IFTF, CC-BY-SA unless otherwise noted.
This page was originally managed by Roger Firth.