Last year, inspired by Charles
"retry/restore/quit" thread, I put together a death window to show the various deaths the player has suffered in the game to the current point. I had to do a lot of things differently, such as saving variables to an external file so that restoring doesn't remove them, to make this possible.
I've put together a bare bones script in a random room's script to test getting it up and running, but now I need to make it global so that the sheet can be accessed anytime (preferably in the menubar). Here's where the problem presents itself - while migrating the code to the main script, I can get everything up and running except the ability to remove the window. I think the problem may rest with my use of the Display command, but I'm not 100% certain.
My question is should I try to make a new script for this (and how), or does it belong in an existing script (Window, User), or is the Main script a fine place for and there are just some bugs? And finally, should I not be using "display" at all and keep it all a "Print" command? If that's the case, how do I argue how to print some things and not others in a Print? Perhaps FormatPrint first?
Here is how it presented in the Roomscript:
;;; Sierra Script 1.0 - (do not remove this comment)
; Broken Bridge Forest
(script# 210)
(include sci.sh)
(include game.sh)
(use controls)
(use cycle)
(use feature)
(use game)
(use inv)
(use main)
(use obj)
(use window)
(use menubar)
(public
rm210 0
)
(local
deathWindowOpen = 0 ; Used as a switch to determine when you can close the deathWindow
deathWindow ; Used to open the display window
i = 0 ; Used in the "for"
textDown = 7 ; Used to place statements progressively lower than earlier statements
textRight = 20 ; Used to move statements right, once y-axis full - NOT YET IMPLEMENTED
[str 30] ; String for pulling text resources
)
(instance rm210 of Rm
(properties
picture scriptNumber
north 0
east 211
south 0
west 215
)
(method (init)
(super init:)
(self
setScript: RoomScript
)
(switch gPreviousRoomNumber
(else
(gEgo init: posn: 32 96)
)
)
(SetUpEgo)
)
)
(instance RoomScript of Script
(properties)
(method (changeState mainState)
(= state mainState)
)
(method (handleEvent pEvent)
(super handleEvent: pEvent)
; removes the window AND dsiplay text! I'm not sure why it disposes the display though.
(if (== deathWindowOpen 1)
(DisposeWindow deathWindow)
(= deathWindowOpen 0)
(= textDown 7)
)
(if (== (pEvent type?) evMOUSEBUTTON)
)
(if(Said 'show/death')
(= deathWindowOpen 1)
(= deathWindow (NewWindow
0
0
190
318
{Death Count}
nwNORMAL
15 ; priority
7
15
))
; For loop to run through the gDeath array and print a statement of death for each that is true
(for ( (= i 0)) (< i 9) ( (++ i)) (if (> [gDeaths i] 0)
(switch i
(0
(Display
(Format @str {You have died %u times:} [gDeaths 0])
dsCOORD 10 textDown
)
(= textDown (+ textDown 12))
)
(1
(deathCountIterator)
)
(2
(deathCountIterator)
)
(3
(deathCountIterator)
)
(4
(deathCountIterator)
)
(5
(deathCountIterator)
)
(6
(deathCountIterator)
)
(7
(deathCountIterator)
)
)
)
)
)
)
)
(procedure (deathCountIterator)
(Display
(Format @str 650 i)
dsCOORD 20 textDown
dsFONT 4
)
(= textDown (+ textDown 9))
)
Attached is how the window looks in the roomscript, and the termination command works just fine (but doesn't work well at all in the Main)