[DGD]A complicated mapping.
Seer Asmodean
seer_asmodean at email.com
Tue Aug 24 22:34:09 CEST 1999
This list seems a little quiet lately, so I think I'll break the silence with a
question.
My question is basically, can I set up something like this, and how do I make
it work:
mapping table_s ;
table_s = ([ "Title1": ([ "Subtitle1": ({ 1, "Short bit of text.\n", "A much
longer bit of text.\n" }),
([ "Subtitle2": ({ 2, "Short bit of text.\n", "A much longer bit of
text.\n" }) ]),
"Title2": ([ "Subtitle1": ({ 1. "Short bit of text.\n", "A much longer bit
of text.\n" }) ]) ]) ;
(That IS a mapping mapped to another mapping mapped to an array.)
I am using Windows, DGD version 1.1p7 (the pre-compiled one downloadable from
imaginary.com, dgd-1.1p7.zip), and the Melville mudlib version 0.9 I think.
So far I haven't made many changes to the lib, if this ever works it will be
part the first large alteration to it.
I need to have table_s available from inside player.c and probably from the
command bins, so it will likely have to be global.
I'm having several problems with this:
1) Where do I declare it, and where do I assign up the values? It's intended to
be a constant.
I've tried putting it in a separate .h file as above (but on one long line for
the compiler) and including it into player.c. This generates a 'Syntax Error'
when I run the mud.
I've tried turning it into a #define, the mud will run but any line of code
added to the lib to access it will cause the same unhelpful error message.
2) Assuming I'm not making an impossible request and it can be made to work,
how do I access the various elements?
My current asumption would be something like table_s["Title1"]["Subtitle2"](0)
to return 2, or table_s["Title1"]["Subtitle2"](1) for "Short bit of text.\n".
3) Is it possible to lay such code out like above, i.e split across several
lines in a nice coder-readable table? When coding it I put the whole thing on
one line, not knowing how to tell the compiler that it was all one line.
Thanks in advance for any help anyone can offer.
John Crozier.
List config page: http://list.imaginary.com/mailman/listinfo/dgd
More information about the DGD
mailing list