Compass Woes

So I finally ran out of space with z-code, probably due to how ridiculously chunky my code is. The problem though is that I use a z-code compass (swiped from Emily Short’s Bronze). I searched for a way to program the same compass, only in glulx and found this, emshort.wordpress.com/2007/12/17 … compasses/. However, she has since taken down the example, redirecting people to something vaguely referred to as “Erik Temple’s graphical extensions”. The problem is that one, I have no idea which one she’s referring to (though I think it might be Glulx Status Window Control?) and two, if Glulx Status Window Control is what she’s referring to, I have no idea how to use it at all or Glulx Text Effects in general. From flailing about randomly, I think I have the compass itself working, but the red for unmarked areas never happens. I’m also pretty sure that half of this code is just ignored by Inform and completely contradictory.

[code]Include Glulx Text Effects by Emily Short.
Include Menus by Emily Short.
Include Basic Help Menu by Emily Short.
Include Flexible Windows by Jon Ingold.
Include Glulx Status Window Control by Erik Temple.
Include Basic Screen Effects by Emily Short.

When play begins:
open the status window.

Table of User Styles (continued)
style name justification obliquity indentation first-line indentation boldness fixed width relative size glulx color
special-style-2 left-right-justified italic-obliquity 15 -4 light-weight proportional-font 0 g-red

The Street is a room. Not The Street is a room. Not The Street is north of The Street.

To turn screen black:
set the text color of the status window to g-white;
set the background color of the status window to g-white;
open status window;
leave space;

To turn screen white:
set the background color of the status window to g-white;
set the text color of the status window to g-black;
open status window;
leave space.

To leave space:
say paragraph break;
say paragraph break;
say paragraph break;
say paragraph break.

Table of Fancy Status
left central right
" [if in darkness]Darkness[otherwise][location][end if]" “” “[top rose]”
" [regional area]" “” “[middle rose]”
" [turn count]" “” “[bottom rose]”

To say regional area:
if in darkness, rule succeeds;
if location is in The Not Street, say “Your House”;
if location is in The Street, say “The Street”.

When play begins:
open the status window.

To say red reverse:
say second custom style.

To say black reverse:
set the background color of the status window to g-black.

To say white reverse:
set the background color of the status window to g-white.

Definition: a room is discernible:
if it is lit, yes;
if in darkness, no;
yes.

To say top rose:
let place be the room up from the location;
if the place is a discernible room, say "[if the place is unvisited][red reverse][end if]U "; otherwise say " "; [2]
let place be the room northwest from the location;
if place is a discernible room, say “[if the place is unvisited][red reverse][end if]NW”; otherwise say " ";
let place be the room north from the location;
if place is a discernible room, say "[if the place is unvisited][red reverse][end if] N "; otherwise say " ";
let place be the room northeast from the location;
if place is a discernible room, say “[if the place is unvisited][red reverse][end if]NE”; otherwise say " ".

To say middle rose:
say " ";
let place be the room west from the location;
if place is a discernible room, say "[if the place is unvisited][red reverse][end if]W "; otherwise say " ";
say " . ";
let place be the room east from the location;
if place is a discernible room, say “[if the place is unvisited][red reverse][end if] E”; otherwise say " ".

To say bottom rose:
let place be the room down from the location;
if the place is a discernible room, say "[if the place is unvisited][red reverse][end if]D "; otherwise say " ";
let place be the room southwest from the location;
if place is a discernible room, say “[if the place is unvisited][red reverse][end if]SW”; otherwise say " ";
let place be the room south from the location;
if place is a discernible room, say "[if the place is unvisited][red reverse][end if] S "; otherwise say " ";
let place be the room southeast from the location;
if place is a discernible room, say “[if the place is unvisited][red reverse][end if]SE”; otherwise say " ".

Rule for constructing the status line:
fill status bar with Table of Fancy Status;
open status window;
rule succeeds.[/code]

I don’t even know where to start. Does anyone have any advice or a site I can go to to see how to use color change in glulx or something? I read all the documentation, but I’m still hopelessly lost.

Erik Temple here. There are now a lot more extensions under my name than when Emily wrote that comment, so I can see where the confusion comes in… Her example used graphics rather than text, so I believe she was probably referring to Graphical Window Sprites (no longer maintained and not compatible with either 6Exx or 6Fxx), which included a graphical compass rose example. If you want to go the graphics route, you could use the Glimmr extensions (see my signature below) and adapt the logic of the Graphical Window Sprites example.

But you’re almost there in using Glulx Status Window Control to help recreate the text status bar, so moving to graphics probably shouldn’t be on your radar unless you have other plans for using graphics. The main problem in the code you posted is that you are using a text-grid window (the status window) for the compass, but the Glulx Text Effects extension only sets text-buffer window styles. (You have a secondary problem in that you need reset to roman type after setting the red-reverse style for each letter, but that’s not a big deal, and the code below fixes it.)

