So I’m playing around with runtime object creation, including things like TravelConnectors, while arguably not needed it’s still fun to tinker with, I’ve run into an issue however.
pleasureGarden: Room 'The Pleasure Garden'
"A room for breaking things."
intendedNorthDir = pGarden2
north()
{
if (intendedNorthDir.ofKind(Room))
{
connector = new TravelConnector();
connector.destination = intendedNorthDir;
connector.travelDesc = {: "You travel" };
pleasureGarden.north = connector;
//you can use travelvia here but that's not needed right now
}
}
;
The movement part appears to work, however displaying the TravelDesc is not something I seem to be able to get to display… I feel like I’m missing something painfully obvious here but I really am not sure what. Any help is appreciated!
When you’re assigning a method like that use setMethod(). Example:
#charset "us-ascii"
#include <adv3.h>
#include <en_us.h>
startRoom: Room 'Void' "This is a featureless void. ";
+me: Person;
northRoom: Room 'North Room' "This is the room to the north. "
south = startRoom;
versionInfo: GameID;
gameMain: GameMainDef initialPlayerChar = me;
DefineSystemAction(Foozle)
execSystemAction() {
local conn;
conn = new TravelMessage();
conn.destination = northRoom;
conn.setMethod(&travelDesc, { : "You travel, dynamically. " });
startRoom.north = conn;
defaultReport('Bingo-bango, you can now go north...o. ');
}
;
VerbRule(Foozle) 'foozle' : FoozleAction verbPhrase = 'foozle/foozling';
Transcript:
Void
This is a featureless void.
>n
You can't go that way. There are no obvious exits.
>foozle
Bingo-bango, you can now go north...o.
>n
You travel, dynamically.
North Room
This is the room to the north.
>
A couple things to note:
setMethod() is used to assign travelDesc. There are a couple other ways to do this. If I have a bunch of these sorts of things I’ll declare a subclass with a custom travelDesc that displays some other property, call it customTravelDesc, and then assign that property, customTravelDesc, on individual instances.
You don’t want a bare TravelConnector; the travelDesc stuff is defined on TravelMessage rather than TravelConnector directly.
Related to the above, depending on what you’re trying to do (and if you have a bunch of NPCs who might be moving) you might want to handle this via noteTraversal()/explainTravelBarrier()/canTravellerPass() and so on.
I use a lot of itemized lists when explaining things.