So I was really happy to apply this code to CZK and see how it worked. Unfortunately, it didn't work great! See, my "grammar helper" stuff uses the "anything" grammar token, so any object is fair game. Since CZK has several guns, >EMPTY GUN got a "Which gun do you mean, this gun or that gun or... ?"
Nothing else could be done about this at the grammar level so I had to look other places. Luckily, FindObject determines what objects are available at any point, so it just took some digging and examination to find a good place to test against an AnythingTokenCheck routine.
if not AnythingTokenCheck(obj)
{
#ifset DEBUG
if debug_flags & D_FINDOBJECT
{
print "[FindObject("; obj.name; " ["; number obj; "], "; \
objloc.name; " ["; number objloc; "]): "; \
"false (AnythingTokenCheck returned false)]"
}
#endif
return false
}
Now let's look at the AnythingTokenCheck routine:
I check for a parent of obj just so we can dismiss any objects not currently in any room or container straight away, and then it can check against the location. This way, >EMPTY will only be used against objects within scope.
Now, it doesn't seem like people generally use the anything grammar token for much other than ASK/TELL, but I still think AnythingTokenCheck will be useful whenever people do use them for other means, and now it's there to be replaced when people need it.
No comments:
Post a Comment