So, the main thing you need to do is make sure that you’re setting the text-grid stylehints for the styles you intend to use in text-grid windows. That requires some I6-level hacking, as you can see in the section of the revised code that replaces the Glulx Text Effects I6 routines (compare to the original Glulx Text Effects source code to see what I’ve done–it’s very simple). Note that a number of the stylehints that you were setting in your table of user styles don’t really do anything when applied to a text-grid window, so I’ve taken the liberty of blanking out the ineffectual table entries.

Also note that the status line stylehints need to be set before the custom stylehints or else you’ll get presumably undesired results (viz., a red square around the “red-reversed” text rather than a red letter). Glulx Text Effects sets the custom stylehints at nearly the earliest possible moment, in the “before starting the virtual machine” activity; my revised version of your code below uses a “first before starting the virtual machine” to hook in before this.

Note that this solution doesn’t seem to work in Quixe–you get the compass rose, but not the color changes. This may simply mean that you’d need to use custom CSS, but I don’t really know.

Some of the code in your example wasn’t actually being used (the “turn screen black” and “turn screen white” blocks, for example), but the implication seems to be that you’d like the user to be able to set the look of the status line/compass window. This isn’t really very smooth using Glulx Text Effects or my ugly hack of it, but I’ve illustrated how to get it to work–basically, you have to reset all of the stylehints, then close and reopen the status window. Use JUMP to make the status line white, WAVE to make it black again.

The code follows.

–Erik

[code]Include Glulx Text Effects by Emily Short.
Include Menus by Emily Short.
Include Basic Help Menu by Emily Short.
Include Flexible Windows by Jon Ingold.
Include Glulx Status Window Control by Erik Temple.
Include Basic Screen Effects by Emily Short.

First before starting the virtual machine:
set the background of the status window to colored;
set the text color of the status window to g-white;
set the background color of the status window to g-black.

When play begins:
open the status window.

Table of User Styles (continued)
style name justification obliquity indentation first-line indentation boldness fixed width relative size glulx color
special-style-2 – italic-obliquity – -- – -- – g-red

The Street is a room. Not The Street is a room. Not The Street is north of The Street.

Instead of jumping:
turn screen white.

Instead of waving hands:
turn screen black.

To turn screen white:
set the background of the status window to colored;
set the text color of the status window to g-black;
set the background color of the status window to g-white;
initialize user styles;
close the status window;
open status window.

To turn screen black:
set the background of the status window to colored;
set the text color of the status window to g-white;
set the background color of the status window to g-black;
initialize user styles;
close the status window;
open status window.

Table of Fancy Status
left central right
" [if in darkness]Darkness[otherwise][location][end if]" “” “[top rose]”
" [regional area]" “” “[middle rose]”
" [turn count]" “” “[bottom rose]”

To say regional area:
if in darkness, rule succeeds;
if location is in The Not Street, say “Your House”;
if location is in The Street, say “The Street”.

To say red reverse:
say second custom style.

Definition: a room is discernible:
if it is lit, yes;
if in darkness, no;
yes.

To say top rose:
let place be the room up from the location;
if the place is a discernible room, say “[if the place is unvisited][red reverse][end if]U [roman type]”; otherwise say " "; [2]
let place be the room northwest from the location;
if place is a discernible room, say “[if the place is unvisited][red reverse][end if]NW[roman type]”; otherwise say " ";
let place be the room north from the location;
if place is a discernible room, say “[if the place is unvisited][red reverse][end if] N [roman type]”; otherwise say " ";
let place be the room northeast from the location;
if place is a discernible room, say “[if the place is unvisited][red reverse][end if]NE[roman type]”; otherwise say " ".

To say middle rose:
say " ";
let place be the room west from the location;
if place is a discernible room, say “[if the place is unvisited][red reverse][end if]W [roman type]”; otherwise say " ";
say " . ";
let place be the room east from the location;
if place is a discernible room, say “[if the place is unvisited][red reverse][end if] E[roman type]”; otherwise say " ".

To say bottom rose:
let place be the room down from the location;
if the place is a discernible room, say “[if the place is unvisited][red reverse][end if]D [roman type]”; otherwise say " ";
let place be the room southwest from the location;
if place is a discernible room, say “[if the place is unvisited][red reverse][end if]SW[roman type]”; otherwise say " ";
let place be the room south from the location;
if place is a discernible room, say “[if the place is unvisited][red reverse][end if] S [roman type]”; otherwise say " ";
let place be the room southeast from the location;
if place is a discernible room, say “[if the place is unvisited][red reverse][end if]SE[roman type]”; otherwise say " ".

Rule for constructing the status line:
fill status bar with Table of Fancy Status;
rule succeeds.

