Now I'm going crazy.
A month or so ago, I set up flags all around and they all seemed to work without a problem. I foolishly reverted to globals, but recently began to switch back to flags after figuring out a way to work with scripts to keep them positive heapwise.
But one's giving me trouble now that I can't figure out, and that's only after editing one room script.
(procedure (Btst flagEnum)
;Test a boolean game flag
(return (& [gameFlags (/ flagEnum 16)] (>> $8000 (mod flagEnum 16))))
)
(procedure (Bset flagEnum &tmp oldState)
;Set a boolean game flag
(= oldState (Btst flagEnum))
(|= [gameFlags (/ flagEnum 16)] (>> $8000 (mod flagEnum 16)))
(return oldState)
)
(procedure (Bclr flagEnum &tmp oldState)
;Clear a boolean game flag
(= oldState (Btst flagEnum))
(&= [gameFlags (/ flagEnum 16)] (~ (>> $8000 (mod flagEnum 16))))
(return oldState)
)
They are as copied directly from this thread, other than I added the return statements to bypass warnings.
But for example, if I run this:
(if (Said 'nudge/bag,trash')
(if (not (Btst fTrashMoved)) (Print 6 23) (theTrashPile ignoreControl: ctlWHITE setMotion: DPath 138 148 loop: 0) (Bset fTrashMoved)
else (Print 6 28))
)
I get the correct Print statement and theTrashPile moves, BUT it will just let me do this repeatedly and subsequent Btst fTrashMoved indicates it's false.
I have another flag, fAlleyLightBusted, that seems to stick after I throw a rock at the light... until I nudge the trash, at which point it seems to go false. Enter and leave the room multiple times, no problem, until the nudge. Neither flag even has a related Bclr; once they're set once, they should be set forever. They're also completely unrelated actions; the only Bset for fTrashMoved is the one above and, again, everything in the "if" statement happens except the flag set. fAlleyLightBusted doesn't even get set in the RoomScript, it's in a different Script (although same script doc) altogether.
Basically, it all seems fubar, at least when it comes to this damn bag. I tried setting up a test:
(if (Said 'what')
(FormatPrint "Trash Moved: %d" (Btst fTrashMoved))
(FormatPrint "Lights Out: %d" (Btst fAlleyLightBusted))
)
and find that fAlleyLightBusted does go from false to true (or, more accurately, a very large negative number, is that good?) when the rock is throw. fTrashMoved remains 0 when the nudge script kicks in. And fAlleyLightBusted goes back to 0 when the nudge script is run.
Should the test above accurately reflect flag settings, as I feel like it should?
I've double and triple checked that all previously global variables have been correctly renamed to flags (and these flags/variables only apply to this single room). The flag names match the enums given in game.sh.
Is there a way to flush print the contents of gameFlags all over so I can check if the wrong bit is getting set for the bag? I wouldn't even know how to go about fixing that, but I really just can't see anything that would cause this behavior and it's the only thought I'm having.