How can I make a room display objects and exits in two side-by-side columns?
By default, rooms display their contents list and then their exit list. The @conformat and @exitformat attributes on the room control the appearance of these lists. The easiest way to get a side-by-side display is to have @conformat do nothing but store the list of objects the player can see, and to have @exitformat display both contents and exits in two columns:
&CONFORMAT here=[set(me,VISIBLE:%0)] &EXITFORMAT here= [ljust(Contents:,40)] Exits: [iter(lnum(1,max(words(v(VISIBLE)),words(%0))), %r[ljust(name(extract(v(VISIBLE),#@,1)),40)] [name(extract(%0,#@,1))])]
The CONFORMAT, which is evaluated first, stores the list of contents visible to the looker in the VISIBLE attribute. The EXITFORMAT iterates through the elements of VISIBLE and its %0 (the list of visible exits) and displays them in two columns.
(You may want to truncate the names at 40 chars, etc., as well)
2001-Mar-28 10:44am dunemush
Instead of using extract() to get at the elements of one of the lists, you can also use the mix() function to pass the corresponding elements of two (Or more) lists to an attribute. For example:
&format_line object=[ljust(name(%0), 30)][name(%1)] @conformat object= @exitformat object=[ljust(Contents, 30)] Exits%r[mix(format_lines, lvcon(me), %0, %b, %r)]
This code also uses the lvcon() function to get the list of visible contents, rather than saving the list in the @conformat. An empty @conformat is needed so you don\\\\\\\'t get the default contents list and your custom one generated in the @exitformat.
2004-Jul-24 10:47am shawnw
In recent versions of Penn(), align() allows for separation of code logic for either columns.
@conformat here= @exitformat here=align(<30 >30,Exits:%r[iter(%0,name(##),%b,%r)], Things:%r[iter(lvcon(me),name(##),%b,%r)])
Note that the >30 in align will right-align the Things list. This can easily be changed to <30 to left-align it.
2004-Jul-24 10:57am walker