Section - Modified I6 inclusions (in place of Section - I6 inclusions in Glulx Text Effects by Emily Short)

Include (-

[ SetColor S N;
glk_stylehint_set(wintype_TextBuffer, S, stylehint_TextColor, N);
glk_stylehint_set(wintype_TextGrid, S, stylehint_TextColor, N);
];

[ FixitySet S N;
N–;
glk_stylehint_set(wintype_TextBuffer, S, stylehint_Proportional, N);
glk_stylehint_set(wintype_TextGrid, S, stylehint_Proportional, N);
];

[ SetSize S N;
glk_stylehint_set(wintype_TextBuffer, S, stylehint_Size, N);
glk_stylehint_set(wintype_TextGrid, S, stylehint_Size, N);
];

[ BoldnessSet S N;
N = N-2;
glk_stylehint_set(wintype_TextBuffer, S, stylehint_Weight, N);
glk_stylehint_set(wintype_TextGrid, S, stylehint_Weight, N);
];

[ ParaIndent S N;
glk_stylehint_set(wintype_TextBuffer, S, stylehint_ParaIndentation, N);
glk_stylehint_set(wintype_TextGrid, S, stylehint_ParaIndentation, N);
];

[ Indent S N;
glk_stylehint_set(wintype_TextBuffer, S, stylehint_Indentation, N);
glk_stylehint_set(wintype_TextGrid, S, stylehint_Indentation, N);
];

[ Justification N S;
N–;
glk_stylehint_set(wintype_TextBuffer, S, stylehint_Justification, N);
glk_stylehint_set(wintype_TextGrid, S, stylehint_Justification, N);
];

[ Obliquify S N;
N–;
glk_stylehint_set(wintype_TextBuffer, S, stylehint_Oblique, N);
glk_stylehint_set(wintype_TextGrid, S, stylehint_Oblique, N);
];

-)[/code]

I’m not so sure what exactly I’m doing wrong, but the code still doesn’t change the compass color and displays oddly. When you run the code, the words/letters have a box of black surrounding them, but the bar itself is white. I had to rename the corresponding extention code in Emily Short’s Glulx Text Effects as Section - I6 inclusions, though I don’t think that plays a role (though it very well might given how little I know about all of this).

Oops, I forgot that I’m using a customized version of Glulx Text Effects that adds a bunch of sections to make things more customizable (the original is just a single text block with no section headers, meaning that you can’t replace anything). Here’s the version I’m using, if you want to try it with this:

dl.dropbox.com/u/947038/Glulx%20 … ffects.i7x

However, I tried putting section headers before and after the replaced section in the 6F95 bundled version, and that also worked fine. It sounds like you also tried that and still had troubles, though.

Maybe it’s an interpreter thing? We might be able to narrow things down if you try my gblorb in your interpreter:

dl.dropbox.com/u/947038/Compass%20Test.gblorb

–Erik

It works with your customizable Glulx Text Effects. I might have placed the headers wrong; I did label them rather haphazardly. The blocky color thing is apparently limited only to Inform 7 itself. If I package the code into a gblorb file, it’s absolutely fine.

Thank you so much for your time. Without your help, I would have never figured out how to get a functional compass.

Glad to hear it’s working for you. Are you on Windows? If so, the blocks of color you see may indicate an issue with the interpreter that’s bundled with the IDE. The game looks good to me both within the Mac IDE and as a gblorb running in Gargoyle, Zoom, and Spatterlight. (As I mentioned, Quixe ignores all of the stylehints to the status window, but this may be because the author is expected to manage the look of the window using CSS–?).

–Erik

Yep, I use Windows, though it is odd. I would think that a lot of people would be complaining if it was a Windows IDE issue (unless you are saying its a problem with just my Inform 7/computer?). It works fine on the interpeters I ran the gborb with, Gargolye and Windows Glulx.

I doubt there are many people who have changed text colors in Glulx status lines; as far as I know, Glulx Status Window Control is the only way to do it (at least, for people who don’t want to directly hack the I6 template layer). So, I don’t think it’s surprising that this might have gone unreported until now.

I believe that the Windows IDE interpreter is a variant of Windows Glulxe (though I could be wrong), so that’s interesting as well.

–Erik

That really is strange then.

Should it be reported? I mean it really is a trival thing, and I personally don’t mind.

I’ve noticed, but figured as long as it outputs okay, I don’t care that much. But the stuff I’m doing merely makes it look like the status line is split down the middle - black boxes on either side. Seems to be a result of using Eric Eve’s Exits extension.

You get used to it pretty quickly, and I didn’t even think about reporting it. I guess it is technically a bug; if it’s easy to fix, I guess it would be nice to have it fixed.

This is a bug in the Game tab of the Windows front-end: it’s ignoring the current style’s colours when clearing text grid windows. This will be fixed in the next build.