I'm still learning and am designing some environments as a sort of
self-teaching excercise.
In one area, I want to make it so that leaving the room through
different exists has different effects. So, for example if you go
North it would check a setting elsewhere and potentially change where
"north" leads and then update that setting.
I tried to include the actions after the direction name in the room,
but I seem to have done it wrong. I know I can do it in a really
stupid way by modifying the underlying behavior that traveling uses
throughout the game, but I'm guessing I'm just using the wrong kind of
brackets or leaving out a word. This feels like something that should
be simple, but I can't quite get it.
Thanks!
--JA
If you read up on TravelConnectors, you'll find that whenever the player
uses a travel command, a TravelConnector is invoked. Rooms themselves
are TravelConnectors, so a line like
south = livingRoom
invokes a TravelConnector. The getDestination() method of a
TravelConnector returns the destination of travel via that connector. In
a Room object, this method has the code
return self;
(You can learn all this by exploring the Library Reference Manual.) So
you could easily create your own class, derived from TravelConnector,
which would substitute a line like
return myCurrentDestination;
in that method. You could then swap in, at any time, whatever value you
like for myCurrentDestination.
Does that help?
--JA
We'll see if I can figure it out!