Sunday, November 16, 2014

another DoLook update

So, while testing the new Roodylib code on old released code such as Kent Tessman's Spur, I came across things like Spur's "Little Jimmy" character where the object's/character's inventory is listed in the long_desc.  The problem with that is that verblib.h (and my update to DoLook) still print a new line after the long_desc even if everything has already been listed and no object-content text is going to be printed.

Originally, I was going to make a post here about how the best solve for that is to make a before routine for the object for DoLook, have it run the long_desc and return true so the rest of DoLook is never called.  Just as I was going to write the post here, though, I thought, eh, I'll take another look and see if I can fix DoLook since the before routine method sort of seems like weaseling out.

The good news is, I think I found a solution I'm generally happy with.

replace DoLook
{
local i,skip_ahead, no_fullstop, has_children, count
if not light_source
VMessage(&DoLook, 1) ! "It's too dark to see anything."
else
{
if ( object is transparent or !(object is living, transparent) or
object is platform or (object is container and
(object is open or object is not openable))) and
object is not quiet ! and object is not already_listed
{
for i in object
{
i is not already_listed
if i is not hidden
{
has_children = true
count++
}
}
}
if not object.long_desc
{
#ifclear FORCE_DEFAULT_MESSAGE
if object is container and
object is not quiet and object is not living
{
if (object is openable,open)
print "It's open.";
Perform(&DoLookIn,object) ! so we get "it is closed." if closed
skip_ahead = true
}
elseif has_children
no_fullstop = true
else
#endif
! "Looks just like you'd expect..."
VMessage(&DoLook, 2)
}
if (object is transparent or !(object is living, transparent) or
object is platform or (object is container and
(object is open or object is not openable))) and
object is not quiet ! and object is not already_listed
{
has_children = false
for i in object
{
if i is not hidden and i is not already_listed
{
has_children = true
break
}
}
}
if i and object ~= player and not skip_ahead
{
if count = 1
NEW_PARSE &= ~PRONOUNS_SET
local tempformat
tempformat = FORMAT
FORMAT = FORMAT | NOINDENT_F
list_nest = 0
if not no_fullstop
print ""
WhatsIn(object,has_children)
FORMAT = tempformat
NEW_PARSE |= PRONOUNS_SET
}
run object.after
#ifset AUTOMATIC_EXAMINE ! objects are examined automatically when picked up
if object is not examined
object is examined
#endif
#ifclear NO_LOOK_TURNS
return true
#endif
}
}
view raw gistfile1.txt hosted with ❤ by GitHub


You may notice that the call to WhatsIn has an extra argument.  Normally, WhatsIn goes through every child of the object and clears its already_listed attribute before going on to list things.  I updated it so it does not do that step if the second routine argument is true (which is why DoLook has to clear already_listed before the object's long_desc property is even run).

This is how Little Jimmy's long_desc would look with the new code:


(Basically, the only change is that it marks the taffy as already_listed- of course, I probably should have moved it so it's only marked if Jimmy is holding the taffy, but in this case, it shouldn't affect anything.)

No comments:

Post a Comment