I do not think that that makes sense. Your command pattern will only be a match if both object1 and object2 are identified. If object2 is absent, Quest says "
I don't understand your command." because the pattern matching fails. If object2 is not recognised it says "
I can't see that. (fjghjhj)" (or whatever). It only runs your script if both object1 and object2 are defined, so there is no need to test if that is the case.
I have looked at the core libraries, and I am more confused than ever. It is in OnEnterRoom:
<function name="OnEnterRoom" parameters="oldRoom">
<![CDATA[
game.displayroomdescriptiononstart = false
if (IsDefined("oldRoom")) {
if (oldRoom <> null) {
if (HasScript(oldRoom, "onexit")) {
do (oldRoom, "onexit")
}
}
}
// etc
So here it is apparently checking if the parameter was sent. But Quest throws an error if a function is expecting a parameter, but is not sent one (like this: "
Error running script: No parameters passed to TestFunction function - expected 1 parameters"), so again it seems redundant.
The other two places it is used is in a couple of scripts. This is from Coreparser, and is related to what you said:
<script type="script">
<![CDATA[
if (not IsDefined("object2")) {
object2 = null
}
//etc.
And in CoreTypes:
<changedparent type="script">
if (game.pov = this) {
if (IsDefined("oldvalue")) {
OnEnterRoom(oldvalue)
}
else {
OnEnterRoom(null)
}
}
// etc.
How can oldvalue or object2 be defined in these places? Where do they exist? What is their scope? I understood variables to be defined only within the scope of the script itself.