Is there a more efficient way to do the following? Perhaps by storing the data in DATA statements for retrieval by a subscripted string variable?

See code below:

// ********************************************************************************************
// room 1 - tavern
if (r=1) then
console.setOutputAttr( win.fgnd_LightGray | win.bgnd_Black );
stdout.put("You are standing in a tavern with creaky wooden floors. Laughter and",nl);
stdout.put("commotion surround you as the bartender tends to his customers. A few",nl);
stdout.put("tables and chairs are visible here. A staircase heads upstairs to the",nl);
stdout.put("second floor of the tavern.",nl);
console.setOutputAttr( win.fgnd_White | win.bgnd_Black );
stdout.put("Exits: ");
console.setOutputAttr( win.fgnd_Yellow | win.bgnd_Black );
stdout.put("<south, up>",nl);
console.setOutputAttr( win.fgnd_White | win.bgnd_Black );
endif;
// room 2 - Staircase
if (r=2) then
console.setOutputAttr( win.fgnd_LightGray | win.bgnd_Black );
stdout.put("You are standing on the upstairs hallway of the tavern. A few",nl);
stdout.put("rooms are visible up ahead, the largest of which stands to the",nl);
stdout.put("east. It appears unoccupied at the moment.",nl);
console.setOutputAttr( win.fgnd_White | win.bgnd_Black );
stdout.put("Exits: ");
console.setOutputAttr( win.fgnd_Yellow | win.bgnd_Black );
stdout.put("<down, east>",nl);
console.setOutputAttr( win.fgnd_White | win.bgnd_Black );
endif;
// room 3 - Store
if (r=3) then
console.setOutputAttr( win.fgnd_LightGray | win.bgnd_Black );
stdout.put("You are standing in the village shop. Commands here include",nl);
stdout.put("'buy <item>','sell <item>' and 'list'. A clerk is normally",nl);
stdout.put("here attending to customers.",nl);
console.setOutputAttr( win.fgnd_White | win.bgnd_Black );
stdout.put("Exits: ");
console.setOutputAttr( win.fgnd_Yellow | win.bgnd_Black );
stdout.put("<west>",nl);
console.setOutputAttr( win.fgnd_White | win.bgnd_Black );
endif;

