[ZIL] - Extensions with EXTRA-FLAGS

Hi, I am currently working on a little project in which I’d like to make some new flags. Additionally, I would be redefining some in-built variables, such as V-EXAMINE, V-WEAR, V-UNWEAR. My idea would be that these flags, and redefined verbs would just be in some file I could insert into my project, like an extension. However, I am, for some reason having this really weird issue where after setting EXTRA-FLAGS to include the new flags needed and made by the extension, it suddenly doesn’t know those symbols at all. I did my best to boil this down as simple as I could to find the bug, here’s the code.

"Game - Main"
<CONSTANT GAME-BANNER "Test Game">
<CONSTANT RELEASEID 1> <VERSION ZIP>

;"Including game files"
<INSERT-FILE "Parser">
<INSERT-FILE "Redefine">

<ROOM TEST-ROOM (DESC "Test Room")
    (LOC ROOMS)
    (FLAGS RLANDBIT LIGHTBIT)>

<ROUTINE GO () 
   <SETG HERE ,TEST-ROOM>
   <MOVE ,PLAYER ,HERE>
   <CRLF> <V-VERSION>
   <CRLF> <V-LOOK>
   <MAIN-LOOP>>


"Game - Redefine"

<SET REDEFINE T>
<SETG EXTRA-FLAGS '(FUNBIT WACKYBIT ZANNYBIT VERYCOOLBIT)>

<ROUTINE FOOBAR ()
    <=? ,WACKYBIT ,ZANNYBIT>
    <RTRUE>>

<ROUTINE V-WEAR ()
    <FSET? ,PRSO ,WACKYBIT>
    ;"~~REST OF NORMAL V-WEAR DEFINITION~~">

<ROUTINE V-EXAMINE ("AUX" P (N <>))
    <N=? ,ZANNYBIT ,VERYCOOLBIT>
    ;"~~REST OF NORMAL V-EXAMINE DEFINITION~~">

When trying to compile this with ZILF 0.9, whenever it comes upon those tags within Redefine.zil outside of their definition in EXTRA-FLAGS, be it in the routine FOOBAR, or the redefined verbs, it says something along the lines of: undefined global or constant: . I have tried various things to fix this, such as redefining the verbs and defining the tags in the main file, didn’t work, not redefining any builtin verbs, didn’t work. What is going on here? How do I fix this?

EDIT: After some tinkering around on my own, and so it looks like everything will compile with NO problems, IF the line defining all of those new tags are in the Main file… what on earth, why is that? More confusing to me is that the line MUST be before we include the parser with the INSERT-FILE routine. Am I missing something?

1 Like

ZIL projects can be very sensitive to the order of definitions. I’ve tried to keep it simple in ZILF: there’s only one library file to include, so the only requirements are that something has to be defined before or after including the parser.

In this case, EXTRA-FLAGS has to be defined before the parser. That’s because its value is used in parser.zil to make sure every flag is initially set on at least one object (by defining an object with the full set of flags), which is the only way to create a flag in ZIL.

2 Likes

Thank you! After reading that I tried putting just <GLOBAL EXTRA-FLAGS <>> before including the parser and redefine file, and it seems to have worked!

Also, side note, since I have been redefining V-WEAR, I seem to have found some weird behavior in it. If there is a piece of clothing inside of a container (say a shirt) and you type “WEAR SHIRT” it uses the implicit take to get it but then says You already have that. I’m not certain but I think this is due to the verb just basically calling V-TAKE, even though the syntax definition has TAKE, which I believe means it’ll automatically do implicit takes. So it will get the shirt, and try to get it again and respond with the fact you already have that.
Was the behavior of V-WEAR supposed to work like that?