Author Topic: Retry/Restore/Quit Death Dialog  (Read 4612 times)

0 Members and 1 Guest are viewing this topic.

Offline Kawa

Re: Retry/Restore/Quit Death Dialog
« Reply #15 on: December 11, 2020, 05:49:45 AM »
I know Phil mentioned making the use statements redundant was on his TODO list at one point. Kawa, is that implemented in your latest SCICompanion build?
Sorry, negatory.

Offline Doan Sephim

Re: Retry/Restore/Quit Death Dialog
« Reply #16 on: December 14, 2020, 03:55:33 PM »
Inspired by what Charles posted here, but hopelessly frustrated by the errors due to naming conventions and other problems I was encountering, I set to work on making my own version of the death page. And as you can see from the attached picture, I've come up with something that essentially works! Charles' code was very helpful of course, and even though it doesn't have the red letters, I'd prefer a small script anyway.

The only problem, I set it up in a regular old Room Script. Anything more complicated than a Room or Region, and I'm fairly out of my depth. I did make a small effort to translate this to the main Script, but I failed.

The script uses just one global variable - an array with numbers that starts off (0) and turns on (1) when ego dies. To keep these variables true after restoring the game, I write them to an external file (thanks kawa).

So here is my request if anyone is willing to help. Could someone help me transcribe this to a non-Room Script, something that I can call from the Menubar?

Code: [Select]
;;; 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))
)
« Last Edit: December 14, 2020, 04:00:19 PM by Doan Sephim »
Artificial Intelligence Competition


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.09 seconds with 23 queries.