Still working through Learning TADS 3, getting great value out of it. Many thanks for the book(s) and for the response to my rookie questions on this forum.
I have another one.
I have implemented a character, a street person standing on a corner holding a handwritten poster.
I have an EventShuffleList of descriptions…
stateDesc = "<<eventList>>"
eventList =
[
'The unkempt man leaned his back to the lamppost, the tattered
cardboard poster held to his chest. ',
'The disheveled man continued to peer steadily at
Harry, waving the tattered cardboard from side to side over his
chest. ',
'Harry felt uncomfortable in the glare of the roughly
dressed man with the cardboard poster that could barely be read. '
];
This works fine, at each “look” command a different description is displayed.
But once the poster is read, I want a different shuffle list to be used. When I implement the following code, though, I get an index out of range exception whenever I enter the location where the street person is standing…
-
streetPersonStanding: ActorState, ShuffledEventList
{
stateDesc = “<>”
afterAction()
{
if(gRevealed(‘posterText’))
{
eventList =
[
'The unkempt man leaned his back to the lamppost, the tattered
cardboard poster held to his chest. ','The disheveled man continued to peer steadily at Harry, waving the tattered cardboard from side to side over his chest. ', 'Harry felt uncomfortable in the glare of the roughly dressed man with the cardboard poster that could barely be read. ' ]; } else { eventList = [ 'The unkempt man leaned his back to the lamppost, the tattered cardboard poster in his hand at his side. ', 'The disheveled man cast his gaze across the street, the poster at his side. ', 'The homeless man waved his poster at passing traffic. ' ]; } }
}
There is always a defined event list, one list if/else the other. I’ve tried various alternates to afterAction(), but I can’t get the event list initialized on entry to the room.
I think there is an acceptable alternative—implement before and after streetPersonStanding states—but I think it would be a bit more elegant to have it all in one actor state.
Jerry