I have my follow Aaron code working, mostly, but there is one problem I can’t quite get around yet. And in moving it to my test-bed environment, I see another problem that, for whatever reason, I don’t seem to see in my game code.
I’ll start with that test-bed-only problem.
When Harry enters Room B (in the test bed environment), Aaron is waiting. Harry’s entry triggers an addAgendaItem() on the aaron object (implemented in actorBeforeAction() on the harry object).
So far, so good, all works. Harry enters the room, and Aaron is waiting for Harry to follow.
A follow Aaron command moves both characters to Room C.
Aaron is still inviting Harry to follow.
But when he does—north to Room D which is the second stop in the followAgendaItem’s connectorList—Aaron refuses to lead.
Even though the connectorList includes roomD as an endpoint, Aaron won’t go there.
As stated, this is a relatively minor thing at the moment, since for whatever reason (and I cannot spot the difference) it is working in the game code.
What is not working is when I try to interrupt the followAgendaItem. Aaron is not a patient man. Harry gets one shot at following him. If Harry does not follow Aaron to Room C but instead wanders into Room B-2 on his own, I want Aaron to leave and the followAgendaItem to be removed. I magically move Aaron to Room E and remove the agenda item with this code…
actorBeforeAction()
{
if(harry.location == roomA && aaron.location == roomB)
aaron.addToAgenda(followAaron);
if(harry.location == roomB2)
{
aaron.removeFromAgenda(followAaron);
aaron.moveInto(roomE);
}
}
…in the harry object.
A break point in the debugger verifies that this code is hit during a run of the game, and the debugger further verifies that the followAgendaItem is removed from aaron.agendaList.
When Harry proceeds into Room E, there's Aaron, as expected, but the prompt is still inviting Harry to follow him.
A follow command at this point does fail, but why the prompt? And how can I get rid of it?
Here’s the test-bed code…
[code]#charset “us-ascii”
#include <tads.h>
#include “advlite.h”
versionInfo: GameID
IFID = ‘243748b1-5310-4916-8436-890e9ccc16fd’
name = ‘test’
byline = ‘by Jerry Ford’
htmlByline = ‘by
Jerry Ford’
version = ‘1’
authorEmail = ‘Jerry Ford jerry.o.ford@gmail.com’
desc = ‘Testing followAgendaItem’
htmlDesc = ‘Testing followAgendaItem.’
;
gameMain: GameMainDef
/* the initial player character is ‘harry’ */
initialPlayerChar = harry
paraBrksBtwnSubcontents = nil
usePastTense = true
;
// harry, main character
harry: Actor ‘Harry;;man self’ @roomA
“Harry. <.p>”
globalParamName = ‘harry’
isHim = true
isInitState = true
person = 3
proper = true
actorBeforeAction()
{
if(harry.location == roomA && aaron.location == roomB)
aaron.addToAgenda(followAaron);
if(harry.location == roomB2)
{
aaron.removeFromAgenda(followAaron);
aaron.moveInto(roomE);
}
}
;
roomA: Room ‘Room A’
“Now in Room A.”
north = roomB
;
roomB: Room ‘Room B’
“Now in Room B.”
north = roomC
south = roomA
west = roomB2
;
roomB2: Room ‘Room B-2’
“Now in Room B-2.”
east = roomB
;
roomC: Room ‘Room C’
“Now in Room C.”
north = roomD
south = roomB
;
roomD: Room ‘Room D’
“Now in Room D.”
north = roomE
south = roomC
;
roomE: Room ‘roomE’
“Now in Room E.”
south = roomD
;
// aaron character
aaron: Actor ‘Aaron;aaron’ @roomB
“Aaron looked every bit the high-priced, slick lawyer that he was. Short
cropped black hair ever so slightly receded from the forehead, but still
densely covering the scalp; medium height, stocky build, impeccably
dressed for the occasion. <.p>”
isHim = true
globalParamName = ‘aaron’
person = 3
bulkCapacity = 5000
;
// *********** FollowAgenda Items *****************************************
-
followAaron: FollowAgendaItem
isReady = (harry.location == roomB)
connectorList = [roomB.north, roomC.north]specialDesc()
{
if(isDone != true)
{
"Aaron waited for Harry to follow him ";switch(getActor.getOutermostRoom) { case roomB: "north to Room C. <.p>"; break; case roomC: "north to Room D. <.p>"; break; } } else inherited;
}
arrivingDesc()
{
if(nextDirection != nil)
{
“Arron hurried along the path and waited for Harry to follow him
<<nextDirection.departureName>>. <.p>”;
}
}
;
[/code]
…and here’s an uninterrupted transcript of game play…
BTW, the roomB.north and roomC.north designations in the connectorList are the result of my trying to fix the problem. I started with listing destination rooms, roomC and roomD, as was shown in the manual.
Jerry