I have a small printing problem, I searched the forums but could not find a similar post. Any tips to steer me in a the right direction will be appreciated.
I created a DoorWay class that lists the exits via initial descriptions, the problem is,
the lounge lists the front door and the narrow passage, with the prompt printed below this output without a newline. On the other hand, when in the kitchen and because the watermelon and pumpkin are listed, there is a newline before the next prompt.
This sample transcript demonstrates my problem:
In the Lounge
The lounge is nondescript.A front door is to the south.
A narrow passage is to the east.
> go passageIn the Kitchen
The kitchen is nondescript.A narrow passage is to the west.
You can also see a watermelon and a pumpkin here.>
It is a trivial issue, but I would like to solve this problem by having consistent output, preferably with a newline printed after the last DoorWay is printed.
Am I going about this the wrong way by using the initial descriptions as my listing mechanism? And if so, what would be a better approach to this?
Below is the listing of my sample code:
!% -SD
Constant Story "";
Include "Parser";
! A door that is listed in the room description.
Class DoorWay
with
initial [;
if (self.door_dir() == u_to) {
print (A) self, " leads upward. ";
} else if (self.door_dir() == d_to) {
print (A) self, " leads downward. ";
} else {
print (A) self, " is to the ", (name) self.door_dir(), ". ";
}
],
has static door open;
[ Initialise;
location = lounge;
move pumpkin to kitchen;
move watermelon to kitchen;
];
Object lounge "In the Lounge"
with description "The lounge is nondescript.",
e_to passage,
has light;
Object kitchen "In the Kitchen"
with description "The kitchen is nondescript.",
w_to passage,
has light;
Object pumpkin "pumpkin"
with name 'pumpkin';
Object watermelon "watermelon"
with name 'watermelon';
DoorWay passage "narrow passage"
with
name 'passage',
found_in lounge kitchen,
door_to [;
if (location == lounge) return kitchen;
return lounge;
],
door_dir [;
if (location == lounge) return e_to;
return w_to;
];
DoorWay front_door "front door"
with
name 'front' 'door',
found_in lounge,
door_dir s_to;
Include "VerbLib";
Include "Grammar";