// room 4 - Small Room
if (r=4) then
console.setOutputAttr( win.fgnd_LightGray | win.bgnd_Black );
stdout.put("You are standing in a small room. It is mostly bare, save for",nl);
stdout.put("a few wooden barrels. The only exit is back west.",nl);
console.setOutputAttr( win.fgnd_White | win.bgnd_Black );
stdout.put("Exits: ");
console.setOutputAttr( win.fgnd_Yellow | win.bgnd_Black );
stdout.put("<west>",nl);
console.setOutputAttr( win.fgnd_White | win.bgnd_Black );
endif;
// room 5 - Road
if (r=5) then
console.setOutputAttr( win.fgnd_LightGray | win.bgnd_Black );
stdout.put("You are standing on a path in the middle of town. The road",nl);
stdout.put("is quite muddy, and you notice wheel ruts in the ground. To the",nl);
stdout.put("east stands a village shop.",nl);
console.setOutputAttr( win.fgnd_White | win.bgnd_Black );
stdout.put("Exits: ");
console.setOutputAttr( win.fgnd_Yellow | win.bgnd_Black );
stdout.put("<north,south,west>",nl);
console.setOutputAttr( win.fgnd_White | win.bgnd_Black );
endif;
// room 6 - Village well
if (r=6) then
console.setOutputAttr( win.fgnd_LightGray | win.bgnd_Black );
stdout.put("You are looking down on your reflection over a deep artisan",nl);
stdout.put("well. The water rises some 100 feet below ground level, and",nl);
stdout.put("the sides are green with moss.",nl);
console.setOutputAttr( win.fgnd_White | win.bgnd_Black );
stdout.put("Exits: ");
console.setOutputAttr( win.fgnd_Yellow | win.bgnd_Black );
stdout.put("<north,south,east,west>",nl);
console.setOutputAttr( win.fgnd_White | win.bgnd_Black );
endif;
// room 7 - Small Church
if (r=7) then
console.setOutputAttr( win.fgnd_LightGray | win.bgnd_Black );
stdout.put("You are standing in a small cathedral. Several pews adorn the",nl);
stdout.put("room here, while high stained glass windows dominate the interior.",nl);
stdout.put("An altar stands to the north.",nl);
console.setOutputAttr( win.fgnd_White | win.bgnd_Black );
stdout.put("Exits: ");
console.setOutputAttr( win.fgnd_Yellow | win.bgnd_Black );
stdout.put("<north,west>",nl);
console.setOutputAttr( win.fgnd_White | win.bgnd_Black );
endif;
// room 8 - Altar
if (r=8) then
console.setOutputAttr( win.fgnd_LightGray | win.bgnd_Black );
stdout.put("You are facing a stone altar in the front of the cathedral.",nl);
stdout.put("The nave in the apse extends some twenty-five feet from center",nl);
stdout.put("to ground. A small storage room is east.",nl);
console.setOutputAttr( win.fgnd_White | win.bgnd_Black );
stdout.put("Exits: ");
console.setOutputAttr( win.fgnd_Yellow | win.bgnd_Black );
stdout.put("<south,east>",nl);
console.setOutputAttr( win.fgnd_White | win.bgnd_Black );
endif;
// room 9 - Small Room
if (r=9) then
console.setOutputAttr( win.fgnd_LightGray | win.bgnd_Black );
stdout.put("You are standing inside a small storage room. It is used to",nl);
stdout.put("store items pertaining to the church. However, some of these",nl);
stdout.put("items do not even belong to the church! (go figure)",nl);
console.setOutputAttr( win.fgnd_White | win.bgnd_Black );
stdout.put("Exits: ");
console.setOutputAttr( win.fgnd_Yellow | win.bgnd_Black );
stdout.put("<west>",nl);
console.setOutputAttr( win.fgnd_White | win.bgnd_Black );
endif;
// room 10 - Guild
if (r=10) then
console.setOutputAttr( win.fgnd_LightGray | win.bgnd_Black );
stdout.put("You are standing in a large guild room. A large crescent flag",nl);
stdout.put("with a star emblazoned on it drapes down from the ceiling. A few",nl);
stdout.put("tables and chairs are here, as well as a large fireplace.",nl);
console.setOutputAttr( win.fgnd_White | win.bgnd_Black );
stdout.put("Exits: ");
console.setOutputAttr( win.fgnd_Yellow | win.bgnd_Black );
stdout.put("<east>",nl);
console.setOutputAttr( win.fgnd_White | win.bgnd_Black );
endif;
// ********************************************************************************************

Regards,

Paul Panks
dunric@yahoo.com
Posted on 2003-04-30 15:38:12 by Paul Panks
Please see this thread http://www.asmcommunity.net/board/index.php?topic=12659

It is a 'sticky' in Main

Otherwise, sorry I was not of any help :(

Later,
Posted on 2003-05-01 07:47:45 by gorshing

Is there a more efficient way to do the following? Perhaps by storing the data in DATA statements for retrieval by a subscripted string variable?

See code below:



Regards,

Paul Panks
dunric@yahoo.com


Well, first of all take a look at the HLA switch statement in the HLA Standard Library (the HLL.HHF module).

To answer your more general question, the answer is yes.
You can create an array of strings and access that data rather than selecting the "array index" via some code sequence.

Another solution is to use objects for this purpose.
If you're familiar at all with classes and object-oriented programming in general, you'll find that room "objects" are very easy to implement using classes and the amount of code to control everything gets reduced by a huge amount.

I did an "adventure" style game once (in MASM) using the UCR Standard Library's
pattern matching routines (the HLA Standard Library pattern matching code is a
superset of the UCR stdlib pattern code). Didn't have objects at my disposal, but
the pattern matching stuff sure helped out.
Cheers,
Randy Hyde
Posted on 2003-05-02 23:02:02 by rhyde