The funcCall () in the room description is something that I’d like to do in every room of the game without having to remember to add it. I know I can use modify Room to alter the base Room class behavior but I cannot figure out if the above is possible and if it is, how to do it.
Where would I need to make changes to allow for adding default content to all rooms? (I’m using TADS 3 and adv3.)
modify Room
myfunc ()
{
"Printed with every room description. ";
}
roomDesc ()
{
myfunc();
inherited;
}
;
roomA: Room 'Room A'
"This is the first room. "
east = roomB
;
roomB: Room 'Room B'
"This is the second room. "
east = roomC
;
+ me: Actor
;
roomC: Room 'Room C'
"This is the third room. "
east = roomA
;
George, thank you very much, that did exactly what I was trying to do. My mistake was that I was trying to do the same with desc, not roomDesc and that didn’t work.
Come to think of it, I don’t really get why one works and the other doesn’t - I double-checked and I used the same syntax but when I try to override desc this way, my function doesn’t get called. I looked at the source code of both desc() and roomDesc() in Thing.t but I don’t grasp the difference in their implementations.
I think the use of the room template might make it less obvious. When you use the room template you are really defining desc = ... . Because desc is a method on the Room class, you are overriding that method in the object, so the object won’t inherit any modification of the Room's desc.
Thank you - I think about half an hour after posting my message I realized that setting the room description to a display string (“something”) would not call the base class function. Your solution worked; thank you again for taking the time to help.