I'm trying to see if I can build a situation handler in a TADS 3 library. An example of what I mean by situation handler is in my own Tapestry project (not TADS-based):
https://github.com/jeffnyman/tapestry/b ... tuation.rbTapestry is a library that someone would include in their script. So you can see there that certain situations are looked for at compile time for a script and, if those are found, a very specific problem message is generated.
So here's an example, TADS-based, for a mainCommon() in a putative library. Let's say someone doesn't define gameMain in their own game source. A situation handler would specifically say that:
Code:
mainCommon(prop) {
try {
gameMain.(prop);
} catch(ProgramException pe) {
"PROBLEM: You must define a gameMain object in one of the source files in your project.";
}
}
The problem there is the 'catch'. ProgramException isn't the right thing to put, I guess, but that said, nothing really is. I don't thing anything will be caught because you'll get an "error: undefined symbol 'gameMain'." In other words, I don't think I'm in a situation where an Exception instance is being thrown. So then I thought I might try this:
Code:
mainCommon(prop) {
if (propDefined(&gameMain) == nil) {
"PROBLEM: You must define a gameMain object in one of the source files in your project.";
}
The problem there, of course, is that I have to call propDefined on something. I can't use self in that context. And there really is no other object I could apply the check to. Keep in mind, this is for a library, not for a game using a library.
And, again, the goal here is to provide a library that guides the user via recognition of the specific situation and then tailored output for that situation.