This looks very evil to me:
[rant]Scope checking something is an activity on objects.
Include (-
[ DoScopeActionAndRecurse domain nosearch context i ad n obj next_obj;
BeginActivity((+ scope checking +), domain)
if(ForActivity((+ scope checking +), domain) == false){
DoScopeAction(domain);
}
EndActivity((+ scope checking +), domain)
! (a)
if ((domain ~= nosearch) &&
((domain ofclass K1_room or K8_person) || (IsSeeThrough(domain) == 1))) {
obj = child(domain);
while (obj) {
next_obj = sibling(obj);
if ((domain == actor) || (TestConcealment(domain, obj) == false))
DoScopeActionAndRecurse(obj, nosearch, context);
obj = next_obj;
}
}
! (b)
if (domain provides component_child) {
obj = domain.component_child;
while (obj) {
next_obj = obj.component_sibling;
if ((domain == actor) || (TestConcealment(domain, obj) == false))
DoScopeActionAndRecurse(obj, 0, context);
obj = next_obj;
}
}
! (c)
ad = domain.&add_to_scope;
if (ad ~= 0) {
! Test if the property value is not an object.
#Ifdef TARGET_ZCODE;
i = (UnsignedCompare(ad-->0, top_object) > 0);
#Ifnot; ! TARGET_GLULX
i = (((ad-->0)->0) ~= $70);
#Endif; ! TARGET_
if (i) {
ats_flag = 2+context;
RunRoutines(domain, add_to_scope);
ats_flag = 0;
}
else {
n = domain.#add_to_scope;
for (i=0 : (WORDSIZE*i)<n : i++)
if (ad-->i)
DoScopeActionAndRecurse(ad-->i, 0, context);
}
}
];
-) instead of "DoScopeActionAndRecurse" in "Parser.i6t"
[/rant]
I’m using it to “glue” an off-stage object (which I’ll call Y) to an on-stage object (which I’ll call X), so that the former is automatically made visible whenever the latter is, via code like this:After scope checking {X}:
Place {Y} in scope, but not its contents. [so that it doesn't create infinite recursion or some other ugliness]
Making Y a component of X is attractive, but a PITA under my use case because its identity may change suddenly and I’d have to keep the physical model up-to-date; moreover there may end up being many X’s and many Y’s.
The alternative is to make a “fake Y” and attach it to X, and redirect actions to the real Y, but that feels ugly too. Y is understood in a variety of somewhat complex ways, printing it is not exactly trivial, and I’m not sure either would transfer to the fake Y very effectively.
Am I completely insane to be even considering this?